Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.47 KB | None | 0 0
  1. [will@neuromancer shapeshift-code-challenge]$ cat provision-ec2.yml
  2. ---
  3. - hosts: localhost
  4.   connection: local
  5.   gather_facts: false
  6.   roles:
  7.     - role: provision-ec2
  8.  
  9. - hosts: docker-atomic
  10.   remote_user: centos
  11.   gather_facts: false
  12.   roles:
  13.     - role: docker
  14.  
  15. [will@neuromancer shapeshift-code-challenge]$ cat roles/provision-ec2/tasks/main.yml
  16. ---
  17. - name: spin up Docker host in EC2
  18.   ec2:
  19.     aws_access_key: ***
  20.     aws_secret_key: ***
  21.     image: ami-1f492e73
  22.     instance_type: t2.micro
  23.     key_name: shapeshift-code-challenge
  24.     region: sa-east-1
  25.     zone: sa-east-1a
  26.     wait: yes
  27.     instance_tags:
  28.       Name: atomic-host
  29.   register: ec2
  30.  
  31. - name: add host to group
  32.   add_host:
  33.     name: "{{ item.public_ip }}"
  34.     groups: docker-atomic
  35.   with_items: "{{ ec2.instances }}"
  36.  
  37. - name: wait for VM to boot up
  38.   wait_for:
  39.     host: "{{ item.public_ip }}"
  40.     port: 22
  41.     delay: 10
  42.     timeout: 300
  43.     state: started
  44.   with_items: "{{ ec2.instances }}"
  45.  
  46. [will@neuromancer shapeshift-code-challenge]$ cat roles/docker/tasks/main.yml
  47. ---
  48. - name: ensure docker is running
  49.   service:
  50.     name: docker
  51.     state: running
  52.  
  53. - name: log in to Docker Hub
  54.   docker_login:
  55.     username: williamstiern
  56.     password: supersecretpassword
  57.     email: william.stiern@gmail.com
  58.  
  59. - name: run bitcoind container
  60.   docker_container:
  61.     name: bitcoind
  62.     image: williamstiern/shapeshift-code-challenge-bitcoin
  63.     state: started
  64.     detach: true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement