Merge branch 'fedora-upgrade' into 'master'
add fedora-upgrade role, change package update headers to be more descriptive See merge request jlay/deploy-base!1
This commit is contained in:
commit
62eb3f28fb
5 changed files with 44 additions and 4 deletions
1
play.yml
1
play.yml
|
@ -6,6 +6,7 @@
|
||||||
roles:
|
roles:
|
||||||
- {role: bootstrap}
|
- {role: bootstrap}
|
||||||
- {role: update-packages}
|
- {role: update-packages}
|
||||||
|
- {role: fedora-upgrade}
|
||||||
- {role: install-packages}
|
- {role: install-packages}
|
||||||
- {role: create-user}
|
- {role: create-user}
|
||||||
- {role: hardening}
|
- {role: hardening}
|
||||||
|
|
4
roles/fedora-upgrade/defaults/main.yml
Normal file
4
roles/fedora-upgrade/defaults/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
fedora_latest: 30
|
||||||
|
fedora_minimum: 29
|
||||||
|
fedora_target: "{{ fedora_latest|int }}"
|
4
roles/fedora-upgrade/tasks/main.yml
Normal file
4
roles/fedora-upgrade/tasks/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- include_tasks: tasks.yml
|
||||||
|
when: (ansible_distribution in ["Fedora"] and not is_atomic) and (ansible_distribution_version != fedora_target and ansible_distribution_version >= fedora_minimum)
|
23
roles/fedora-upgrade/tasks/tasks.yml
Normal file
23
roles/fedora-upgrade/tasks/tasks.yml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: install dnf-plugin-system-upgrade
|
||||||
|
dnf:
|
||||||
|
name: dnf-plugin-system-upgrade
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: stage upgraded packages for fedora {{ fedora_target }}
|
||||||
|
shell: dnf -y system-upgrade download --releasever="{{ fedora_target }}"
|
||||||
|
warn: false
|
||||||
|
register: dnf_result
|
||||||
|
changed_when: "'Download complete' in dnf_result.stdout"
|
||||||
|
|
||||||
|
- name: trigger upgrade
|
||||||
|
shell: nohup bash -c 'sleep 2 && dnf system-upgrade reboot' &
|
||||||
|
register: upgraded_reset
|
||||||
|
when: (dnf_result is changed)
|
||||||
|
|
||||||
|
- name: wait for hosts to upgrade, reboot, and return
|
||||||
|
wait_for_connection:
|
||||||
|
timeout: 900
|
||||||
|
delay: 20
|
||||||
|
when: upgraded_reset is changed
|
|
@ -1,23 +1,31 @@
|
||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
|
|
||||||
- name: update packages (atomic)
|
- name: update packages (Fedora Atomic)
|
||||||
atomic_host:
|
atomic_host:
|
||||||
revision: latest
|
revision: latest
|
||||||
when: ansible_distribution == 'Fedora' and is_atomic
|
when: ansible_distribution == 'Fedora' and is_atomic
|
||||||
register: atomic_host_upgraded
|
register: atomic_host_upgraded
|
||||||
|
|
||||||
- name: update packages (non-atomic)
|
- name: refresh and update packages (Fedora)
|
||||||
|
dnf:
|
||||||
|
name: "*"
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
when: ansible_distribution == 'Fedora' and not is_atomic
|
||||||
|
register: fedora_upgraded
|
||||||
|
|
||||||
|
- name: update packages (generic - non-atomic/dnf)
|
||||||
package:
|
package:
|
||||||
name: '*'
|
name: '*'
|
||||||
state: latest
|
state: latest
|
||||||
when: ansible_distribution in ["CentOS", "Red Hat Enterprise Linux", "Fedora", "Debian", "Ubuntu"] and not is_atomic
|
when: ansible_distribution in ["CentOS", "Red Hat Enterprise Linux", "Debian", "Ubuntu"] and not is_atomic
|
||||||
register: host_upgraded
|
register: host_upgraded
|
||||||
|
|
||||||
- name: reboot updated hosts
|
- name: reboot updated hosts
|
||||||
shell: nohup bash -c "sleep 2 && shutdown -r now" &
|
shell: nohup bash -c "sleep 2 && shutdown -r now" &
|
||||||
register: host_reset
|
register: host_reset
|
||||||
when: (atomic_host_upgraded is changed) or (host_upgraded is changed)
|
when: (atomic_host_upgraded is changed) or (host_upgraded is changed) or (fedora_upgraded is changed)
|
||||||
|
|
||||||
- name: wait for rebooted host to return
|
- name: wait for rebooted host to return
|
||||||
wait_for_connection:
|
wait_for_connection:
|
||||||
|
|
Loading…
Reference in a new issue