Ask Your Question
0

Parsing a file in a machine and some questions.

asked 2015-03-16 16:21:13 -0500

jimsonpai gravatar image

Hi all I am trying to play with puppet a little I've got few questions. I'll appreciate if someone can answer it for me.

  • 1) So I got a puppet and a puppet master. in puppet's /etc/testing, there's a file call readme. It contains a number either 1 or 0.

I want it so that when I run puppet agent -t in my puppet machine; if the readme file contain 1 then create a file in /etc/ call hello. if it's 0 then do not create any file. So bascially if readme have 1 then execute the following in my init.pp

file { '/etc/hello':
        ensure => present,
        source => 'puppet:///<mydirectory>/<myfile>',
        owner => root,
        group => root,
        mode => 0755,
   }

how to do that anybody?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-03-16 17:29:37 -0500

lavaman gravatar image

Any time you want the master to respond to the current condition of the agent machine, you need a custom fact. Then you can use conditional logic in your manifest to decide whether to apply a resource based on the fact value.

https://docs.puppetlabs.com/facter/2....

edit flag offensive delete link more

Comments

Thanks. It's very helpful but I am confuse on how can I integrate it in manifest. Best if there's a simple example on reading files in agent.

jimsonpai gravatar imagejimsonpai ( 2015-03-16 19:54:53 -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

Stats

Asked: 2015-03-16 16:21:13 -0500

Seen: 43 times

Last updated: Mar 16 '15