From 7fd4ed4c67a449a77e7004248def0e94b71a4024 Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Sep 30 2024 17:01:06 +0000 Subject: vhost_update: allow prompt to set targets for update / reboot Signed-off-by: Kevin Fenzi --- diff --git a/playbooks/vhost_reboot.yml b/playbooks/vhost_reboot.yml index 3fd1c7c..04ae534 100644 --- a/playbooks/vhost_reboot.yml +++ b/playbooks/vhost_reboot.yml @@ -16,6 +16,10 @@ # TODO: Figure out how to compare virt info pre and post boot. - name: find instances + vars_prompt: + - name: target + prompt: What is the target vhost + private: false hosts: "{{ target }}" gather_facts: False user: root @@ -33,6 +37,9 @@ local_action: add_host hostname={{ item }} groupname=myvms_new with_items: "{{ vmlist.list_vms }}" + - name: add the vmhost to target group + local_action: add_host hostname={{ target }} groupname=target + # Call out to another playbook. Disable any proxies that may live here - name: update proxy dns if needed import_playbook: update-proxy-dns.yml @@ -72,7 +79,7 @@ - name: shutdown vms virt: command=shutdown name={{ inventory_hostname }} ignore_errors: true - delegate_to: "{{ target }}" + delegate_to: "target" - name: wait for the whole set to die. hosts: myvms_new @@ -84,7 +91,7 @@ local_action: wait_for port=22 delay=30 timeout=300 state=stopped host={{ inventory_hostname }} - name: reboot vhost - hosts: "{{ target }}" + hosts: "target" gather_facts: False user: root diff --git a/playbooks/vhost_update.yml b/playbooks/vhost_update.yml index 0ed67cc..e3297ce 100644 --- a/playbooks/vhost_update.yml +++ b/playbooks/vhost_update.yml @@ -5,6 +5,10 @@ # - name: find instances + vars_prompt: + - name: target + prompt: What is the target vhost + private: false hosts: "{{ target }}" gather_facts: False user: root @@ -18,11 +22,14 @@ local_action: add_host hostname={{ item }} groupname=myvms_new with_items: '{{vmlist.list_vms}}' + - name: add the vmhost to target group + local_action: add_host hostname={{ target }} groupname=target + # Call out to another playbook. Disable any proxies that may live here #- include_playbook: update-proxy-dns.yml status=disable proxies=myvms_new:&proxies - name: set downtime - hosts: "{{ target }}:myvms_new" + hosts: "target:myvms_new" gather_facts: False user: root serial: 1 @@ -37,7 +44,7 @@ when: nonagios is not defined or not "true" in nonagios - name: update the system - hosts: "{{ target }}:myvms_new" + hosts: "target:myvms_new" gather_facts: True user: root @@ -70,7 +77,7 @@ when: package_excludes is defined - name: run rkhunter if installed - hosts: "{{ target }}:myvms_new" + hosts: "target:myvms_new" user: root tasks: