Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [DIGITALOCEAN]
- localhost ansible_connection=local
- [PROVISION]
- TEST1
- TEST2
- TEST3
- [DROPLETS]
- TEST1 ansible_ssh_host=x.x.x.x
- TEST2 ansible_ssh_host=y.y.y.y
- See, this one never seems to make it in... It changes too, and they get unordered too.
- ---
- - hosts: PROVISION
- gather_facts: no
- vars:
- do_token: TOKEN
- tasks:
- - name: Create new droplet
- digital_ocean: >
- state=present
- command=droplet
- name={{ inventory_hostname }}
- unique_name=yes
- size_id=512mb
- region_id=nyc3
- image_id=ubuntu-18-04-x64
- ssh_key_ids=KEY
- api_token={{ do_token }}
- wait=yes
- wait_timeout=500
- register: hostname
- delegate_to: localhost
- - name: Add host to Ansible config
- lineinfile:
- dest: "/etc/ansible/hosts"
- insertafter: '^[DROPLETS]'
- state: present
- line: "{{ hostname.droplet.name }} ansible_ssh_host={{ hostname.droplet.ip_address }}"
- delegate_to: localhost
Add Comment
Please, Sign In to add comment