@@ -38,6 +38,9 @@ prerequisites:
3838
3939* Create a DigitalOcean API token, and pass it to the inventory generator by
4040 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.
4144* Set the vault decryption password of the Ansible vaulted file with our
4245 secrets. This may be done by setting the ` ANSIBLE_VAULT_PASSWORD_FILE `
4346 environment variable to point to a file containing the password.
@@ -99,9 +102,11 @@ Naming
99102We follow a simplified version of the naming scheme on [ this blog
100103post] ( https://mnx.io/blog/a-proper-server-naming-scheme/ ) :
101104
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.
105110
106111We use [ planets in our Solar System] ( https://namingschemes.com/Solar_System )
107112for 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:
113118
1141191 . Create the droplet with monitoring and relevant SSH keys.
1151202 . 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.
118124
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:
123127
124128```
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
133130```
134131
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:
138133
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.
145138
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:
149140
150141```
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'"
159143```
160144
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+
161149Then, to ensure you are connecting to the expected server, you should grab the
162150SSH host keys via the DigitalOcean Droplet Console:
163151
@@ -181,14 +169,6 @@ Finally, you should reboot the droplet. This is due to a bug in cloud-init on
181169DigitalOcean, which generates a new machine ID after startup, causing system
182170logs to be seem invisible.
183171
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-
192172Running Ansible
193173---------------
194174
0 commit comments