Tuesday, September 24, 2019

Puppet sandbox


In order to check your puppet script in a sandox, go to any linux server and create the following directory structure:



Create dir


/tmp/mypuppet/


Under this directory 


./modules./modules/test./modules/test/templates./modules/test/templates/test.erb./modules/test/manifests./modules/test/manifests/init.pp



Here's your manifest: 
./test.pp

puppet apply --modulepath /tmp/mypuppet/modules test.pp

In my example , this was the manifest:

test.pp :
node qtvr-wto134 {class { 'test::config': }
} 

the modules modules/test/manifests/init.pp :


class test::config ($routingRulesList = ['zzffline1', 'zzffline2', 'zzffline3'],) {
file { "/home/michael_puppet_sandbox/mypuppet/locations.include":ensure => present,content => template("test/test.erb"),}
}

 and the template modules/test/templates/test.erb :
<% @routingRulesList.each do |routingRule| -%><%=routingRule%><% end %>


and then click on

 puppet apply --modulepath /tmp/mypuppet/modules .  test.pp 


The command puppet apply --modulepath /tmp/mypuppet/modules . test.pp  will create the following output file :



puppet apply --modulepath /tmp/mypuppet/modules . test.pp
zzffline1zzffline2zzffline3