- name: Install Ubuntu packages
when: ansible_distribution == 'Ubuntu'
ansible.builtin.include_tasks:
file: install_ubuntu.yml
- name: Install Rocky packages
when: ansible_distribution == 'Rocky'
ansible.builtin.include_tasks:
file: install_rocky.yml
- name: Copy update status script
ansible.builtin.copy:
src: files/{{ ansible_os_family|lower }}_update_status.py
dest: /usr/local/bin/update_status
owner: root
group: root
mode: '0755'
- name: Copy reboot status script
ansible.builtin.copy:
src: files/{{ ansible_os_family|lower }}_reboot_status.py
dest: /usr/local/bin/reboot_status
owner: root
group: root
mode: '0755'
#- name: Get snmp community string from Azure key vault
# local_action:
# module: azure.azcollection.azure_rm_keyvaultsecret_info
# vault_uri: "{{ az_keyvault_url }}"
# register: snmp_community
#- name: Print snmp community string
# debug:
# msg: "SNMP Community: {{ snmp_community }}"
- name: Configure snmpd
ansible.builtin.template:
src: templates/snmpd.conf.j2
dest: /etc/snmp/snmpd.conf
owner: root
group: root
mode: 0600
backup: yes
notify: Restart snmpd
- name: Create a cron to output package update status once an hour
ansible.builtin.cron:
name: check update status
job: "/usr/local/bin/update_status /tmp/update_status.txt > /dev/null 2>&1"
minute: "0"
state: present
user: root
cron_file: ansible_update_status
- name: Create a cron to output reboot status once an hour
ansible.builtin.cron:
name: "check reboot status"
job: "/usr/local/bin/reboot_status /tmp/reboot_status.txt > /dev/null 2>&1"
minute: "5"
state: present
user: root
cron_file: ansible_reboot_status
- name: Create cron to output reboot status after a restart
ansible.builtin.cron:
name: "update reboot status after a reboot"
job: "/usr/local/bin/reboot_status /tmp/reboot_status.txt > /dev/null 2>&1"
special_time: reboot
state: present
user: root
cron_file: ansible_reboot_status
- name: Run update_status
ansible.builtin.command: "/usr/local/bin/update_status /tmp/update_status.txt"
- name: Run upgrade_status
ansible.builtin.command: "/usr/local/bin/reboot_status /tmp/reboot_status.txt"