@@ -38,6 +38,9 @@ prerequisites:
38
38
39
39
* Create a DigitalOcean API token, and pass it to the inventory generator by
40
40
setting the ` DO_API_TOKEN ` environment variable.
41
+ * If you are creating a new droplet, and want to configure DNS as well, then
42
+ create a CloudFlare API token, and pass it to the Ansible playbook by setting
43
+ the ` CLOUDFLARE_TOKEN ` environment variable.
41
44
* Set the vault decryption password of the Ansible vaulted file with our
42
45
secrets. This may be done by setting the ` ANSIBLE_VAULT_PASSWORD_FILE `
43
46
environment variable to point to a file containing the password.
@@ -99,9 +102,11 @@ Naming
99
102
We follow a simplified version of the naming scheme on [ this blog
100
103
post] ( https://mnx.io/blog/a-proper-server-naming-scheme/ ) :
101
104
102
- * Servers are named ` <prefix>.matplotlib.org ` in A records.
103
- * Servers get a functional CNAME alias (e.g., ` web01.matplotlib.org ` ).
104
- * matplotlib.org is a CNAME to the functional CNAME of a server.
105
+ * Servers are named ` <prefix>.matplotlib.org ` in A records, pointing to the
106
+ IPv4 address of the droplet.
107
+ * Servers get a functional CNAME alias (e.g., ` web01.matplotlib.org ` ) pointing
108
+ to the hostname ` <prefix>.matplotlib.org ` .
109
+ * matplotlib.org is a CNAME alias of the functional CNAME of a server.
105
110
106
111
We use [ planets in our Solar System] ( https://namingschemes.com/Solar_System )
107
112
for the name prefix. When creating a new server, pick the next one in the list.
@@ -113,51 +118,34 @@ The summary of the initial setup is:
113
118
114
119
1 . Create the droplet with monitoring and relevant SSH keys.
115
120
2 . Assign new droplet to the matplotlib.org project and the Web firewall.
116
- 3 . Grab the SSH host fingerprints.
117
- 4 . Reboot.
121
+ 3 . Add DNS entries pointing to the server on CloudFlare.
122
+ 4 . Grab the SSH host fingerprints.
123
+ 5 . Reboot.
118
124
119
- We currently use a simple $10 droplet from DigitalOcean. You can create one
120
- from the control panel, or using the ` doctl ` utility. Be sure to enable
121
- monitoring, and add the ` website ` tag and relevant SSH keys to the droplet. An
122
- example of using ` doctl ` is the following:
125
+ We currently use a simple $12 droplet from DigitalOcean. You can create one
126
+ from the control panel, or using the ` create.yml ` Ansible playbook:
123
127
124
128
```
125
- doctl compute droplet create \
126
- --image fedora-35-x64 \
127
- --region tor1 \
128
- --size s-1vcpu-2gb \
129
- --ssh-keys <key-id>,<key-id> \
130
- --tag-name website \
131
- --enable-monitoring \
132
- venus.matplotlib.org
129
+ ansible-playbook create.yml
133
130
```
134
131
135
- Note, you will have to use ` doctl compute ssh-key list ` to get the IDs of the
136
- relevant SSH keys saved on DigitalOcean, and substitute them above. Save the ID
137
- of the new droplet from the output, e.g., in:
132
+ This playbook will prompt you for 3 settings:
138
133
139
- ```
140
- ID Name Public IPv4 Private IPv4 Public IPv6 Memory VCPUs Disk Region Image VPC UUID Status Tags Features Volumes
141
- 294098687 mpl.org 2048 1 50 tor1 Fedora 35 x64 new website monitoring,droplet_agent
142
- ```
143
-
144
- the droplet ID is 294098687.
134
+ 1 . The host name of the droplet, which should follow the naming convention
135
+ above.
136
+ 2 . The functional CNAME alias of the droplet.
137
+ 3 . The names of SSH keys to add to the droplet.
145
138
146
-
147
- You should also assign the new droplet to the ` matplotlib.org ` project and the
148
- ` Web ` firewall:
139
+ You may also pass these directly to Ansible as:
149
140
150
141
```
151
- doctl projects list
152
- # Get ID of the matplotlib.org project from the output.
153
- doctl projects resources assign <project-id> --resource=do:droplet:<droplet-id>
154
-
155
-
156
- doctl compute firewall list
157
- # Get ID of the Web firewall from the output.
158
- doctl compute firewall add-droplets <firewall-id> --droplet-ids <droplet-id>
142
+ ansible-playbook create.yml --extra-vars "host=pluto functional=web99 ssh_keys='a b c'"
159
143
```
160
144
145
+ The playbook will create the server, as well as add DNS records on CloudFlare.
146
+ Note, you must set ` DO_API_TOKEN ` and ` CLOUDFLARE_TOKEN ` in the environment to
147
+ access these services.
148
+
161
149
Then, to ensure you are connecting to the expected server, you should grab the
162
150
SSH host keys via the DigitalOcean Droplet Console:
163
151
@@ -181,14 +169,6 @@ Finally, you should reboot the droplet. This is due to a bug in cloud-init on
181
169
DigitalOcean, which generates a new machine ID after startup, causing system
182
170
logs to be seem invisible.
183
171
184
- DNS setup
185
- ---------
186
-
187
- 1 . Add an A record for ` <prefix>.matplotlib.org ` to the IPv4 address of the new
188
- droplet.
189
- 2 . Add a CNAME record for ` webNN.matplotlib.org ` pointing to the given
190
- ` <prefix.matplotlib.org> ` .
191
-
192
172
Running Ansible
193
173
---------------
194
174
0 commit comments