Corey Osman
2011-May-05 00:40 UTC
[Puppet Users] variables inside a template for my hp ilo device
I am writing a hp ilo module to automatically assign a static ip that is derived from the IP of the system which is fed in via facter. I basically just need to change the network the ilo is connected to. The ruby code works great inside the irb console. However, puppet doesn''t seem to be able to use the variable I have derived from the ipaddress. This is my first template so I am not exactly sure if I can use ruby syntax inside a template. Any ideas on how I can accomplish this? # Define the two variables which will be used to determin which network the ilo will go on ilonet = ''21'' gwbit = ''240'' dns = ''10.0.1.19'' netmask = ''255.255.255.0'' iparray = ipaddress.split(''.'') iloip = iparray[0] + ''.'' + iparray[1] + ''.'' + iparray[2] + ''.'' + ilonet gwarray = iloip.split(''.'') gateway = gwarray[0] + ''.'' + gwarray[1] + ''.'' + gwarray[2] + ''.'' + gwbit <RIBCL VERSION="2.0"> <LOGIN USER_LOGIN="adminname" PASSWORD="password"> <SERVER_INFO MODE="write"> <SERVER_NAME value ="<%= hostname %>"/> </SERVER_INFO> <RIB_INFO MODE="write"> <MOD_NETWORK_SETTINGS> <SPEED_AUTOSELECT VALUE = "Y"/> <IP_ADDRESS VALUE = "<%= iloip %>"/> <SUBNET_MASK VALUE = "<%= netmask %>"/> <GATEWAY_IP_ADDRESS VALUE = "<%= gateway %>"/> <DNS_NAME VALUE = "ilo-<%= hostname %>"/> <PRIM_DNS_SERVER value = "<%= dns %>"/> <DHCP_ENABLE VALUE = "N"/> <DOMAIN_NAME VALUE = ""/> </MOD_NETWORK_SETTINGS> </RIB_INFO> <USER_INFO MODE="write"> <ADD_USER USER_NAME="User" USER_LOGIN="admin" PASSWORD="changeme"> <ADMIN_PRIV value ="Y"/> <REMOTE_CONS_PRIV value ="Y"/> <RESET_SERVER_PRIV value ="Y"/> <VIRTUAL_MEDIA_PRIV value ="Y"/> <CONFIG_ILO_PRIV value="Yes"/> </ADD_USER> </USER_INFO> </LOGIN> </RIBCL> -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Daniel Pittman
2011-May-05 19:05 UTC
Re: [Puppet Users] variables inside a template for my hp ilo device
On Wed, May 4, 2011 at 17:40, Corey Osman <corey@logicminds.biz> wrote:> I am writing a hp ilo module to automatically assign a static ip that is derived from the IP of the system which is fed in via facter. I basically just need to change the network the ilo is connected to. > > The ruby code works great inside the irb console. However, puppet doesn''t seem to be able to use the variable I have derived from the ipaddress. This is my first template so I am not exactly sure if I can use ruby syntax inside a template.It should be just fine you you wrap it in the "Ruby escape": <% example = 12 * 12 %> <%= example %> => 144 If you want, though, you can use the erb command line tool that ships with Ruby to make the transformation for you. ''erb -x foo.erb'' will spit out the transformed Ruby to generate your content, and you can inspect that to see exactly how this is working. Regards, Daniel -- ⎋ Puppet Labs Developer – http://puppetlabs.com ✉ Daniel Pittman <daniel@puppetlabs.com> ✆ Contact me via gtalk, email, or phone: +1 (877) 575-9775 ♲ Made with 100 percent post-consumer electrons -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.