knife - Why Aren't My Chef Normal Attributes Persisted? -


i need persist values between runs of chef-client on node. chef docs thought normal attributes intended

"at beginning of chef-client run, default, override, , automatic attributes reset...normal attributes never reset...at conclusion of chef-client run, default, override, , automatic attributes disappear, leaving collection of normal attributes persist until next chef-client run.")

however, if bootstrap node following recipe twice

log 'message'   message "before setting #{node['my_key']}"   level :warn end  node.normal['my_key'] = 'my value'  log 'message'   message "after setting #{node['my_key']}"   level :warn end 

i expect see

before setting value

on 2nd run (as value persisted 1st run). reverts unset again.

is possible value persist? need run recipe in different way? or not possible?

edit: far can see chef run completes successfully. here command , output:

mfreake@my-linux:/export/apps/chef/chef-repo/cookbooks$ knife bootstrap node1.blah.com --ssh-user mfreake --ssh-password 'yaddayadda' --sudo --use-sudo-password  --bootstrap-proxy 'http://proxy.blah.com/' -n node1 --run-list persist_test::read_set_read node node1 exists, overwrite it? (y/n) y client node1 exists, overwrite it? (y/n) y creating new client node1 creating new node node1 connecting node1.marketpipe.com node1.blah.com [sudo] password mfreake: -----> existing chef installation detected node1.blah.com starting first chef client run... node1.blah.com starting chef client, version 12.4.2 node1.blah.com resolving cookbooks run list: ["persist_test::read_set_read"] node1.blah.com synchronizing cookbooks: node1.blah.com   - persist_test node1.blah.com compiling cookbooks... node1.blah.com [2015-09-30t17:45:40+01:00] warn: cloning resource attributes log[message] prior resource (chef-3694) node1.blah.com [2015-09-30t17:45:40+01:00] warn: previous log[message]: /var/chef/cache/cookbooks/persist_test/recipes/read_set_read.rb:2:in `from_file' node1.blah.com [2015-09-30t17:45:40+01:00] warn: current  log[message]: /var/chef/cache/cookbooks/persist_test/recipes/read_set_read.rb:9:in `from_file' node1.blah.com converging 2 resources node1.blah.com recipe: persist_test::read_set_read node1.blah.com   * log[message] action write[2015-09-30t17:45:40+01:00] warn: message add log.  node1.blah.com  node1.blah.com    node1.blah.com   * log[message] action write[2015-09-30t17:45:40+01:00] warn: message add log. value node1.blah.com  node1.blah.com    node1.blah.com  node1.blah.com running handlers: node1.blah.com running handlers complete node1.blah.com chef client finished, 2/2 resources updated in 1.621458795 seconds 

ok, there's 2 cases node state, including attributes not saved on chef-server:

  1. when run end in error (here depending on error, state saved anyway, it's out of scope question)
  2. running chef-client -o any_recipe_list -ooption here temporarily override runlist, won't save chef-server not overwrite actual run list.

node.normal , node.set same thing, writing values in node object stored on server. examples in documentation on attributes

here problem due use of knife bootstrap (with version > 12.1 per documentation on validator less bootstrap) start creating node on chef-server , client key. calling twice , allowing overwrite previous object reset whole node object.

the bootstrap shoudl used once, chef-client run later should triggered way (crontab, knife ssh, etc.)


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -