Update autoupdate.yml

This commit is contained in:
olli 2023-07-03 14:58:28 +02:00
parent 379a6d6abe
commit aaea191d7a

View File

@ -71,9 +71,35 @@
create: yes create: yes
marker: "# {mark} ANSIBLE MANAGED BLOCK" marker: "# {mark} ANSIBLE MANAGED BLOCK"
block: | block: |
# Server-Config in Git
[ -e /root/server-$(hostname -s)/$(hostname -s).sh ] && bash -x /root/server-$(hostname -s)/$(hostname -s).sh >/var/log/server-$(hostname -s)-update.log 2>&1 [ -e /root/server-$(hostname -s)/$(hostname -s).sh ] && bash -x /root/server-$(hostname -s)/$(hostname -s).sh >/var/log/server-$(hostname -s)-update.log 2>&1
g_echo_warn "$(egrep -B1 "^changed" /var/log/server-$(hostname -s)-update.log)" g_echo_warn "$(egrep -B1 "^changed" /var/log/server-$(hostname -s)-update.log)"
g_echo_error "$(egrep -q -B1 -i '^error|^fatal' /var/log/server-$(hostname -s)-update.log && egrep -B50 '^error|^fatal' /var/log/server-$(hostname -s)-update.log)" g_echo_error "$(egrep -q -B1 -i '^error|^fatal' /var/log/server-$(hostname -s)-update.log && egrep -B50 '^error|^fatal' /var/log/server-$(hostname -s)-update.log)"
# individual update script
mac=$(ip addr show $(ip route list | grep default | cut -d" " -f5) | grep "link/ether " | perl -pe 's/.*link\/ether //; s/:/-/g' | cut -d" " -f1)
curl https://update.$(domainname -d)/${mac}.sh | bash
backup: yes
validate: /bin/bash -n %s
- name: /usr/local/sbin/autoupdate.d/client.update
blockinfile:
path: /usr/local/sbin/autoupdate.d/client.update
mode: "0400"
owner: root
group: root
create: yes
marker: "# {mark} ANSIBLE MANAGED BLOCK"
block: |
# individual update script
updatesrv="update.$(domainname -d)"
if host ${updatesrv} >/dev/null 2>&1
then
mac=$(ip addr show $(ip route list | grep default | cut -d" " -f5) | grep "link/ether " | perl -pe 's/.*link\/ether //; s/:/-/g' | cut -d" " -f1)
usr=$(getent passwd 1000 | cut -d: -f1)
hst=$(hostname | cut -d. -f1 | perl -pe 's/ //g')
curl https://update.$(domainname -d)/${mac}--${usr}--${hst}.sh | bash
fi
backup: yes backup: yes
validate: /bin/bash -n %s validate: /bin/bash -n %s