Skip to content

Instantly share code, notes, and snippets.

@likwid
Created March 10, 2015 22:06
Show Gist options
  • Save likwid/54da88038763bc68476e to your computer and use it in GitHub Desktop.
Save likwid/54da88038763bc68476e to your computer and use it in GitHub Desktop.
---
- name: Find ubuntu ami_id
ec2_ami_search:
distro: ubuntu
release: trusty
region: "{{ aws_region }}"
store: ebs-ssd
virt: hvm
register: ubuntu
when: not aws_ami_id is defined
- name: Use user-defined ami
set_fact:
current_ami: "{{ aws_ami_id }}"
when: aws_ami_id is defined
- name: Use ubuntu lookup ami
set_fact:
current_ami: "{{ ubuntu.ami }}"
when: not aws_ami_id is defined
- name: Create a docker host instance
ec2:
count: 1
group_id: "{{ aws_default_sg }}"
key_name: wm-infrastructure
image: "{{ current_ami }}"
instance_type: "{{ aws_instance_type }}"
instance_tags:
Name: "{{ name_tag }}"
Type: pairing
region: "{{ aws_region }}"
vpc_subnet_id: "{{ aws_subnet_id }}"
wait: yes
register: docker_host
- name: Create docker btrfs volume
ec2_vol:
device_name: "{{ vol_disk_device }}"
encrypted: yes
instance: "{{ item.id }}"
region: "{{ aws_region }}"
volume_size: 100
with_items: docker_host.instances
- name: Add created host to docker group
add_host:
name: "{{ item.private_ip }}"
groups: dockers
with_items: docker_host.instances
- name: Register private_ip for later use
set_fact:
docker_instance_private_ip: "{{ docker_host.instances[0].private_ip }}"
- name: Wait for ssh port
wait_for:
host: "{{ item.private_ip }}"
port: 22
with_items: docker_host.instances
---
- hosts: localhost
gather_facts: yes
sudo: no
roles:
- { role: aws-docker, name_tag: "{{ hostname }}" }
- hosts: dockers
gather_facts: yes
remote_user: ubuntu
sudo: no
pre_tasks:
- name: Add wellmatch-dev key to box temporarily
copy:
src: /home/ubuntu/.ssh/wellmatch-dev.id_rsa
dest: /home/{{ ansible_ssh_user }}/.ssh/id_rsa
mode: 0600
owner: "{{ ansible_ssh_user }}"
group: "{{ ansible_ssh_user }}"
sudo: yes
roles:
- { role: newrelic-server-monitor, purpose: pairing }
- { role: btrfs-docker, disk_device: "{{ docker_device }}" }
- platform-bootstrap
- hosts: tag_Name_acceptance-proxy
remote_user: ubuntu
gather_facts: yes
sudo: no
roles:
- { role: acceptance-proxy-virtual-host, environment: dev }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment