[chef] failing to feed run_list to first-boot.json from userdata


Chronological Thread 
  • From:
  • To: chef < >
  • Subject: [chef] failing to feed run_list to first-boot.json from userdata
  • Date: Fri, 20 Jan 2012 11:10:05 -0800


hai. i'm failing to feed a run_list present in ec2 userdata to a
first-boot.json file. what am i doing wrong? maybe run_list shouldn't
be within attributes? (see userdata below).

i'm using a client.rb based on jtimberman's gist. my modification
is here: https://gist.github.com/1648988

my knife ec2 launch command:

knife ec2 server create -N "testme" -S sshkey -f m1.large -I \
ami-xxx -G sg-xxx,sg-xxx --user-data /tmp/userdata --distro distroX

# distroX
bash -c '
S3CFG="--config=/root/.s3cfg-w-https"
S3CMDOPT="--force $S3CFG"
X_ENV=dev
X_AV_REGION=us-east-1
S3_BUCKET="x-ops-$X_ENV-$X_AV_REGION"
s3cmd get $S3CMDOPT s3://$S3_BUCKET/chef/client.frak.rb /etc/chef/client.rb
/usr/bin/chef-client -j /etc/chef/first-boot.json -l debug -L 
/var/log/chef/client.log
'


and the output from the launch:

Waiting for sshd....done
Bootstrapping Chef on ec2-xx-xx-xx-xx.compute-1.amazonaws.com
ec2-xx-xx-xx-xx.compute-1.amazonaws.com 
s3://x-ops-dev-east-1/chef/client.frak.rb -> /etc/chef/client.rb  [1 of 1]
 1502 of 1502   100% in    0s    10.31 kB/s  done
ec2-xx-xx-xx-xx.compute-1.amazonaws.com FATAL: I cannot find 
/etc/chef/first-boot.json



:/etc/chef#
 curl -s http://169.254.169.254/latest/user-data
{
    "validation_key": "-----BEGIN RSA PRIVATE KEY-----\nMIxx_snip\n",
    "attributes": {
        "role": "chefsrv",
        "node_name_override": "testme",
        "env": "dev",
        "cluster": "dev",
        "vol_list": [
            "vol-f1xxxx",
            "vol-p3xxxx"
        ],
        "run_list": [
            "role[base]",
            "role[postfix-client]",
            "role[syslog-ng-client]"
        ]
    },
    "chef_server": "https://10.xx.xx.113";,
    "validation_client_name": "chef-validator"
}



i tried another test of this by placing run_list at the same level as
attributes in the userdata.

Waiting for sshd..done
Bootstrapping Chef on ec2-50-yy-yy-xx.compute-1.amazonaws.com
ec2-50-yy-yy-xx.compute-1.amazonaws.com 
s3://x-ops-dev-us-east-1/chef/client.frak.rb -> /etc/chef/client.rb  [1 of 1]
 1507 of 1507   100% in    0s    10.35 kB/s  done
ec2-50-yy-yy-xx.compute-1.amazonaws.com 
/usr/lib/ruby/1.8/chef/client.rb:313:in `converge': undefined method 
`run_list' for nil:NilClass (NoMethodError)
ec2-50-yy-yy-xx.compute-1.amazonaws.com  from 
/usr/lib/ruby/1.8/chef/client.rb:87:in `run'
ec2-50-yy-yy-xx.compute-1.amazonaws.com  from 
/usr/lib/ruby/1.8/chef/application/client.rb:215:in `run_application'
ec2-50-yy-yy-xx.compute-1.amazonaws.com  from 
/usr/lib/ruby/1.8/chef/application/client.rb:207:in `loop'
ec2-50-yy-yy-xx.compute-1.amazonaws.com  from 
/usr/lib/ruby/1.8/chef/application/client.rb:207:in `run_application'
ec2-50-yy-yy-xx.compute-1.amazonaws.com  from 
/usr/lib/ruby/1.8/chef/application.rb:62:in `run'
ec2-50-yy-yy-xx.compute-1.amazonaws.com  from /usr/bin/chef-client:25

:/etc/chef#
 cat first-boot.json
[
  "role[base]",
  "role[postfix-client]",
  "role[syslog-ng-client]"
:/etc/chef#
 




also, within this block (from client.rb), what does "json_attribs" do?

if chef_config.has_key?("run_list")
  File.open("/etc/chef/first-boot.json", "w") do |f|
    f.print(JSON.pretty_generate(chef_config["run_list"]))
  end
  json_attribs "/etc/chef/first-boot.json"
end


thanks!
kallen




Archive powered by MHonArc 2.6.16.

§