-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This role can be used to update a SEAPATH machine. It is based on the update_machine_cluster.yaml and update_machine_standalone.yaml of the main branch. Signed-off-by: Mathieu Dupré <[email protected]>
- Loading branch information
1 parent
e2c7d9f
commit 30ef9cb
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# SEAPATH Update Role | ||
|
||
This role can be used to update a SEAPATH machine. | ||
|
||
⚠ For the moment, only Yocto’s version of SEAPATH is supported. | ||
|
||
## Requirements | ||
|
||
No requirement. | ||
|
||
## Role Variables | ||
|
||
| Variable | Required | Default | Comments | | ||
|-------------------------|----------|-----------|--------------------------------------------------| | ||
| swu_image | yes | swu_image | Path of the swupdate file on the Ansible machine | | ||
|
||
## Dependencies | ||
|
||
No dependency. | ||
|
||
## Example Playbook | ||
|
||
```yaml | ||
- hosts: cluster_machines | ||
roles: | ||
- { role: seapath_ansible.update } | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (C) 2024 Savoir-faire Linux, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
--- | ||
swu_image: update.swu |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (C) 2024 Savoir-faire Linux, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
--- | ||
galaxy_info: | ||
author: "Seapath" | ||
description: Update a SEAPATH machine | ||
min_ansible_version: 2.9.10 | ||
license: Apache-2.0 | ||
dependencies: [] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright (C) 2024 Savoir-faire Linux, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
--- | ||
|
||
- name: Check if the system have swupdate | ||
command: swupdate -v | ||
register: swupdate_version | ||
ignore_errors: yes | ||
- fail: | ||
msg: "Only Swupdate update is supported" | ||
when: swupdate_version.rc != 0 | ||
|
||
|
||
- name: Check the SEAPATH mode, cluster or standalone | ||
stat: | ||
path: /etc/corosync/corosync.conf | ||
register: corosync_conf | ||
|
||
- block: | ||
- name: Set hypervisor in maintenance mode | ||
command: crm node standby "{{ inventory_hostname }}" | ||
- name: Wait for all ressources to be migrated | ||
shell: | ||
cmd: crm status|grep "Migrating"|wc -l | ||
register: check_migration | ||
until: check_migration.stdout == '0' | ||
retries: 10 | ||
when: corosync_conf.stat.exists | ||
|
||
- name: Copy SWU file on machine | ||
copy: | ||
src: "{{ swu_image_path }}" | ||
dest: "/tmp/update.swu" | ||
- name: Apply update | ||
command: swupdate -i /tmp/update.swu | ||
- name: Reboot host | ||
reboot: | ||
msg: "Reboot initiated by Ansible" | ||
connect_timeout: 5 | ||
reboot_timeout: 600 | ||
pre_reboot_delay: 0 | ||
post_reboot_delay: 30 | ||
test_command: whoami | ||
- name: Wait systemd has finished to boot | ||
command: systemctl is-system-running --wait | ||
register: system_status | ||
failed_when: system_status.rc != 0 and system_status.rc != 1 | ||
tags: | ||
- skip_ansible_lint | ||
|
||
|
||
- name: unset maintenance mode for hypervisor | ||
command: crm node online "{{ inventory_hostname }}" | ||
when: corosync_conf.stat.exists | ||
|
||
- name: Check if update has succeed | ||
shell: | ||
cmd: journalctl -u swupdate_check.service -b |grep "Update have failed"|wc -l | ||
register: update_status | ||
failed_when: update_status.stdout != '0' |