krishna g
krishna g

Reputation: 461

How to override Attributes in packer chef solo provisioner

My packer code contains packer chef solo provisioner

{

  "type": "chef-solo",
  "cookbook_paths": ["chef/cookbooks/vendor"],
  "run_list": ["recipe[cicada-jenkins-cookbook::default]","recipe[cicada-jenkins-cookbook::support_tools]","recipe[cicada-jenkins-cookbook::cft_seed_dsl]","recipe[cicada-jenkins-cookbook::terraform_seed_dsl]"]

}

In here i need to overide attributes how can i pass them in packer

Upvotes: 6

Views: 2855

Answers (2)

John L.
John L.

Reputation: 11

Rather than overriding the values in your Packer "json" attribute, try defining your attribute overrides in a Chef role. Then just point to the location of the roles directory on your local disk using 'roles_path'.

"provisioners":
[
  { 
    "type": "chef-solo",
    "cookbook_paths": ["cookbooks"],
    "roles_path": "cookbooks/dev-boxes/roles",
    "run_list": [
      "role[java]",
      "role[sbt]",
      "recipe[dev-boxes::recipe1]",
      "recipe[dev-boxes::recipe2]"
    ]
  }
],

Upvotes: 1

krishna g
krishna g

Reputation: 461

{
    "type": "chef-solo",
    "cookbook_paths": ["chef/cookbooks/vendor"],
    "roles_path": "chef/roles",
    "json": {
          "jenkins": {
            "master": {
              "port": 8080
            },
            "executor": {
              "timeout": 300
            }
          },
          "jenkins-cookbook": {
            "admin_user": "uname",
            "admin_pass": "pwd"
          }
    },
    "run_list":["role[jenkins]"]
}
  • as per the packer documentation we can pass the node attributes in the form of json

Upvotes: 5

Related Questions