Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@petrkohut
Last active July 17, 2017 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petrkohut/336bee9df011d7b053415039f2a9ea60 to your computer and use it in GitHub Desktop.
Save petrkohut/336bee9df011d7b053415039f2a9ea60 to your computer and use it in GitHub Desktop.

image.json

{
  "builders": [
    {
      "type": "docker",
      "image": "ubuntu",
      "commit": true
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "/usr/bin/apt-get update",
        "/usr/bin/apt-get -y install ansible"
      ]
    },
    {
      "type": "ansible-local",
      "playbook_file": "./playbook.yml",
      "playbook_dir": "./",
      "extra_arguments": [ "-vvv" ]
    }
  ],
  "post-processors": [
    [
      {
        "type": "docker-tag",
        "repository": "docker-image-with-ansible-installed",
        "tag": "latest"
      }
    ]
  ]
}

playbook.yml

---
-
  hosts: all
  become: true
  tasks:
    - name: Say Hello
      command: echo "Hello World!"

packer build image.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment