Ask Your Question

Transfer code from site.pp to common.yaml

asked 2015-12-10 07:16:41 -0500

jdhvnkl2 gravatar image

updated 2015-12-15 08:10:09 -0500

Hi, i will rewrite my question. according to what i understood from documentation, I should use yaml files with hiera instead of the regular manifest site.pp. I want instead of writing in the site.pp file to write in the common.yaml file, however i have some difficulty with the syntax of yaml. I want to write the following code in the common.yaml file:

file { '/tmp/name':  
  ensure => present,

which mean i want to create file in /tmp/ with the name "name" and ensure he is present. and writing all this in yaml file so my server will check if that file exist.

edit retag flag offensive close merge delete


Can you please rewrite you question? What do you want to achieve?

lupin gravatar imagelupin ( 2015-12-10 12:08:34 -0500 )edit

I hope now you can understan, if you cant i will rewrite again. all i want is to creeate File in remote server (on my agents) with puppet using hiera. thank you for your help

jdhvnkl2 gravatar imagejdhvnkl2 ( 2015-12-10 12:44:04 -0500 )edit

Hiera has nothing to do with creation of file nor the site.pp. The resource type file is the one that creates the file on your agent. I suggest you download the Learning VM from Puppetlabs website and do the exercise there first.

lupin gravatar imagelupin ( 2015-12-10 13:52:33 -0500 )edit

In the site.pp i can write a command that create a file on a specific agent. or do exec command. the yaml file also allow me to control the configuration of agent for example create a file on an agent. how do i write it on common.yaml (create specific file on agent)

jdhvnkl2 gravatar imagejdhvnkl2 ( 2015-12-10 14:27:14 -0500 )edit

Maybe, should i create a class that use the resource and then ise it with hiera?

jdhvnkl2 gravatar imagejdhvnkl2 ( 2015-12-10 14:52:12 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-12-15 08:20:33 -0500

Hi, you're really going to need to study Puppet a bit through the documentation, learning VM and so forth. I am going to take a very wild guess at what you're really trying to achieve - hope it helps.

# common.yaml
    ensure: 'present'

# some_class's init.pp file:
class some_class (
) {
  create_resources('file', $files)

Now this won't make much sense to you because you'll need to firstly learn about Puppet, Hiera, hashes, and the create_resources pattern. :)

Good luck!

edit flag offensive delete link more


it exactly what i was trying to achieve. although I already figured out how to do it. I am happy to see i did it like your answer. thank you so much for your help :)

jdhvnkl2 gravatar imagejdhvnkl2 ( 2015-12-15 08:38:05 -0500 )edit

Great! :)

Alex Harvey gravatar imageAlex Harvey ( 2015-12-15 08:40:54 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-12-10 07:16:41 -0500

Seen: 139 times

Last updated: Dec 15 '15