Skip to content

Instantly share code, notes, and snippets.

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 wrouesnel/ae6901f65ed5b0c3f65a51965a943223 to your computer and use it in GitHub Desktop.
Save wrouesnel/ae6901f65ed5b0c3f65a51965a943223 to your computer and use it in GitHub Desktop.
# Ansible playbook to use a transient EC2 image to build the container
- name: Creating a disposable worker
hosts: localhost
connection: local
tasks:
- name: locating latest docker host AMI
ec2_ami_find:
region: eu-central-1
owner: self
name: debian-8-docker-*
sort: name
sort_end: 1
no_result_action: fail
register: ami_find
- name: deploying temporary instance
ec2:
region: eu-central-1
key_name: "root_key"
image: "{{ ami_find.results[0].ami_id }}"
instance_type: t2.micro
instance_tags:
role: docker-build-instance
wait: true
wait_timeout: 600
register: ec2result
- add_host: name={{ ec2result.instances[0].private_ip }} groups=workers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment