Skip to content

Commit dd4ae1b

Browse files
committed
Add preliminary ansible playbook
All this does right now is install the right packages.
1 parent 6af8177 commit dd4ae1b

File tree

5 files changed

+132
-0
lines changed

5 files changed

+132
-0
lines changed

Diff for: README.md

+34
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,37 @@ overrides in environment variables:
4040
interfaces)
4141
* The directory containing the git repositories with `SITE_DIR` (defaults to
4242
`sites` in the current directory)
43+
44+
Ansible configuration
45+
=====================
46+
47+
When running on DigitalOcean hosting, an Ansible playbook is used to configure
48+
the server with consistent settings.
49+
50+
Setup
51+
-----
52+
53+
Before you can run our ansible playbooks, you need to meet the following
54+
prerequisites:
55+
56+
* Create a DigitalOcean API token, and pass it to the inventory generator by
57+
setting the `DO_API_TOKEN` environment variable.
58+
* Set the vault decryption password of the ansible vaulted file with our
59+
secrets. This may be done by setting the `VAULT_PASSWORD` environment
60+
variable.
61+
* Download all the collections the playbooks depend on with the following
62+
command:
63+
```
64+
ansible-galaxy collection install \
65+
--requirements-file collections/requirements.yml
66+
```
67+
68+
You may wish to use [direnv](https://direnv.net/) to set environment variables.
69+
70+
Running
71+
-------
72+
73+
There is currently only one playbook:
74+
75+
* `matplotlib.org.yml`, for the main matplotlib.org hosting. This playbook
76+
operates on droplets with the `website` tag in DigitalOcean.

Diff for: ansible.cfg

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[defaults]
2+
3+
inventory = {{CWD}}/inventories
4+
5+
interpreter_python = auto
6+
7+
# plays will gather facts by default, which contain information about
8+
# the remote system.
9+
#
10+
# smart - gather by default, but don't regather if already gathered
11+
# implicit - gather by default, turn off with gather_facts: False
12+
# explicit - do not gather by default, must say gather_facts: True
13+
gathering = smart
14+
15+
# if set to a persistent type (not 'memory', for example 'redis') fact values
16+
# from previous runs in Ansible will be stored. This may be useful when
17+
# wanting to use, for example, IP information from one group of servers
18+
# without having to talk to them in the same playbook run to get their
19+
# current IP information.
20+
fact_caching = jsonfile
21+
# This option tells Ansible where to cache facts. The value is plugin dependent.
22+
# For the jsonfile plugin, it should be a path to a local directory.
23+
# For the redis plugin, the value is a host:port:database triplet: fact_caching_connection = localhost:6379:0
24+
fact_caching_connection = /tmp
25+
26+
# Enabling pipelining reduces the number of SSH operations required to
27+
# execute a module on the remote server. This can result in a significant
28+
# performance improvement when enabled, however when using "sudo:" you must
29+
# first disable 'requiretty' in /etc/sudoers
30+
#
31+
# By default, this option is disabled to preserve compatibility with
32+
# sudoers configurations that have requiretty (the default on many distros).
33+
#
34+
pipelining = True

Diff for: collections/requirements.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
collections:
3+
- name: community.general
4+
- name: community.digitalocean

Diff for: inventories/inventory.digitalocean.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
plugin: community.digitalocean.digitalocean
3+
api_token: "{{ lookup('env', 'DO_API_TOKEN') }}"
4+
attributes:
5+
- id
6+
- name
7+
- memory
8+
- vcpus
9+
- disk
10+
- size
11+
- image
12+
- networks
13+
- volume_ids
14+
- tags
15+
- region
16+
keyed_groups:
17+
- key: do_tags | lower
18+
prefix: ''
19+
separator: ''
20+
compose:
21+
ansible_host: do_networks.v4 | selectattr('type','eq','public')
22+
| map(attribute='ip_address') | first
23+
class: do_size.description | lower
24+
distro: do_image.distribution | lower

Diff for: matplotlib.org.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
- hosts: website
3+
tasks:
4+
- name: Enable copr
5+
ansible.builtin.dnf:
6+
name: "dnf-command(copr)"
7+
state: present
8+
- name: Enable caddy copr
9+
community.general.copr:
10+
name: "@caddy/caddy"
11+
state: enabled
12+
13+
- name: Install server maintenance
14+
ansible.builtin.dnf:
15+
name: "fail2ban"
16+
state: present
17+
18+
- name: Install web server requirements
19+
ansible.builtin.dnf:
20+
name:
21+
- caddy
22+
- git
23+
- mailcap
24+
- python3-aiohttp
25+
state: present
26+
27+
- name: Install server monitoring tools
28+
ansible.builtin.dnf:
29+
name:
30+
- golang-github-prometheus
31+
- golang-github-prometheus-alertmanager
32+
- golang-github-prometheus-node-exporter
33+
- grafana
34+
# Remove this when Loki is packaged.
35+
- podman
36+
state: present

0 commit comments

Comments
 (0)