Amod Pandey
Amod Pandey

Reputation: 1396

chef-client override runlist does not update attributes on the server

I have a cookbook with attributes. I add a recipe from this cookbook to run list of a node. I run chef-client on that node and see the attributes and their values on the chef server. Later I made changes to cookbook attributes, uploaded the cookbook, ran that specific recipe using -o option. I do not see the updated values of the attributes on the chef server.

I read somewhere that -o option does not update the chef server. So is it that we should not use -o option frequently and use it only for development purpose.

If the cookbook was always run through -o option can not see the attributes and the recipe on the node attribute on the server (which I think is bad?).

Thanks Amod

Upvotes: 1

Views: 3841

Answers (2)

aabes
aabes

Reputation: 208

While I agree with the sentiment that you're probably doing it wrong, if you need to override the runlist one way of achieving it is:

a) create /etc/chef/alternative.json, with the content below filled with your alternative runlist:

{"run_list":[]}

b) make sure you have the “real” runlist of the node in e.g. /etc/chef/first-boot.json

c) Periodically run the command below to refresh statistics

chef-client -j /etc/chef/empty.json

d) when you really want to converge the node, use:

chef-client -j /etc/chef/first-boot.json

Upvotes: 1

Tensibai
Tensibai

Reputation: 15784

the -o option is there to allow a chef-run with a totally different runlist than usual, thus not saving it to chef-server.

If you need to run periodically with -o, you're probably doing it wrong. Make your recipe idempotent or change it so it can be enabled for a run using a flag somewhere (node attribute or data-bag item) without modifying the node run list

Without the use case it's hard to give a correct advice on how to address this.

Upvotes: 0

Related Questions