Last active
January 31, 2018 06:35
-
-
Save miticojo/e217aac35149dc64e8f7103755260c02 to your computer and use it in GitHub Desktop.
OS rolling update with traditional RH repo and external rpm (for driver)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - hosts: nodes | |
| serial: "20%" | |
| vars: | |
| drivers_packages: | |
| - https://trello-attachments.s3.amazonaws.com/5967300a3e4895c3daf46c6f/5a2e5675861820458e017fa1/04710232eef65ff68adb8587d158e3e0/kmod-hpvsa-1.2.16-114.rhel7u4.x86_64.rpm | |
| proxy_http: '' | |
| proxy_https: '' | |
| tasks: | |
| - name: update os | |
| yum: | |
| name: "*" | |
| state: latest | |
| update_cache: yes | |
| - name: update os | |
| yum: | |
| name: "{{item}}" | |
| state: latest | |
| with_items: "{{drivers_packages}}" | |
| when: drivers_packages|length != 0 | |
| environment: | |
| http_proxy: "{{http_proxy}}" | |
| https_proxy: "{{https_proxy}}" | |
| - name: Check for reboot hint. | |
| shell: LAST_KERNEL=$(rpm -q --last kernel | awk 'NR==1{sub(/kernel-/,""); print $1}'); CURRENT_KERNEL=$(uname -r); if [ $LAST_KERNEL != $CURRENT_KERNEL ]; then echo 'reboot'; else echo 'no'; fi | |
| ignore_errors: true | |
| register: reboot_hint | |
| - name: Restart system | |
| shell: sleep 2 && shutdown -r now "Machine restart after update" | |
| when: reboot_hint.stdout.find("reboot") != -1 | |
| register: rebooting | |
| async: 1 | |
| poll: 0 | |
| ignore_errors: true | |
| become: yes | |
| - set_fact: | |
| wait_for_host: "{{ ansible_host }}" | |
| - name: Wait for restart | |
| local_action: | |
| module: wait_for | |
| host="{{ wait_for_host }}" | |
| state=started | |
| delay=10 | |
| timeout=600 | |
| port="{{ ansible_port | default(ansible_ssh_port | default(22,boolean=True),boolean=True) }}" | |
| become: no | |
| when: rebooting|changed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment