Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - hosts: localhost
- connection: local
- vars_files:
- - vars.yml
- vars_prompt:
- - name: do_name
- prompt: "Name of server"
- private: no
- - name: do_dns
- prompt: "DNS name to bind (press return for none)"
- private: no
- tasks:
- - name: Register SSH key
- digital_ocean: >
- state=present
- command=ssh
- name="{{ do_ssh_name }}"
- ssh_pub_key="{{ do_ssh_pub_key }}"
- api_token={{ do_api_token }}
- register: do_droplet
- - name: Register Droplet
- digital_ocean: >
- state=active
- command=droplet
- name={{ do_name }}
- region_id={{ do_region }}
- size_id={{ do_size }}
- image_id={{ do_image }}
- ssh_key_ids={{ do_droplet.ssh_key.id }}
- unique_name=yes
- api_token={{ do_api_token }}
- wait_timeout=600
- register: do_droplet
- - name: Register DNS
- digital_ocean_domain: >
- state=present
- name="{{ do_dns }}"
- id="{{ do_droplet.droplet.id }}"
- api_token={{ do_api_token }}
- when: do_dns|length > 0
- - debug: msg="IP is {{ do_droplet.droplet.ip_address }}"
- - name: Add new droplet to inventory
- add_host: >
- name="{{ do_name }}"
- groups=dohosts
- ansible_ssh_host="{{ do_droplet.droplet.ip_address }}"
- ansible_ssh_user=root
- ssh_private_key_file="{{ do_ssh_private_key }}"
- ### need these for xenial
- # - name: apt-get update
- # raw: apt-get update -qq
- # - name: Install python 2.7
- # raw: apt-get install -qq python2.7
- - hosts: dohosts
- gather_facts: no
- vars_files:
- - defaults/main.yml
- - vars.yml
- # by using pre_tasks, we can get all this preliminary stuff (especially the 'wait') scheduled before
- # the actual role executes
- pre_tasks:
- - name: Wait for new host to come up
- local_action: wait_for host={{ ansible_ssh_host }} port=22 state=started delay=10
- - setup:
- - include: tasks/swap.yml
- - include: tasks/software.yml
- - include: tasks/security.yml
- - include: tasks/users.yml
- handlers:
- - include: handlers/site.yml
- # install all the goodness
- roles:
- - qualitybox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement