Skip to content

Commit 7f8359f

Browse files
committed
Add more information to droplet creation
Also, set tags in CloudFlare DNS.
1 parent 749216a commit 7f8359f

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ ansible-playbook create.yml --extra-vars "host=pluto functional=web99 ssh_keys='
148148

149149
The playbook will create the server, as well as add DNS records on CloudFlare.
150150
Note, you must set `DO_API_TOKEN` and `CLOUDFLARE_TOKEN` in the environment to
151-
access these services.
151+
access these services. The droplet ID and IP address will be printed at the
152+
end of the playbook.
152153

153154
Then, to ensure you are connecting to the expected server, you should grab the
154155
SSH host keys via the DigitalOcean Droplet Console:
@@ -173,6 +174,12 @@ Finally, you should reboot the droplet. This is due to a bug in cloud-init on
173174
DigitalOcean, which generates a new machine ID after startup, causing system
174175
logs to be seem invisible.
175176

177+
This can be done from the Console, or via the CLI:
178+
179+
```
180+
doctl compute droplet-action reboot <droplet-id>
181+
```
182+
176183
Running Ansible
177184
---------------
178185

collections/requirements.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
collections:
33
- name: ansible.posix
44
- name: community.general
5-
version: ">=2.0.0"
5+
version: ">=8.0.0"
66
- name: community.digitalocean

create.yml

+17
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@
115115
map(attribute='ip_address') |
116116
first
117117
}}
118+
tags:
119+
- website
118120
zone: matplotlib.org
119121

120122
- name: Setup functional DNS for droplet on CloudFlare
@@ -124,8 +126,23 @@
124126
record: "{{ functional }}"
125127
type: CNAME
126128
value: "{{ host }}.matplotlib.org"
129+
tags:
130+
- website
127131
zone: matplotlib.org
128132

133+
- name: Print droplet info
134+
ansible.builtin.debug:
135+
msg:
136+
- "Droplet ID is {{ new_droplet.data.droplet.id }}"
137+
- >-
138+
First Public IPv4 is {{
139+
(new_droplet.data.droplet.networks.v4 | selectattr('type', 'equalto', 'public')).0.ip_address |
140+
default('<none>', true) }}
141+
- >-
142+
First Private IPv4 is {{
143+
(new_droplet.data.droplet.networks.v4 | selectattr('type', 'equalto', 'private')).0.ip_address |
144+
default('<none>', true) }}
145+
129146
vars:
130147
# We currently name servers based on planets in the Solar System.
131148
valid_planets:

0 commit comments

Comments
 (0)