Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

How to use .each in site.pp

$
0
0
My environment: Oracle Linux V6.7 Puppet Agent 4.2.3 Puppet Server 2.1.2 Facter 3.1.1 ---------------------------------------- I'm fairly new to Puppet and still finding my way through things. I am using structured facts via key=value pairs in /opt/puppetlabs/facter/facts.d/myfacts.txt. This is working and I'm able to parse the local client facts as needed. However...I have one situation where I'm not being successful - when one fact will contain one or more values. I have a local fact: my_role=["A", "B", "C"] In my site.pp I am trying to do this: $my_role.each |$specialrole| { case $specialrole { 'A': { file {"/tmp/special_A": ensure => present, } } 'B': { file {"/tmp/special_B": ensure => present, } } 'C': { file {"/tmp/special_C": ensure => present, } } } } I've tried several different permutations of the above setup but all without success. I'm not getting any syntax errors or any errors at all from puppet agent --test.....but I'm also not getting the results. Nothing happens. Note: the exact actions in each case are not all just a file/ensure action...I'm using the above only as an example of my end goal. A more realistic example would be a server that is both a database server and a web server. I want to do certain things for a db server; and other certain things for a web server. Any suggestions are quite welcome. There's probably a better way of achieving the desired results - I'm just not familiar enough with Puppet to know what else to do. Any suggestions or guidance is very welcome. Thank you.

Viewing all articles
Browse latest Browse all 6104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>