3

How can I bootstrap the run list of a node in chef server with one of the predefined roles, when the node is created dynamically (not using knife)?

Cloudify installs the node (an ubuntu image with chef client) and starts chef client, which registers with chef server. A new node and client is created in chef server, but the node's run list is empty. I want to populate the run list with mongo role so that MongoDB is installed on the node and configured. If I manually create the node in the chef server with mongo role in run list before running the cloudify process, then mongo is installed and everything is fine. However, this is not an option though because of autoscaling and other requirements. So how can we automate creating a node in chef server with role in run list?

  • Chef server is configured with cookbooks and roles. One of these roles is mongo, whose runlist has recipes to install and configure MongoDB.
  • Cloudify installs chef client on a ubuntu image. This is the node.
  • /etc/chef/client.rb file has following:

    log_level             :debug
    log_locaiton          "/var/log/chef/client.log"
    ssl_verification_mode :verify_none
    chef_server_url       "htts://chefserver/organizations/orgname"
    verify_api_cert       false
    node_name             SOME_GUID
    
Srini K
  • 3,315
  • 10
  • 37
  • 47
  • 1
    You need to bootstrap the node with a `run_list` that includes the role... – sethvargo Aug 05 '14 at 21:30
  • I know how to do that when creating the node manually from UI or with knife. But how can I do that when node comes up and starts its chef client, which in turn registers with chef server. Now the chef server has a node which should be bootstrapped with run_list. It is not practical for this bootstrapping process to be a manual step. The question is how to automate the run_list bootstrapping process. Is there somewhere in configuration we can specify the role this node should play or can this be scripted and executed from somewhere before the node registers? – Srini K Aug 06 '14 at 13:52
  • 3
    Populate `/etc/chef/first-boot.json` and run `chef-client -j /etc/chef/first-boot.json` – sethvargo Aug 06 '14 at 14:59
  • Thanks. Exactly what I needed. Works now. – Srini K Aug 06 '14 at 18:25

1 Answers1

0

Role is a specific case of a runlist. See docs for example (search for role[)

Ilya Sher
  • 601
  • 5
  • 4
  • According to the answer Srini accepted it appears to me that Cloudify is not used as designed (among other things to control Chef client configuration and runs). Could you please tell which parts of your system are controlled by Cloudify? Maybe show the blueprint? – Ilya Sher Aug 08 '14 at 11:27