summaryrefslogtreecommitdiff
path: root/playbook.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'playbook.yaml')
-rw-r--r--playbook.yaml266
1 files changed, 3 insertions, 263 deletions
diff --git a/playbook.yaml b/playbook.yaml
index ebeefd5..7a9dc79 100644
--- a/playbook.yaml
+++ b/playbook.yaml
@@ -7,84 +7,11 @@
- name: Ensure XMPP server is set up
gather_facts: false
hosts: all
+ roles:
+ - bootstrap
+ - munin-node
tasks:
- - name: Ensure all authorized keys are copied to root account
- remote_user: root
- ansible.posix.authorized_key:
- key: |
- {% for key in authorized_key_files %}
- {{ lookup('file', key) }}
- {% endfor %}
- user: root
- exclusive: true
-
- # Now, we create a non-root user with sudo privileges
- - name: Ensure wheel group exists
- remote_user: root
- ansible.builtin.group:
- name: wheel
- state: present
-
- - name: Ensure wheel group allows passwordless sudo
- remote_user: root
- ansible.builtin.lineinfile:
- dest: /etc/sudoers
- state: present
- regexp: "^%wheel"
- line: "%wheel ALL=(ALL) NOPASSWD: ALL"
- validate: visudo -cf %s
-
- - name: Ensure non-root admin account is created in wheel group
- remote_user: root
- ansible.builtin.user:
- name: admin
- groups: wheel
- append: true
-
- - name: Ensure admin ssh directory exists
- remote_user: root
- ansible.builtin.file:
- path: /home/admin/.ssh
- state: directory
- owner: admin
- group: admin
- mode: "0700"
-
- - name: Copy authorised keys to admin account
- remote_user: root
- ansible.builtin.copy:
- src: /root/.ssh/authorized_keys
- dest: /home/admin/.ssh/authorized_keys
- remote_src: true
- owner: admin
- group: admin
- mode: preserve
-
- - name: Ensure cloud-init is disabled
- ansible.builtin.copy:
- content: ""
- dest: /etc/cloud/cloud-init.disabled
- force: false
- owner: root
- group: root
- mode: "0644"
- become: true
-
- - name: Ensure hostname is set
- ansible.builtin.hostname:
- name: "{{ hostname }}"
- become: true
-
- - name: Ensure hostname is configured in /etc/hosts
- ansible.builtin.template:
- src: "{{ playbook_dir }}/files/hosts.j2"
- dest: /etc/hosts
- owner: root
- group: root
- mode: "0644"
- become: true
-
- name: Retrieve DANE hash
ansible.builtin.shell:
cmd: >
@@ -216,39 +143,6 @@
tags:
- dns
- # This is needed by ansible.builtin.deb822_repository to interact with the
- # sources lists. In ansible-core 2.20 and above, there is a builtin
- # install_python_debian parameter that handles that without this extra step,
- # but we are currently running 2.19.
- # TODO(debian-forky) use deb822_repository's install_python_debian parameter
- - name: Ensure python3-debian is installed
- ansible.builtin.apt:
- name:
- - python3-debian
- state: present
- update_cache: true
- become: true
-
- - name: Ensure debian apt repositories are configured
- ansible.builtin.deb822_repository:
- name: debian
- uris: "{{ debian_uri }}"
- suites:
- - "{{ debian_version }}"
- - "{{ debian_version }}-updates"
- components: main
- signed_by: /usr/share/keyrings/debian-archive-keyring.gpg
- become: true
-
- - name: Ensure debian-security apt repositories are configured
- ansible.builtin.deb822_repository:
- name: debian-security
- uris: "{{ debian_security_uri }}"
- suites: "{{ debian_version }}-security"
- components: main
- signed_by: /usr/share/keyrings/debian-archive-keyring.gpg
- become: true
-
# We specifically use apt instead of the more general package module here,
# because we want to ensure the cache is updated before we try and install
# anything. This is needed because, on a freh Debian install on AWS
@@ -258,18 +152,12 @@
- name: Ensure required packages are installed
ansible.builtin.apt:
name:
- - libdbi-perl # Used by munin postgres plugins
- lua-dbi-postgresql # Prosody postgres connection
- lua-unbound # Prosody DNS resolution
- - munin-node # Graphs and monitoring
- postgresql # Database
- prosody # XMPP server
- prosody-modules # Extra addons
- python3-psycopg2 # Used by ansible postgres role
- - rsync # Backups
- - systemd-timesyncd # Used to make sure the date is correct
- - ufw # Firewall
- - unattended-upgrades # Not every hosting provider installs by default
state: present
update_cache: true
become: true
@@ -351,7 +239,6 @@
proto: tcp
state: enabled
loop:
- - 4949 # Munin
- 5000 # XEP-0065
- 5223 # XEP-0368
- 5270 # XEP-0368
@@ -402,113 +289,6 @@
notify: Restart nginx
when: not is_transport_server
- - name: Ensure munin is configured
- ansible.builtin.template:
- src: "{{ playbook_dir }}/files/munin-node.conf.j2"
- dest: /etc/munin/munin-node.conf
- owner: root
- group: root
- mode: "0644"
- become: true
- notify: Restart munin-node
-
- - name: Ensure munin plugins are configured
- ansible.builtin.file:
- src: "/usr/share/munin/plugins/{{ item.src }}"
- dest: "/etc/munin/plugins/{{ item.dest }}"
- owner: root
- group: root
- state: link
- become: true
- with_items:
- - src: apt_all
- dest: apt_all
- - src: cpu
- dest: cpu
- - src: df
- dest: df
- - src: df_abs
- dest: df_abs
- - src: df_inode
- dest: df_inode
- - src: diskstats
- dest: diskstats
- - src: entropy
- dest: entropy
- - src: forks
- dest: forks
- - src: fw_conntrack
- dest: fw_conntrack
- - src: fw_forwarded_local
- dest: fw_forwarded_local
- - src: fw_packets
- dest: fw_packets
- - src: if_
- dest: if_enp1s0
- - src: if_err_
- dest: if_err_enp1s0
- - src: irqstats
- dest: irqstats
- - src: load
- dest: load
- - src: memory
- dest: memory
- - src: netstat
- dest: netstat
- - src: open_files
- dest: open_files
- - src: open_inodes
- dest: open_inodes
- - src: postgres_autovacuum
- dest: postgres_autovacuum
- - src: postgres_bgwriter
- dest: postgres_bgwriter
- - src: postgres_cache_
- dest: postgres_cache_prosody
- - src: postgres_checkpoints
- dest: postgres_checkpoints
- - src: postgres_connections_
- dest: postgres_connections_prosody
- - src: postgres_connections_db
- dest: postgres_connections_db
- - src: postgres_locks_
- dest: postgres_locks_prosody
- - src: postgres_oldest_prepared_xact_
- dest: postgres_oldest_prepared_xact_prosody
- - src: postgres_prepared_xacts_
- dest: postgres_prepared_xacts_prosody
- - src: postgres_querylength_
- dest: postgres_querylength_prosody
- - src: postgres_scans_
- dest: postgres_scans_prosody
- - src: postgres_size_
- dest: postgres_size_prosody
- - src: postgres_streaming_
- dest: postgres_streaming_prosody
- - src: postgres_transactions_
- dest: postgres_transactions_prosody
- - src: postgres_tuples_
- dest: postgres_tuples_prosody
- - src: postgres_users
- dest: postgres_users
- - src: postgres_xlog
- dest: postgres_xlog
- - src: proc_pri
- dest: proc_pri
- - src: processes
- dest: processes
- - src: swap
- dest: swap
- - src: threads
- dest: threads
- - src: uptime
- dest: uptime
- - src: users
- dest: users
- - src: vmstat
- dest: vmstat
- notify: Restart munin-node
-
- name: Ensure turn is configured
ansible.builtin.template:
src: "{{ playbook_dir }}/files/turnserver.conf.j2"
@@ -622,34 +402,6 @@
enabled: true
become: true
- # Vultr adds a custom sshd_config file that enabled password authentication.
- # I don't want this to be enabled, since I'm already copying the public key.
- - name: Ensure password authentication is not explicitly enabled
- ansible.builtin.file:
- path: "/etc/ssh/sshd_config.d/50-cloud-init.conf"
- state: absent
- become: true
- notify: Restart sshd
-
- - name: Ensure password based authentication is disabled
- ansible.builtin.copy:
- src: "{{ playbook_dir }}/files/50-disable-password-auth.conf"
- dest: "/etc/ssh/sshd_config.d/50-disable-password-auth.conf"
- owner: root
- group: root
- mode: "0644"
- become: true
- notify: Restart sshd
-
- - name: Ensure unattended upgrades config is installed
- ansible.builtin.copy:
- src: "{{ playbook_dir }}/files/50unattended-upgrades"
- dest: "/etc/apt/apt.conf.d/50unattended-upgrades"
- owner: root
- group: root
- mode: "0644"
- become: true
-
handlers:
- name: Restart prosody
@@ -664,24 +416,12 @@
state: restarted
become: true
- - name: Restart sshd
- ansible.builtin.service:
- name: sshd
- state: restarted
- become: true
-
- name: Restart nginx
ansible.builtin.service:
name: nginx
state: restarted
become: true
- - name: Restart munin-node
- ansible.builtin.service:
- name: munin-node
- state: restarted
- become: true
-
vars:
env_prefix: >-