Skip to content

Commit

Permalink
Add more information to droplet creation
Browse files Browse the repository at this point in the history
Also, set tags in CloudFlare DNS.
  • Loading branch information
QuLogic committed Feb 14, 2025
1 parent 749216a commit 7f8359f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ ansible-playbook create.yml --extra-vars "host=pluto functional=web99 ssh_keys='

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

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

This can be done from the Console, or via the CLI:

```
doctl compute droplet-action reboot <droplet-id>
```

Running Ansible
---------------

Expand Down
2 changes: 1 addition & 1 deletion collections/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
collections:
- name: ansible.posix
- name: community.general
version: ">=2.0.0"
version: ">=8.0.0"
- name: community.digitalocean
17 changes: 17 additions & 0 deletions create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
map(attribute='ip_address') |
first
}}
tags:
- website
zone: matplotlib.org

- name: Setup functional DNS for droplet on CloudFlare
Expand All @@ -124,8 +126,23 @@
record: "{{ functional }}"
type: CNAME
value: "{{ host }}.matplotlib.org"
tags:
- website
zone: matplotlib.org

- name: Print droplet info
ansible.builtin.debug:
msg:
- "Droplet ID is {{ new_droplet.data.droplet.id }}"
- >-
First Public IPv4 is {{
(new_droplet.data.droplet.networks.v4 | selectattr('type', 'equalto', 'public')).0.ip_address |
default('<none>', true) }}
- >-
First Private IPv4 is {{
(new_droplet.data.droplet.networks.v4 | selectattr('type', 'equalto', 'private')).0.ip_address |
default('<none>', true) }}
vars:
# We currently name servers based on planets in the Solar System.
valid_planets:
Expand Down

0 comments on commit 7f8359f

Please sign in to comment.