{
  "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`}}",

        "if [ -f /tmp/pattern/events/init/user-setup ]; then",
        "  sudo ruby /tmp/pattern/events/init/user-setup",
        "fi",
      ]
    }
  ]
}

{
  "variables": {
    "repository_url": null,
    "revision": null,
    "role": null
  },
  "builders": [
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline_shebang": "/bin/bash -x",
      "inline": [
        "if [ ! -d /opt/cloudconductor/patterns ]; then",
        "  sudo mkdir -p /opt/cloudconductor/patterns",
        "fi",

        "sudo git clone {{user `repository_url`}} /opt/cloudconductor/patterns",

        "cd /opt/cloudconductor/patterns/*",
        "git checkout {{user `revision`}}",

        "if [ -f ./events/init/user-setup ]; then",
        "  sudo ruby ./events/init/user-setup",
        "fi"
      ]
    }
  ]
}

Change directory that contains pattern repository from /tmp to /opt/cloudconductor
Change directory that contains pattern repository from /tmp to /opt/cloudconductor
