hi all, Ive been having a bit of a trouble with something that should be pretty simple. My goal is to create a host file on a node with IP address and hostname (specified in the node manifest). I created the manifests and templates below but when I use them I get a hosts file without spaces or newlines, like below. Please help me figure out how do I add the spaces and new lines? Or where in the puppet code can I trace this back to find out what is going wrong ? current hosts file: " 10.24.43.20ds.blabla.net10.24.43.35static.blabla.net10.24.43.50alert.blabla.net10.24.43.50blocked.something.com " At the bottom of the topic is the list of versions and rpms The template file looks like this: test/templates/v1_0/templates/hosts.TEMPLATE 8<--------------------- <% extra_hosts.each do |ip,address| %> <%= ip %> <%= address %> <% end %> 8<------------------- my component manifest file looks like this: test/v1_0/standard.pp 8<------------------ class test::v1_0::standard ( $extra_hosts, ) { class { "test::v1_0" : extra_hosts => "$extra_hosts", } file { "/opt/environment/" : ensure => directory, purge => true, recurse => true, force => true, mode => 0555, owner => root, group => root, } } # end of class 8<------------------ the test/v1_0.pp module file 8<---------- class test::v1_0 ( $extra_hosts, ) { file { "/opt/environment/etc" : mode => "0555", owner => "root", group => "root", purge => true, recurse => true, force => true, ensure => directory, } file { "/opt/environment/etc/hosts" : content => template(''/var/components/test/templates/v1_0/templates/hosts.TEMPLATE''), mode => "0444", owner => "root", group => "root", ensure => present, } } # end of class 8<--- And finally my node manifest: 8<------- ## Common variables ## 3rd octet of the environment $env_net = "43" # Nodes node default { class { "test::v1_0::standard" : extra_hosts => [ [ "10.24.${env_net}.20" , "ds.blabla.net" ], [ "10.24.${env_net}.35" , "static.blabla.net" ], [ "10.24.${env_net}.50" , "alert.blabla.net" ], [ "10.24.${env_net}.50" , "blocked.something.com" ], ], } } 8<- Versions: Ruby 1.8.7 Puppet 3.2.1 OS: Centos 6.3 RPMs Ruby: ruby-1.8.7.352-10.el6_4.x86_64 ruby-rdoc-1.8.7.352-10.el6_4.x86_64 rubygem-json-1.5.5-1.el6.x86_64 ruby-shadow-1.4.1-13.el6.x86_64 ruby-augeas-0.4.1-1.el6.x86_64 ruby-rgen-0.6.2-1.el6.noarch ruby-libs-1.8.7.352-10.el6_4.x86_64 ruby-irb-1.8.7.352-10.el6_4.x86_64 rubygems-1.3.7-1.el6.noarch libselinux-ruby-2.0.94-5.3.el6.x86_64 Puppet: puppet-3.2.1-1.el6.noarch puppet-server-3.2.1-1.el6.noarch puppetlabs-release-6-6.noarch -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
I think that the problem is that you are converting the array into a string: class { "test::v1_0" : extra_hosts => "$extra_hosts", } Try taking out the "; class { "test::v1_0" : extra_hosts => $extra_hosts, } On Wed, Jun 5, 2013 at 6:00 PM, mepunite <kevin.j.cross@gmail.com> wrote:> hi all, > Ive been having a bit of a trouble with something that should be pretty > simple. > My goal is to create a host file on a node with IP address and hostname > (specified in the node manifest). I created the manifests and templates > below but when I use them I get a hosts file without spaces or newlines, > like below. > > Please help me figure out how do I add the spaces and new lines? > > Or where in the puppet code can I trace this back to find out what is going > wrong ? > > current hosts file: > " > 10.24.43.20ds.blabla.net10.24.43.35static.blabla.net10.24.43.50alert.blabla.net10.24.43.50blocked.something.com > " > > At the bottom of the topic is the list of versions and rpms > > The template file looks like this: > test/templates/v1_0/templates/hosts.TEMPLATE > 8<--------------------- > > <% extra_hosts.each do |ip,address| %> > > <%= ip %> <%= address %> > > <% end %> > > 8<------------------- > > my component manifest file looks like this: > test/v1_0/standard.pp > 8<------------------ > class test::v1_0::standard > ( > $extra_hosts, > ) > { > class { "test::v1_0" : > extra_hosts => "$extra_hosts", > } > file { "/opt/environment/" : > ensure => directory, > purge => true, > recurse => true, > force => true, > mode => 0555, > owner => root, > group => root, > } > } # end of class > 8<------------------ > > the test/v1_0.pp module file > 8<---------- > class test::v1_0 > ( > $extra_hosts, > ) > { > file { "/opt/environment/etc" : > mode => "0555", > owner => "root", > group => "root", > purge => true, > recurse => true, > force => true, > ensure => directory, > } > file { "/opt/environment/etc/hosts" : > content => > template(''/var/components/test/templates/v1_0/templates/hosts.TEMPLATE''), > mode => "0444", > owner => "root", > group => "root", > ensure => present, > } > } # end of class > 8<--- > > > And finally my node manifest: > 8<------- > ## Common variables > ## 3rd octet of the environment > $env_net = "43" > # Nodes > node default { > class { > "test::v1_0::standard" : > extra_hosts => [ > [ "10.24.${env_net}.20" , > "ds.blabla.net" ], > [ "10.24.${env_net}.35" , > "static.blabla.net" ], > [ "10.24.${env_net}.50" , > "alert.blabla.net" ], > [ "10.24.${env_net}.50" , > "blocked.something.com" ], > ], > } > > } > 8<- > > Versions: > Ruby 1.8.7 > Puppet 3.2.1 > > OS: > Centos 6.3 > > RPMs > Ruby: > ruby-1.8.7.352-10.el6_4.x86_64 > ruby-rdoc-1.8.7.352-10.el6_4.x86_64 > rubygem-json-1.5.5-1.el6.x86_64 > ruby-shadow-1.4.1-13.el6.x86_64 > ruby-augeas-0.4.1-1.el6.x86_64 > ruby-rgen-0.6.2-1.el6.noarch > ruby-libs-1.8.7.352-10.el6_4.x86_64 > ruby-irb-1.8.7.352-10.el6_4.x86_64 > rubygems-1.3.7-1.el6.noarch > libselinux-ruby-2.0.94-5.3.el6.x86_64 > > Puppet: > puppet-3.2.1-1.el6.noarch > puppet-server-3.2.1-1.el6.noarch > puppetlabs-release-6-6.noarch > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > >-- Javier Fontán Muiños Project Engineer OpenNebula - The Open Source Toolkit for Data Center Virtualization www.OpenNebula.org | jfontan@opennebula.org | @OpenNebula -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
That is exactly the problem ... Thanks you saved me hours of head scratching. On Wednesday, June 5, 2013 5:06:38 PM UTC+1, Javi Fontan wrote:> > I think that the problem is that you are converting the array into a > string: > > class { "test::v1_0" : > extra_hosts => "$extra_hosts", > } > > Try taking out the "; > > class { "test::v1_0" : > extra_hosts => $extra_hosts, > } > > On Wed, Jun 5, 2013 at 6:00 PM, mepunite <kevin....@gmail.com<javascript:>> > wrote: > > hi all, > > Ive been having a bit of a trouble with something that should be pretty > > simple. > > My goal is to create a host file on a node with IP address and hostname > > (specified in the node manifest). I created the manifests and templates > > below but when I use them I get a hosts file without spaces or newlines, > > like below. > > > > Please help me figure out how do I add the spaces and new lines? > > > > Or where in the puppet code can I trace this back to find out what is > going > > wrong ? > > > > current hosts file: > > " > > > 10.24.43.20ds.blabla.net10.24.43.35static.blabla.net10.24.43.50alert.blabla.net10.24.43.50blocked.something.com > > " > > > > At the bottom of the topic is the list of versions and rpms > > > > The template file looks like this: > > test/templates/v1_0/templates/hosts.TEMPLATE > > 8<--------------------- > > > > <% extra_hosts.each do |ip,address| %> > > > > <%= ip %> <%= address %> > > > > <% end %> > > > > 8<------------------- > > > > my component manifest file looks like this: > > test/v1_0/standard.pp > > 8<------------------ > > class test::v1_0::standard > > ( > > $extra_hosts, > > ) > > { > > class { "test::v1_0" : > > extra_hosts => "$extra_hosts", > > } > > file { "/opt/environment/" : > > ensure => directory, > > purge => true, > > recurse => true, > > force => true, > > mode => 0555, > > owner => root, > > group => root, > > } > > } # end of class > > 8<------------------ > > > > the test/v1_0.pp module file > > 8<---------- > > class test::v1_0 > > ( > > $extra_hosts, > > ) > > { > > file { "/opt/environment/etc" : > > mode => "0555", > > owner => "root", > > group => "root", > > purge => true, > > recurse => true, > > force => true, > > ensure => directory, > > } > > file { "/opt/environment/etc/hosts" : > > content => > > > template(''/var/components/test/templates/v1_0/templates/hosts.TEMPLATE''), > > mode => "0444", > > owner => "root", > > group => "root", > > ensure => present, > > } > > } # end of class > > 8<--- > > > > > > And finally my node manifest: > > 8<------- > > ## Common variables > > ## 3rd octet of the environment > > $env_net = "43" > > # Nodes > > node default { > > class { > > "test::v1_0::standard" : > > extra_hosts => [ > > [ "10.24.${env_net}.20" , > > "ds.blabla.net" ], > > [ "10.24.${env_net}.35" , > > "static.blabla.net" ], > > [ "10.24.${env_net}.50" , > > "alert.blabla.net" ], > > [ "10.24.${env_net}.50" , > > "blocked.something.com" ], > > ], > > } > > > > } > > 8<- > > > > Versions: > > Ruby 1.8.7 > > Puppet 3.2.1 > > > > OS: > > Centos 6.3 > > > > RPMs > > Ruby: > > ruby-1.8.7.352-10.el6_4.x86_64 > > ruby-rdoc-1.8.7.352-10.el6_4.x86_64 > > rubygem-json-1.5.5-1.el6.x86_64 > > ruby-shadow-1.4.1-13.el6.x86_64 > > ruby-augeas-0.4.1-1.el6.x86_64 > > ruby-rgen-0.6.2-1.el6.noarch > > ruby-libs-1.8.7.352-10.el6_4.x86_64 > > ruby-irb-1.8.7.352-10.el6_4.x86_64 > > rubygems-1.3.7-1.el6.noarch > > libselinux-ruby-2.0.94-5.3.el6.x86_64 > > > > Puppet: > > puppet-3.2.1-1.el6.noarch > > puppet-server-3.2.1-1.el6.noarch > > puppetlabs-release-6-6.noarch > > > > > > > > > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Puppet Users" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to puppet-users...@googlegroups.com <javascript:>. > > To post to this group, send email to puppet...@googlegroups.com<javascript:>. > > > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > > > -- > Javier Fontán Muiños > Project Engineer > OpenNebula - The Open Source Toolkit for Data Center Virtualization > www.OpenNebula.org | jfo...@opennebula.org <javascript:> | @OpenNebula >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.