[chef] Variables in attributes file


Chronological Thread 
  • From: Alex < >
  • To: Chef Mailinglist < >
  • Subject: [chef] Variables in attributes file
  • Date: Tue, 3 Sep 2013 22:50:44 -0400

Is it possible to create attributes based on a dynamic variables?


# Example

default['ipdns']['#{int}']['address'] = '#{ip}'


# Code

node['network']["interfaces"].each do | int, parms |

  if int =~ /eth/

    File.open("/etc/sysconfig/network-scripts/ifcfg-#{int}") do |f|

      f.each_line do |line|

        if line.strip == ">

          node['network']["interfaces"]["#{int}"]["addresses"].each do |ip, params|

            if params['family'] == ('inet')

              #puts "#{int} - #{ip}"

              #puts "default['ipdns']['#{int}']['address'] = '#{ip}'"

              default['ipdns']['#{int}']['address'] = '#{ip}'

              #puts { "int" => "{int}", "ip" => "{ip}" }

            end

          end

        end

      end

    end

  end

end




Archive powered by MHonArc 2.6.16.

§