6

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

krishna g
  • 461
  • 1
  • 5
  • 15

2 Answers2

5
{
    "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
krishna g
  • 461
  • 1
  • 5
  • 15
1

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]"
    ]
  }
],
Chaim Eliyah
  • 2,743
  • 4
  • 24
  • 37
John L.
  • 11
  • 2