Ansible AWX is a great tool for automating tasks like patching Linux servers at night. It’s easier to use than regular Ansible Galaxy because AWX integrates well with Active Directory (AD) through LDAP. I also like that AWX can schedule tasks to run automatically and send notifications to Slack when the task is done.

AWX makes it simple to store playbooks in Git, and it can even automate tasks with network devices like F5 load balancers. Here’s a playbook I use to update Ubuntu servers:


hosts: linux
serial: 1pre_tasks:
– name: Disable PRTG
service:

tasks:
– name: Update apt cache
become: yes
apt: update_cache=yes

– name: Upgrade packages
become: yes
apt: upgrade=dist

– name: Check if a reboot is required
become: yes
register: reboot_required_file
stat: path=/var/run/reboot-required get_md5=no

– name: Restart machine if reboot is needed
become: yes
shell: sleep 2 && shutdown -r now “Ansible updates triggered”
async: 1
poll: 0
ignore_errors: true
when: reboot_required_file.stat.exists == true

– name: Wait for server to come back
become: no
local_action: wait_for

This playbook updates the server, checks if a reboot is needed, and reboots if necessary. AWX helps schedule this and sends updates through Slack.

Share.
Leave A Reply

Exit mobile version