Compare changes

Choose any two refs to compare.

+12
check-borgmatic.yml
···
+
---
+
- name: Check the date of the last borgmatic archive
+
hosts: borgmatic_hosts
+
gather_facts: true
+
become: true
+
tasks:
+
- name: Get last borgmatic archive date
+
ansible.builtin.shell: borgmatic list | tail -n 1 | awk '{print $2,$3,$4}'
+
register: borgmatic_list
+
+
- ansible.builtin.debug:
+
msg: "{{ borgmatic_list.stdout }}"
+1 -19
debian-update.yml
···
---
-
- hosts: debianservers
+
- hosts: debian_servers
gather_facts: true
become: true
···
- name: Perform a dist-upgrade
ansible.builtin.apt:
upgrade: dist
-
-
- name: Check if backports are enabled in sources.list
-
ansible.builtin.lineinfile:
-
path: /etc/apt/sources.list
-
regex: "backports"
-
state: absent
-
changed_when: false
-
check_mode: true
-
register: backports
-
-
- name: Perform a dist-upgrade from Debian backports
-
ansible.builtin.apt:
-
default_release: bookworm-backports
-
update_cache: true
-
upgrade: dist
-
when:
-
- ansible_distribution == 'Debian'
-
- backports.found == 1
- name: Check if reboot is required
ansible.builtin.stat:
+19 -15
freebsd-update.yml
···
-
---
-
- hosts: freebsdservers
+
- hosts: freebsd_servers
gather_facts: true
become: true
-
vars:
-
jails:
-
- aa-torrenting
-
- blocky
-
- unbound
-
tasks:
- name: Update all installed packages
community.general.pkgng:
name: "*"
state: latest
-
-
- name: Update all installed packages in jails
-
community.general.pkgng:
-
name: "*"
-
state: latest
-
jail: "{{ item }}"
-
with_items: "{{ jails }}"
+
- name: Update the base system
+
ansible.builtin.shell: freebsd-update fetch install --not-running-from-cron
+
- name: Get currently running FreeBSD kernel version in memory
+
ansible.builtin.shell: freebsd-version -r
+
register: running_kv
+
- name: Get newly installed kernel version
+
ansible.builtin.shell: freebsd-version -k
+
register: installed_kv
+
- name: Check for kernel version mismatch
+
set_fact:
+
reboot_required: "{{ running_kv.stdout != installed_kv.stdout }}"
+
- name: Display reboot status
+
ansible.builtin.debug:
+
msg: "Reboot required: {{ reboot_required }}"
+
- name: Reboot the FreeBSD server if needed
+
ansible.builtin.reboot:
+
reboot_timeout: 3600
+
when: reboot_required
+17 -45
inventory.yml
···
-
debianservers:
+
borgmatic_hosts:
hosts:
-
hyperreal.coffee:
-
ansible_user: jas
-
ansible_host: hyperreal.headscale.moonshadow.dev
-
ansible_python_interpreter: /usr/bin/python3
-
auxnc-8g:
-
ansible_user: jas
-
ansible_host: auxnc-8g
-
ansible_python_interpreter: /usr/bin/python3
-
headscale:
+
desktop:
ansible_user: jas
-
ansible_host: headscale.headscale.moonshadow.dev
+
ansible_host: desktop.carp-wyvern.ts.net
ansible_python_interpreter: /usr/bin/python3
-
-
almaservers:
-
hosts:
-
archive-warror:
-
ansible_user: jas
-
ansible_host: archive-warrior.headscale.moonshadow.dev
-
ansible_python_interpreter: /usr/bin/python3
-
-
freebsdservers:
-
hosts:
nas:
ansible_user: jas
-
ansible_host: nas.headscale.moonshadow.dev
-
ansible_python_interpreter: /usr/local/bin/python3
-
-
promservers:
+
ansible_host: nas.carp-wyvern.ts.net
+
ansible_python_interpreter: /usr/local/bin/python3.11
+
debian_servers:
hosts:
-
desktop:
+
moonshadow:
ansible_user: jas
-
ansible_host: localhost
+
ansible_host: moonshadow.carp-wyvern.ts.net
ansible_python_interpreter: /usr/bin/python3
-
-
promclients:
+
freebsd_servers:
hosts:
-
hyperreal.coffee:
-
ansible_user: jas
-
ansible_host: hyperreal.headscale.moonshadow.dev
-
ansible_python_interpreter: /usr/bin/python3
-
backup:
-
ansible_user: jas
-
ansible_host: backup.headscale.moonshadow.dev
-
ansible_python_interpreter: /usr/bin/python3
-
headscale:
-
ansible_user: jas
-
ansible_host: headscale.headscale.moonshadow.dev
-
ansible_python_interpreter: /usr/bin/python3
-
archive-warrior:
-
ansible_user: jas
-
ansible_host: archive-warrior.headscale.moonshadow.dev
-
ansible_python_interpreter: /usr/bin/python3
+
nas:
+
ansible_user: root
+
ansible_host: nas.carp-wyvern.ts.net
+
ansible_python_interpreter: /usr/local/bin/python3.11
+
tornode:
+
ansible_user: root
+
ansible_host: tornode
+
ansible_python_interpreter: /usr/local/bin/python3.11
+17 -1
prometheus-clients.yml
···
---
-
- hosts: promclients
+
- hosts: prom_clients
tasks:
- name: Import Node Exporter role
import_role:
name: prometheus.prometheus.node_exporter
+
when: ansible_service_mgr == "systemd"
+
+
- name: Install Node Exporter on FreeBSD
+
community.general.pkgng:
+
name: "node_exporter"
+
state: latest
+
when: ansible_service_mgr == "bsdinit"
+
become: true
+
+
- name: Enable node_exporter service on FreeBSD
+
ansible.builtin.service:
+
name: node_exporter
+
enabled: true
+
state: started
+
when: ansible_service_mgr == "bsdinit"
+
become: true
+1 -1
prometheus-servers.yml
···
---
-
- hosts: promservers
+
- hosts: prom_servers
tasks:
- name: Import Node Exporter role
import_role:
+63
remote-logging-setup.yml
···
+
- hosts: remote_logging_clients
+
gather_facts: true
+
become: true
+
tasks:
+
- name: Ensure rsyslog is installed
+
ansible.builtin.package:
+
name: rsyslog
+
state: latest
+
when: ansible_system == "Linux"
+
- name: Ensure rsyslog is enabled
+
ansible.builtin.systemd_service:
+
name: rsyslog
+
enabled: true
+
state: started
+
when: ansible_service_mgr == "systemd"
+
- name: Remove any forwarding file if exists
+
ansible.builtin.file:
+
path: /etc/rsyslog.d/forward.conf
+
state: absent
+
when: ansible_system == "Linux"
+
- name: Get remote logging server headnet IP address
+
ansible.builtin.shell: tailscale status | grep "aux" | awk '{print $1}'
+
register: ctrl_headnet_ip_addr
+
changed_when: false
+
failed_when: ctrl_headnet_ip_addr.rc != 0
+
- name: Configure log forwarding
+
ansible.builtin.blockinfile:
+
path: /etc/rsyslog.d/forward.conf
+
create: true
+
owner: root
+
group: root
+
mode: 0644
+
block: |
+
# Forward to aux.carp-wyvern.ts.net ({{ctrl_headnet_ip_addr.stdout}})
+
*.* action(type="omfwd" target="{{ctrl_headnet_ip_addr.stdout}}" port="514" protocol="tcp"
+
action.resumeRetryCount="100"
+
queue.type="linkedList" queue.size="10000")
+
when: ansible_system == "Linux"
+
- name: Restart rsyslog
+
ansible.builtin.systemd_service:
+
name: rsyslog
+
enabled: true
+
state: restarted
+
when: ansible_service_mgr == "systemd"
+
- name: Set syslog flags for remote logging on FreeBSD
+
ansible.builtin.shell: sysrc syslog_flags="-s -v -v"
+
register: set_syslog_flags
+
changed_when: '"syslog_flags: -> YES" in set_syslog_flags.stdout'
+
when: ansible_service_mgr == "bsdinit"
+
- name: Set log forwarding on FreeBSD
+
ansible.builtin.lineinfile:
+
path: /etc/syslog.conf
+
regexp: '^\*\.\*'
+
line: "*.* @{{ctrl_headnet_ip_addr.stdout}}"
+
owner: root
+
group: wheel
+
mode: 0644
+
when: ansible_system == "FreeBSD"
+
- name: Restart syslogd
+
ansible.builtin.service:
+
name: syslogd
+
state: restarted
+
when: ansible_service_mgr == "bsdinit"
+1 -1
uptime.yml
···
ansible.builtin.shell: uptime
register: uptime
-
- debug:
+
- ansible.builtin.debug:
msg: "{{ uptime.stdout }}"
+38
zfs-log-compress.yml
···
+
# Based on https://github.com/FreeBSDFoundation/blog/blob/main/zfs-log-compression-on-freebsd/zfs_log_compress.yml
+
---
+
- name: Remove log compression on FreeBSD host, add timestamps to rotated logs
+
hosts: freebsd_servers
+
gather_facts: true
+
become: true
+
tasks:
+
- name: Set compression of /var/log dataset to zstd
+
community.general.zfs:
+
name: zroot/var/log
+
state: present
+
extra_zfs_properties:
+
compression: zstd
+
+
- name: Remove 'J' from the newsyslog.conf file
+
ansible.builtin.replace:
+
path: /etc/newsyslog.conf
+
regexp: "^J|J"
+
replace: ""
+
notify: "Restart newsyslog service"
+
+
- name: Use timestamps instead of numbers for log rotations
+
ansible.builtin.replace:
+
path: /etc/crontab
+
regexp: "newsyslog$"
+
replace: "newsyslog -t DEFAULT"
+
notify: "Restart syslogd service"
+
+
handlers:
+
- name: Restart newsyslog service
+
ansible.builtin.service:
+
name: newsyslog
+
state: restarted
+
+
- name: Restart syslogd service
+
ansible.builtin.service:
+
name: syslogd
+
state: restarted