is there any any wat to create directoryies using hiera

71 views
Skip to first unread message

Supriya Uppalapati

unread,
May 28, 2014, 3:03:45 PM5/28/14
to puppet...@googlegroups.com
Hi,
 
I have created directories in puppet/manifests/init.pp
 
 more init.pp
class createdirectory {
   file { [ "/u01/app/","/u01/oracle", "/u01/oracle/product",  ]:
      ensure => "directory",
      owner  => "oracle",
      group  => "oinstall",
      recurse => true,
      mode   => 755,
}
}

 
But, now I want to specify the "/u01/app/","/u01/oracle", "/u01/oracle/product"  this contents using hiera. Is there any way to do this.
 
Let me know.
 
 

Jeremy T. Bouse

unread,
May 28, 2014, 3:24:25 PM5/28/14
to puppet...@googlegroups.com
On 28.05.2014 11:03, Supriya Uppalapati wrote:
> Hi,
>
> I have created directories in puppet/manifests/init.pp
>
> more init.pp
> class createdirectory {
> file { [ "/u01/app/","/u01/oracle", "/u01/oracle/product", ]:
> ensure => "directory",
> owner => "oracle",
> group => "oinstall",
> recurse => true,
> mode => 755,
> }
> }
>
> But, now I want to specify the "/U01/APP/","/U01/ORACLE",
> "/U01/ORACLE/PRODUCT" this contents using hiera. Is there any way to
> do this.
>
> LET ME KNOW.
>

Setup something like...

some_oracle_variable:
- /u01/app
- /u01/oracle
- /u01/oracle/product

in your hiera data then update your init.pp to include something
like...

class createdirectory {
$some_directories = hiera_array('some_oracle_variable', [])
file { $some_directories:
ensure => "directory",
owner => "oracle",
group => "oinstall",
recurse => true,
mode => 755,
}
}

But that's just spit balling it off the cuff and without actually
testing.

jcbollinger

unread,
May 29, 2014, 1:34:53 PM5/29/14
to puppet...@googlegroups.com


Note well: you do not need hiera_array() just because the data are in the form of an array.  The plain hiera() function will return an array if that is in fact the type of the data.  The hiera_array() function has significantly different semantics, collecting data from all levels of the hierarchy instead of from only the highest-priority level where the data appear.

 
   file { $some_directories:
     ensure  => "directory",
     owner   => "oracle",
     group   => "oinstall",
     recurse => true,
     mode    => 755,
   }
}

But that's just spit balling it off the cuff and without actually
testing.


It looks ok to me, except as noted above.

It could also be done by parameterizing the class and relying on automated data binding instead of an explicit lookup.  Many people seem to prefer that approach, but I don't find the advantages -- and there are one or two -- to be particularly compelling.


John

Reply all
Reply to author
Forward
0 new messages