Created
April 13, 2020 21:17
-
-
Save xinau/d33dc377d2ad5f9718baf26d35b8fb41 to your computer and use it in GitHub Desktop.
Building docker images using packer and ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"variables": { | |
"host": "default", | |
}, | |
"builders": [ | |
{ | |
"type": "docker", | |
"image": "debian:9.6", | |
"commit": true, | |
"run_command": [ | |
"-d", | |
"-i", | |
"-t", | |
"--name", | |
"{{user `host`}}", | |
"{{.Image}}", | |
"/bin/bash" | |
] | |
} | |
], | |
"provisioners": [ | |
{ | |
"type": "ansible", | |
"user": "root", | |
"playbook_file": "./playbook.yml", | |
"extra_arguments": [ | |
"--extra-vars", | |
"ansible_host={{user `host`}} ansible_connection=docker" | |
] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: all | |
tasks: | |
- name: "install python" | |
raw: "apt-get update && apt-get install -yq python" | |
- name: "install netcat" | |
apt: | |
state: present | |
update_cache: true | |
name: | |
- "netcat" | |
- name: "remove apt content" | |
file: | |
state: absent | |
path: "/var/lib/apt/lists/" | |
- name: "remove python" | |
apt: | |
autoremove: true | |
purge: true | |
name: | |
- python |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment