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