This repository has been archived by the owner on Feb 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
launch.yml
68 lines (60 loc) · 1.66 KB
/
launch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
- 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"
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_python_interpreter=/usr/bin/python3
ansible_ssh_host="{{ do_droplet.droplet.ip_address }}"
ansible_ssh_user=root
ansible_ssh_private_key_file="{{ do_ssh_private_key }}"
- hosts: dohosts
vars_files:
- defaults/main.yml
- vars.yml
tasks:
- include: tasks/swap.yml
- include: tasks/software.yml
- include: tasks/security.yml
- include: tasks/users.yml
handlers:
- include: handlers/site.yml