Add patchman-client role; disable nightly update and reboot cron jobs
- roles/patchman_client + patchman-client.yaml: install patchman-client on ubuntu_servers and enroll with the Patchman server on patch.ki5bhv.com - crontab.txt: comment out the 2:00 update.yaml and 7:00 reboot.yaml jobs; updates are now tracked in Patchman and applied manually Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
fcaa1e9204
commit
6d5f532b2b
8 files changed
+1337
-2
No files matched your search
+2
-2
@@ -28,7 +28,7 @@ ANSIBLE_CONFIG=/home/justin/Ansible/ansible.cfg
|
||||
0 5 * * * ansible-playbook /home/justin/Ansible/docker/update-docker-compose.yaml >> /home/justin/cron-logs/update-docker-compose.log 2>&1
|
||||
30 5 * * * ansible-playbook /home/justin/Ansible/docker/restart-qtorrnt.yaml >> /home/justin/cron-logs/restart-qtorrnt.log 2>&1
|
||||
0 6 * * * ansible-playbook /home/justin/Ansible/ubuntu/restart-beszel.yaml >> /home/justin/cron-logs/restart-beszel.log 2>&1
|
||||
0 2 * * * ansible-playbook /home/justin/Ansible/ubuntu/update.yaml >> /home/justin/cron-logs/update.log 2>&1
|
||||
0 7 * * * ansible-playbook /home/justin/Ansible/ubuntu/reboot.yaml >> /home/justin/cron-logs/reboot.log 2>&1
|
||||
#0 2 * * * ansible-playbook /home/justin/Ansible/ubuntu/update.yaml >> /home/justin/cron-logs/update.log 2>&1
|
||||
#0 7 * * * ansible-playbook /home/justin/Ansible/ubuntu/reboot.yaml >> /home/justin/cron-logs/reboot.log 2>&1
|
||||
0 5 * * 2 ansible-playbook /home/justin/Ansible/ubuntu/maint-clean-logs-cache.yaml >> /home/justin/cron-logs/maint-clean-logs-cache.log 2>&1
|
||||
0 0 1,15 * * ansible-playbook /home/justin/Ansible/ubuntu/fix-ssh-host-keys.yaml >> /home/justin/cron-logs/fix-ssh-host-keys.log 2>&1
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
# Installs patchman-client on every Ubuntu server and enrolls it with the
|
||||
# Patchman server on patch.ki5bhv.com. Role settings: roles/patchman_client/defaults/main.yml
|
||||
- name: Install and enroll patchman-client
|
||||
hosts: ubuntu_servers
|
||||
become: true
|
||||
roles:
|
||||
- patchman_client
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
# Patchman server URL, including the /patchman path.
|
||||
# Clients must be in a network allowed to upload (192.168.1.0/24 by default).
|
||||
patchman_server_url: "http://192.168.1.8/patchman"
|
||||
|
||||
# Comma or space delimited tags shown on the host in Patchman.
|
||||
patchman_client_tags: "Server"
|
||||
|
||||
# Options passed to curl when uploading.
|
||||
patchman_client_curl_options: "--insecure --connect-timeout 60 --max-time 300"
|
||||
|
||||
# Report protocol: 1 = text, 2 = json (needs jq and, by default, an API key).
|
||||
patchman_client_protocol: 1
|
||||
patchman_client_api_key: ""
|
||||
|
||||
# Daily report schedule. The minute is derived from the hostname so servers
|
||||
# don't all report at the same moment, but stays stable between runs.
|
||||
patchman_cron_enabled: true
|
||||
patchman_cron_hour: "2"
|
||||
patchman_cron_minute: "{{ 59 | random(seed=inventory_hostname) }}"
|
||||
|
||||
# Send a report right away when the client is installed or its config changes.
|
||||
patchman_report_on_change: true
|
||||
Executable
+1215
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Send patchman report
|
||||
ansible.builtin.command: /usr/sbin/patchman-client
|
||||
changed_when: true
|
||||
when: patchman_report_on_change | bool
|
||||
@@ -0,0 +1,54 @@
|
||||
---
|
||||
- name: Install client dependencies
|
||||
ansible.builtin.package:
|
||||
name: "{{ ['curl'] + (['jq'] if patchman_client_protocol | int == 2 else []) }}"
|
||||
state: present
|
||||
|
||||
- name: Install cron
|
||||
ansible.builtin.package:
|
||||
name: "{{ 'cron' if ansible_facts['os_family'] == 'Debian' else 'cronie' }}"
|
||||
state: present
|
||||
when: patchman_cron_enabled | bool
|
||||
|
||||
- name: Install patchman-client script
|
||||
ansible.builtin.copy:
|
||||
src: patchman-client
|
||||
dest: /usr/sbin/patchman-client
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
notify: Send patchman report
|
||||
|
||||
- name: Create /etc/patchman
|
||||
ansible.builtin.file:
|
||||
path: /etc/patchman
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
|
||||
- name: Configure patchman-client
|
||||
ansible.builtin.template:
|
||||
src: patchman-client.conf.j2
|
||||
dest: /etc/patchman/patchman-client.conf
|
||||
owner: root
|
||||
group: root
|
||||
# keep the file private when it holds an API key
|
||||
mode: "{{ '0600' if patchman_client_api_key else '0644' }}"
|
||||
notify: Send patchman report
|
||||
|
||||
# Writes the whole file so it replaces any hand-made /etc/cron.d/patchman-client
|
||||
- name: Schedule daily patchman report
|
||||
ansible.builtin.template:
|
||||
src: patchman-client.cron.j2
|
||||
dest: /etc/cron.d/patchman-client
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when: patchman_cron_enabled | bool
|
||||
|
||||
- name: Remove daily patchman report schedule
|
||||
ansible.builtin.file:
|
||||
path: /etc/cron.d/patchman-client
|
||||
state: absent
|
||||
when: not patchman_cron_enabled | bool
|
||||
@@ -0,0 +1,24 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
# Patchman server
|
||||
server={{ patchman_server_url }}
|
||||
|
||||
# Options to curl
|
||||
curl_options="{{ patchman_client_curl_options }}"
|
||||
|
||||
# Comma or space delimited tags to send
|
||||
tags="{{ patchman_client_tags }}"
|
||||
|
||||
# Does the client output a report of the upload (e.g. for cronjob output)
|
||||
report=false
|
||||
|
||||
# Protocol version (1 = text, 2 = json)
|
||||
# Protocol 2 requires jq to be installed
|
||||
protocol={{ patchman_client_protocol }}
|
||||
|
||||
# API key for protocol 2 authentication
|
||||
{% if patchman_client_api_key %}
|
||||
api_key={{ patchman_client_api_key }}
|
||||
{% else %}
|
||||
#api_key=pm_your_api_key_here
|
||||
{% endif %}
|
||||
@@ -0,0 +1,6 @@
|
||||
# {{ ansible_managed }}
|
||||
# Send a daily package report to the Patchman server ({{ patchman_server_url }})
|
||||
SHELL=/bin/sh
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
{{ patchman_cron_minute }} {{ patchman_cron_hour }} * * * root /usr/sbin/patchman-client 2>&1 | logger -t patchman-client
|
||||
Reference in new issue
Block a user