2016-08-08 19:36:31 +00:00
|
|
|
# This playboook updates a virthost and all it's guests.
|
2013-11-21 21:37:43 +00:00
|
|
|
#
|
2013-03-04 22:37:13 +00:00
|
|
|
# requires --extra-vars="target=somevhostname yumcommand=update"
|
2015-07-22 21:52:30 +00:00
|
|
|
# Might add nodns=true or nonagios=true at extra-vars
|
2013-11-21 21:37:43 +00:00
|
|
|
#
|
2013-02-25 17:37:22 +00:00
|
|
|
|
2024-11-25 18:24:56 +10:00
|
|
|
---
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Find instances
|
2024-09-30 10:01:06 -07:00
|
|
|
vars_prompt:
|
2025-01-27 16:26:46 -08:00
|
|
|
- name: target
|
2025-03-25 19:22:40 -04:00
|
|
|
prompt: What is the target vhost (to upgrade)
|
2024-11-25 18:24:56 +10:00
|
|
|
private: false
|
2025-03-25 19:22:40 -04:00
|
|
|
# Use a simple regexp to ignore spaces people might accidentally paste.
|
|
|
|
hosts: "{{ target | regex_search('[-a-z0-9.]+')}}"
|
2024-11-25 18:24:56 +10:00
|
|
|
gather_facts: false
|
2013-02-25 17:37:22 +00:00
|
|
|
user: root
|
|
|
|
|
|
|
|
tasks:
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Get list of guests
|
2013-11-21 21:37:43 +00:00
|
|
|
virt: command=list_vms
|
2013-02-25 17:37:22 +00:00
|
|
|
register: vmlist
|
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Add them to myvms_new group
|
2013-11-22 22:03:52 +00:00
|
|
|
local_action: add_host hostname={{ item }} groupname=myvms_new
|
2016-09-21 21:03:04 +00:00
|
|
|
with_items: '{{vmlist.list_vms}}'
|
2013-02-25 17:37:22 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Add the vmhost to target group
|
2025-03-25 20:36:02 -04:00
|
|
|
# Use a simple regexp to ignore spaces people might accidentally paste.
|
|
|
|
local_action: add_host hostname={{ target | regex_search('[-a-z0-9.]+') }} groupname=target
|
2024-09-30 10:01:06 -07:00
|
|
|
|
2015-03-11 17:02:08 +00:00
|
|
|
# Call out to another playbook. Disable any proxies that may live here
|
2024-11-25 18:24:56 +10:00
|
|
|
# - include_playbook: update-proxy-dns.yml status=disable proxies=myvms_new:&proxies
|
2015-03-11 17:02:08 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Set downtime
|
2025-01-27 16:26:46 -08:00
|
|
|
hosts: "target:myvms_new"
|
2024-11-25 18:24:56 +10:00
|
|
|
gather_facts: false
|
2013-02-25 17:37:22 +00:00
|
|
|
user: root
|
2018-04-04 19:20:24 +00:00
|
|
|
serial: 1
|
2013-02-25 17:37:22 +00:00
|
|
|
|
|
|
|
tasks:
|
2018-04-04 19:20:24 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Schedule regular host downtime
|
2015-05-04 14:38:03 +00:00
|
|
|
nagios: action=downtime minutes=30 service=host host={{ inventory_hostname_short }}{{ env_suffix }}
|
2020-06-14 14:14:31 -07:00
|
|
|
delegate_to: noc01.iad2.fedoraproject.org
|
2015-03-11 17:02:08 +00:00
|
|
|
ignore_errors: true
|
2016-09-20 04:08:27 +00:00
|
|
|
failed_when: no
|
2015-07-23 20:17:24 +00:00
|
|
|
when: nonagios is not defined or not "true" in nonagios
|
2015-03-11 17:02:08 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Update the system
|
2025-01-27 16:26:46 -08:00
|
|
|
hosts: "target:myvms_new"
|
2024-11-25 18:24:56 +10:00
|
|
|
gather_facts: true
|
2018-04-04 19:20:24 +00:00
|
|
|
user: root
|
|
|
|
|
|
|
|
tasks:
|
2019-04-10 21:18:52 +00:00
|
|
|
|
2019-04-09 19:13:01 +00:00
|
|
|
- name: Apply updates
|
2024-12-19 13:22:42 +10:00
|
|
|
ansible.builtin.package:
|
2024-11-25 18:24:56 +10:00
|
|
|
state: latest
|
|
|
|
name: "*"
|
|
|
|
update_cache: true
|
2015-10-06 20:10:56 +00:00
|
|
|
async: 7200
|
|
|
|
poll: 30
|
2019-04-10 21:30:53 +00:00
|
|
|
when: package_excludes is not defined
|
2024-11-25 18:24:56 +10:00
|
|
|
|
2019-04-10 21:18:52 +00:00
|
|
|
- debug:
|
2024-11-25 18:24:56 +10:00
|
|
|
msg:
|
|
|
|
- '!!!!!!!!!!!!!!!!!!! host {{ inventory_hostname }} has EXCLUDES OF {{ package_excludes }} !!!!!!!!!!!!!'
|
|
|
|
- '!!!!!!!!!!!!!!!!!!! DANGER DANGER DANGER ^ CHECK THAT EXCLUDES ARE STILL NEEDED ^ !!!!!!!!!!!!!!!!!!!!'
|
2019-04-10 21:18:52 +00:00
|
|
|
when: package_excludes is defined
|
|
|
|
changed_when: true
|
2024-11-25 18:24:56 +10:00
|
|
|
|
2019-04-10 21:18:52 +00:00
|
|
|
- name: Apply updates with excludes
|
2024-12-19 13:22:42 +10:00
|
|
|
ansible.builtin.package:
|
2024-11-25 18:24:56 +10:00
|
|
|
state: latest
|
|
|
|
name: "*"
|
|
|
|
update_cache: true
|
|
|
|
exclude: "{{ package_excludes }}"
|
2019-04-10 21:18:52 +00:00
|
|
|
async: 7200
|
|
|
|
poll: 30
|
|
|
|
when: package_excludes is defined
|
2013-02-25 17:37:22 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Run rkhunter if installed
|
2025-01-27 16:26:46 -08:00
|
|
|
hosts: "target:myvms_new"
|
2013-11-22 22:03:52 +00:00
|
|
|
user: root
|
|
|
|
|
|
|
|
tasks:
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Check for rkhunter
|
2024-12-19 11:22:24 +10:00
|
|
|
ansible.builtin.command: /usr/bin/test -f /usr/bin/rkhunter
|
2013-02-25 17:37:22 +00:00
|
|
|
register: rkhunter
|
|
|
|
ignore_errors: true
|
2015-10-06 20:34:34 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Run rkhunter --propupd
|
2024-12-19 11:22:24 +10:00
|
|
|
ansible.builtin.command: /usr/bin/rkhunter --propupd
|
2018-04-04 19:24:21 +00:00
|
|
|
when: rkhunter is success
|