Rebuilding logic around syslog socket placement

This commit is contained in:
László Károlyi 2024-01-18 16:02:43 +01:00
parent f21e502660
commit 63dcd12ff6
Signed by: karolyi
GPG key ID: 2DCAF25E55735BFE
4 changed files with 75 additions and 19 deletions

View file

@ -32,10 +32,9 @@
delay: 1
until: result is succeeded
- name: Restarting syslog
service:
name: syslogd
state: restarted
- name: Reloading syslog
ansible.builtin.command: |
'{{ ansible_roles_path }}/karolyi.ansible-freebsd-jailhost-tools/tools/reset-syslog-socketpaths.sh' -ar
- include_tasks:
file: '{{ ansible_roles_path }}/karolyi.ansible-freebsd-jailhost-tools/tasks/chroot/install_packages.yml'

View file

@ -38,16 +38,10 @@
loop_control:
loop_var: mountpoint
- name: Delete syslog socket and its directory to avoid recreating log socket
ansible.builtin.file:
path: '{{ dynamic_jails_path }}/{{ jail_id }}/var/run/log'
state: absent
- name: Reloading syslog
ansible.builtin.command: |
'{{ ansible_roles_path }}/karolyi.ansible-freebsd-jailhost-tools/tools/reset-syslog-socketpaths.sh' -r
# - name: Restarting syslog to remove its log socket from kernel FDs
# service:
# name: syslogd
# state: restarted
- name: Delete config dir for jail
ansible.builtin.file:
path: '{{ dynamic_jails_path }}/configs/{{ jail_id }}'
@ -68,7 +62,7 @@
ansible.builtin.command:
/sbin/zfs destroy -f
{{ dynamic_jails_dataset_name }}/{{ jail_id }}
# when: 'zfs_destroy is failed and ": Device busy" in zfs_destroy.msg'
when: 'zfs_destroy is failed and "pool or dataset is busy" in zfs_destroy.msg'
# ignore_errors: yes
- name: Removing jail directory

View file

@ -22,9 +22,8 @@
/usr/bin/killall -HUP dnsmasq
failed_when: false
- name: Restarting syslog to put its log socket into the new jail
service:
name: syslogd
state: restarted
- name: Reloading syslog
ansible.builtin.command: |
'{{ ansible_roles_path }}/karolyi.ansible-freebsd-jailhost-tools/tools/reset-syslog-socketpaths.sh' -r
# vim: sw=2

View file

@ -0,0 +1,64 @@
#!/usr/bin/env sh
#set -xe
EXTRA_SOCKETS=/etc/syslogd.sockets.extra
SCRIPTNAME=$(basename $0)
# Create default list of syslog sockets to watch
#
( umask 022 ; > $EXTRA_SOCKETS )
for i in /jails/static/*/var/run
do
echo $i >>$EXTRA_SOCKETS
done
add_all_dynamic_dirs() {
for i in /jails/dynamic/*
do
echo $i/var/run >>$EXTRA_SOCKETS
done
}
add_latest_only_dirs() {
_jailnames=$(ls -d /jails/dynamic/*|cut -f 4 -d '/'|sed -E 's/-[[:digit:]]+-[[:digit:]]+$/-/g'|uniq)
for jailname in $_jailnames
do
_latest_dir=$(ls -d /jails/dynamic/$jailname*|sort -r|head -1)
echo $_latest_dir/var/run >>$EXTRA_SOCKETS
done
}
TEMP=$(getopt 'ar' "$@")
eval set -- "$TEMP"
_dynamic_dirs=no
_restart_syslogd=no
# extract options and their arguments into variables.
while true ; do
case "$1" in
-a)
shift
_dynamic_dirs=yes
;;
-r)
shift
_restart_syslogd=yes
;;
--)
shift
break
;;
*)
echo "Internal error!"
exit 1
;;
esac
done
test $_dynamic_dirs == "yes" && add_all_dynamic_dirs || add_latest_only_dirs
test $_restart_syslogd == "yes" && service syslogd restart
# vim: sw=4:smarttab