summaryrefslogtreecommitdiffstats
path: root/deployment/playbooks/roles/yum-update-and-reboot
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2019-02-07 02:08:23 +0530
committerValerii Ponomarov <vponomar@redhat.com>2019-02-07 02:36:02 +0530
commit25fcd9c5aa4c360eff19ef08fc4e2bdff6147ffd (patch)
tree544cf09479861ee7c434a7f9ece19167c14ddf35 /deployment/playbooks/roles/yum-update-and-reboot
parenta6c7dead0d6ddad4dae93a4292891617b50b44a0 (diff)
Add end-to-end OCP 'deployment' functionality
Add end-to-end deployment tool of OpenShift and OpenShift Container Storage on top of VMWare. Added code is modified version of the 'reference-architecture/vmware-ansible' dir from the following repo: https://github.com/vponomaryov/openshift-ansible-contrib Read 'deployment/README.rst' file for more details about the deployment tool. Change-Id: Ic96f252ff786cc1ecf24d27f0ec47e324131e41b
Diffstat (limited to 'deployment/playbooks/roles/yum-update-and-reboot')
-rw-r--r--deployment/playbooks/roles/yum-update-and-reboot/tasks/main.yaml44
1 files changed, 44 insertions, 0 deletions
diff --git a/deployment/playbooks/roles/yum-update-and-reboot/tasks/main.yaml b/deployment/playbooks/roles/yum-update-and-reboot/tasks/main.yaml
new file mode 100644
index 00000000..d53f5bd2
--- /dev/null
+++ b/deployment/playbooks/roles/yum-update-and-reboot/tasks/main.yaml
@@ -0,0 +1,44 @@
+# NOTE(vponomar): this role should not be run from nodes
+# which are going to be rebooted.
+---
+
+- block:
+ - name: Check that hostnames_for_reboot var is set and it is not empty list
+ fail:
+ msg: "Role 'yum-update-and-reboot' expects 'hostnames_for_reboot' var
+ to be set as a list of hostnames which should be rebooted."
+ when: "(hostnames_for_reboot is not defined) or hostnames_for_reboot | length < 1"
+
+ - name: Run yum_update command
+ command: "yum update -y"
+ delegate_to: "{{ item }}"
+ with_items: "{{ hostnames_for_reboot }}"
+
+ - name: Reboot machine to apply all major changes to the system if exist
+ shell: "sleep 3 ; /sbin/shutdown -r now 'Reboot triggered by Ansible'"
+ async: 1
+ poll: 0
+ ignore_errors: true
+ delegate_to: "{{ item }}"
+ with_items: "{{ hostnames_for_reboot }}"
+
+ - name: Wait for machine to go down
+ wait_for:
+ host: "{{ item }}"
+ port: 22
+ delay: 0
+ timeout: 180
+ connect_timeout: 5
+ state: stopped
+ with_items: "{{ hostnames_for_reboot }}"
+
+ - name: Wait for machine to go up
+ wait_for:
+ host: "{{ item }}"
+ port: 22
+ delay: 0
+ timeout: 180
+ connect_timeout: 5
+ state: started
+ with_items: "{{ hostnames_for_reboot }}"
+ when: "disable_yum_update_and_reboot is undefined or not (disable_yum_update_and_reboot | bool)"