{
  "variables": {
    "aws_access_key": null,
    "aws_secret_key": null,
    "openstack_host": null,
    "openstack_username": null,
    "openstack_password": null,
    "openstack_tenant_id": null,
    "repository_url": null,
    "role": null
  },
  "builders": [
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline_shebang": "/bin/bash -x",
      "inline": [
        "if [ -f /tmp/packer-create-image.sh ]; then",
        "  sudo /tmp/packer-create-image.sh",
        "fi",

        "cd /tmp",
        "git clone {{user `repository_url`}} pattern",
        "cd /tmp/pattern/resources/chef-repo",
        "berks vendor cookbooks",
        "sudo chef-solo -j /tmp/pattern/resources/chef-repo/roles/{{user `role`}}.json"
      ]
    }
  ]
}

{
  "variables": {
    "repository_url": null,
    "revision": null,
    "role": null
  },
  "builders": [
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline_shebang": "/bin/bash -x",
      "inline": [
        "if [ -f /tmp/packer-create-image.sh ]; then",
        "  sudo /tmp/packer-create-image.sh",
        "fi",

        "cd /tmp",
        "git clone {{user `repository_url`}} pattern",

        "cd /tmp/pattern",
        "git checkout {{user `revision`}}",

        "cd /tmp/pattern/resources/chef-repo",
        "berks vendor cookbooks",
        "sudo chef-solo -j /tmp/pattern/resources/chef-repo/roles/{{user `role`}}.json"
      ]
    }
  ]
}

Change variables and checkout specified branch when provisioning in template
Change variables and checkout specified branch when provisioning in template
