Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [will@neuromancer shapeshift-code-challenge]$ cat provision-ec2.yml
- ---
- - hosts: localhost
- connection: local
- gather_facts: false
- roles:
- - role: provision-ec2
- - hosts: docker-atomic
- remote_user: centos
- gather_facts: false
- roles:
- - role: docker
- [will@neuromancer shapeshift-code-challenge]$ cat roles/provision-ec2/tasks/main.yml
- ---
- - name: spin up Docker host in EC2
- ec2:
- aws_access_key: ***
- aws_secret_key: ***
- image: ami-1f492e73
- instance_type: t2.micro
- key_name: shapeshift-code-challenge
- region: sa-east-1
- zone: sa-east-1a
- wait: yes
- instance_tags:
- Name: atomic-host
- register: ec2
- - name: add host to group
- add_host:
- name: "{{ item.public_ip }}"
- groups: docker-atomic
- with_items: "{{ ec2.instances }}"
- - name: wait for VM to boot up
- wait_for:
- host: "{{ item.public_ip }}"
- port: 22
- delay: 10
- timeout: 300
- state: started
- with_items: "{{ ec2.instances }}"
- [will@neuromancer shapeshift-code-challenge]$ cat roles/docker/tasks/main.yml
- ---
- - name: ensure docker is running
- service:
- name: docker
- state: running
- - name: log in to Docker Hub
- docker_login:
- username: williamstiern
- password: supersecretpassword
- email: william.stiern@gmail.com
- - name: run bitcoind container
- docker_container:
- name: bitcoind
- image: williamstiern/shapeshift-code-challenge-bitcoin
- state: started
- detach: true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement