Update freebsd, add rsyslog
This commit is contained in:
parent
2795f254a1
commit
78729dc03f
@ -5,8 +5,6 @@
|
|||||||
vars:
|
vars:
|
||||||
jails:
|
jails:
|
||||||
- aa-torrenting
|
- aa-torrenting
|
||||||
- blocky
|
|
||||||
- unbound
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Update all installed packages
|
- name: Update all installed packages
|
||||||
@ -30,13 +28,3 @@
|
|||||||
ansible.builtin.shell: freebsd-update -j aa-torrenting fetch install
|
ansible.builtin.shell: freebsd-update -j aa-torrenting fetch install
|
||||||
register: updated_aa_torrenting
|
register: updated_aa_torrenting
|
||||||
changed_when: '"No updates are available to install." not in updated_aa_torrenting.stdout'
|
changed_when: '"No updates are available to install." not in updated_aa_torrenting.stdout'
|
||||||
|
|
||||||
- name: Fetch and install updates in blocky jail
|
|
||||||
ansible.builtin.shell: freebsd-update -j blocky fetch install
|
|
||||||
register: updated_blocky
|
|
||||||
changed_when: '"No updates are available to install." not in updated_blocky.stdout'
|
|
||||||
|
|
||||||
- name: Fetch and install updates in unbound jail
|
|
||||||
ansible.builtin.shell: freebsd-update -j unbound fetch install
|
|
||||||
register: updated_unbound
|
|
||||||
changed_when: '"No updates are available to install." not in updated_unbound.stdout'
|
|
||||||
|
@ -1,36 +1,61 @@
|
|||||||
---
|
---
|
||||||
- hosts: promclients
|
- hosts: debianservers,freebsdservers
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
become: true
|
become: true
|
||||||
|
vars:
|
||||||
|
etc_dir: "{% if ansible_system == 'FreeBSD' %}/usr/local/etc{% else %}/etc{% endif %}"
|
||||||
|
group: "{% if ansible_system == 'FreeBSD' %}wheel{% else %}root{% endif %}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Ensure rsyslog is installed
|
- name: Ensure rsyslog is installed
|
||||||
ansible.builtin.package:
|
ansible.builtin.package:
|
||||||
name: rsyslog
|
name: rsyslog
|
||||||
state: latest
|
state: latest
|
||||||
|
when: ansible_system == "Linux"
|
||||||
|
|
||||||
|
- name: Ensure rsyslog is installed
|
||||||
|
community.general.pkgng:
|
||||||
|
name: "rsyslog"
|
||||||
|
state: latest
|
||||||
|
when: ansible_system == "FreeBSD"
|
||||||
|
|
||||||
- name: Ensure rsyslog is enabled
|
- name: Ensure rsyslog is enabled
|
||||||
ansible.builtin.systemd_service:
|
ansible.builtin.systemd_service:
|
||||||
name: rsyslog
|
name: rsyslog
|
||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
|
- name: Ensure rsyslog is enabled in /etc/rc.conf (FreeBSD)
|
||||||
|
ansible.builtin.shell: sysrc rsyslogd_enable="YES"
|
||||||
|
register: rsyslogd_enable
|
||||||
|
when: ansible_system == "FreeBSD"
|
||||||
|
changed_when: '"YES -> YES" not in rsyslogd_enable.stdout'
|
||||||
|
|
||||||
|
- name: Ensure syslogd is disabled in /etc/rc.conf (FreeBSD)
|
||||||
|
ansible.builtin.shell: sysrc syslogd_enable="NO"
|
||||||
|
register: syslogd_enable
|
||||||
|
when: ansible_system == "FreeBSD"
|
||||||
|
changed_when: '"YES -> NO" in syslogd_enable.stdout'
|
||||||
|
|
||||||
- name: Remove any forwarding file if exists
|
- name: Remove any forwarding file if exists
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /etc/rsyslog.d/forward.conf
|
path: "{{ etc_dir }}/rsyslog.d/forward.conf"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Get control node headnet IP address
|
- name: Get control node headnet IP address
|
||||||
ansible.builtin.shell: tailscale status | head -1 | awk '{print $1}'
|
ansible.builtin.shell: tailscale status | head -1 | awk '{print $1}'
|
||||||
register: ctrl_headnet_ip_addr
|
register: ctrl_headnet_ip_addr
|
||||||
delegate_to: 127.0.0.1
|
delegate_to: 127.0.0.1
|
||||||
|
changed_when: false
|
||||||
|
failed_when: ctrl_headnet_ip_addr.rc != 0
|
||||||
|
|
||||||
- name: Configure log forwarding
|
- name: Configure log forwarding
|
||||||
ansible.builtin.blockinfile:
|
ansible.builtin.blockinfile:
|
||||||
path: /etc/rsyslog.d/forward.conf
|
path: "{{ etc_dir }}/rsyslog.d/forward.conf"
|
||||||
create: true
|
create: true
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: "{{ group }}"
|
||||||
mode: 0644
|
mode: 0644
|
||||||
block: |
|
block: |
|
||||||
# Forward to desktop.headscale.moonshadow.dev ({{ctrl_headnet_ip_addr.stdout}})
|
# Forward to desktop.headscale.moonshadow.dev ({{ctrl_headnet_ip_addr.stdout}})
|
||||||
@ -43,3 +68,8 @@
|
|||||||
name: rsyslog
|
name: rsyslog
|
||||||
enabled: true
|
enabled: true
|
||||||
state: restarted
|
state: restarted
|
||||||
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
|
- name: Restart rsyslog
|
||||||
|
ansible.builtin.shell: service rsyslogd restart
|
||||||
|
when: ansible_service_mgr == "bsdinit"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user