[chef] Re: Re: Dynamic template path.


Chronological Thread 
  • From: Colin Leavett-Brown < >
  • To: " " < >
  • Subject: [chef] Re: Re: Dynamic template path.
  • Date: Tue, 22 May 2012 11:46:02 -0700

Sorry, I've just seen the typo in the template definition. Colin.

On 05/22/2012 11:42 AM, Colin Leavett-Brown wrote:
I hope this isn't something stupid like a typo. I was beginning to
believe that a template could not specify a variable path. Here's the info:

The attribute:

default['nimbus']['control']['network_bridge'] = 'br0'

The recipe:

   template "/etc/sysconfig/network-scripts/ifcfg-" +
node['nimbus'['control']['network_bridge'] do
       source "bridg.erb"
       owner "root"
       group "root"
       mode "0644"
   end

The template:

DEVICE=<%= node['nimbus']['control']['network_bridge'] %>
TYPE=Bridge
BOOTPROTO=static
IPADDR=<%= node['ipaddress'] %>
NETMASK=255.255.255.0
ONBOOT=yes
DELAY=0
NM_CONTROLLED=no

The error:


 nimbus]$ knife cookbook upload nimbus
Uploading nimbus             [0.0.1]
FATAL: Cookbook file recipes/KVM_VMM_control_node.rb has a ruby syntax
error:
FATAL:
/hepuser/crlb/Git/chef-repo/cookbooks/nimbus/recipes/KVM_VMM_control_node.rb:45:
syntax error, unexpected kDO, expecting ']'
FATAL:
/hepuser/crlb/Git/chef-repo/cookbooks/nimbus/recipes/KVM_VMM_control_node.rb:50:
syntax error, unexpected kEND, expecting $end

 nimbus]$

Thanks for your help, Colin.

On 05/22/2012 11:26 AM, Jesse Campbell wrote:
can we see a little more of your recipe? I do something similar in my
recipes without issue.

-Jesse

On Tue, May 22, 2012 at 2:09 
PM,< >
   wrote:
I need to create a template for network scripts, eg:

template "/etc/sysconfig/network-scripts/ifcfg-xxx" do
.
end

Where "xxx" is specified in either default or override attributes. I have
tried:

template "/etc/sysconfig/network-scripts/ifcfg-xxxi#{node['xxx']}" do
template "/etc/sysconfig/network-scripts/ifcfg-" + node['xxx'] do

path = "/etc/sysconfig/network-scripts/ifcfg-" + node['xxx']
template path do

but all give knife upload errors of the form:
FATAL:
/hepuser/crlb/Git/chef-repo/cookbooks/nimbus/recipes/KVM_VMM_control_node.rb:46:
syntax error, unexpected tIDENTIFIER, expecting ']'

Suggestions please.



Archive powered by MHonArc 2.6.16.

§