Creating a directory

79 views
Skip to first unread message

Max Hoopmann

unread,
Feb 13, 2014, 10:18:52 AM2/13/14
to puppet...@googlegroups.com
Hello folks

I'm fairly new to puppet/foreman, and I don't quiet understand how to do one of the most simple things.
I have a puppetmaster and a puppet agent. If I add

# create a directory     
file { "/tmp/test342423423":
    ensure => "directory",
}

to the site.pp and do a puppetrun on the master or puppet agent --test on the agent everythings works fine and I can see the directory "test342423423".

But now I want to do this via the foreman UI. I can create a new provisioning template connect it with the correct OS and environment, but when I do a puppetrun in the browser with the foreman UI nothing happens. Even if I run "puppet agent --test" on the agent the directory won't be created.

Can someone briefly explain how to do these kind of provisioning?

Kind regards!

zerozer...@gmail.com

unread,
Feb 14, 2014, 5:10:55 AM2/14/14
to puppet...@googlegroups.com
On Thursday, February 13, 2014 4:18:52 PM UTC+1, Max Hoopmann wrote:
 
But now I want to do this via the foreman UI. I can create a new provisioning template connect it with the correct OS and environment, but when I do a puppetrun in the browser with the foreman UI nothing happens. Even if I run "puppet agent --test" on the agent the directory won't be created.

I think you need to enclose your resource declaration inside a class, in the init.pp file or in a separate .pp file.
Then in Foreman GUI you can go to Configuration -> Puppet classes and import your class, so you can associate it to your host in the host edit page.
It _should_ work. ;)

Marco

jcbollinger

unread,
Feb 14, 2014, 9:43:19 AM2/14/14
to puppet...@googlegroups.com


Just so.  External node classifiers (ENCs) such as Foreman cannot specify individual resources to Puppet.  They can specify only classes (c.f. classifier) and top-scope variables.  Wrap your declaration in a class, put the class where Puppet can find it, and use Foreman to declare that class for those nodes that should have it.

Putting your declarations into classes is best practice anyway.  Putting ordinary resource declarations directly at the top level of a manifest -- especially site.pp -- tells Puppet that they apply to every managed machine, with no exceptions.  That is rarely appropriate.

Personally, I would recommend developing a working familiarity with Puppet itself before adding Foreman or any other ENC to the mix.  It will be easier, and you will have a better understanding of what Foreman is doing for you (and what it isn't).  Overall, I think you will get better, faster.

To that end, Puppet's online docs are pretty good: http://docs.puppetlabs.com/puppet/3/reference/.  The "The Puppet Language" and "Modules"/"Fundamentals" sections are required reading.  It would be a good idea to also at least skim several of the "Generated References" subsections, especially "Resource Types" and "Functions".  Still, nothing beats actually using the system.  Almost everything you will learn and produce by building your manifest set without an ENC will remain relevant when (if) you add an ENC.


John

Reply all
Reply to author
Forward
0 new messages