Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5519733312 |
No files matched your search
@@ -1,15 +0,0 @@
|
||||
---
|
||||
bugfixes:
|
||||
- >-
|
||||
docker - Read the distribution release through ``ansible_facts['distribution_release']`` for the APT
|
||||
source line, so the role works with ``inject_facts_as_vars`` set to false and in the ansible-core
|
||||
release that stops injecting facts as variables. The source line is unchanged.
|
||||
- >-
|
||||
gitea_runner - Read the timestamp of the forced re-registration backup through
|
||||
``ansible_facts['date_time']``, so the role works with ``inject_facts_as_vars`` set to false and in
|
||||
the ansible-core release that stops injecting facts as variables. The backup name is unchanged.
|
||||
- >-
|
||||
system_baseline - Read the OS family through ``ansible_facts['os_family']`` in the reboot check, so
|
||||
the role (and its ``reboot`` entry point) works with ``inject_facts_as_vars`` set to false and in
|
||||
the ansible-core release that stops injecting facts as variables. Before, the task failed with
|
||||
``'ansible_os_family' is undefined`` there.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
system_baseline - Add the input ``system_baseline_skip_upgrade_during_vzdump`` (default ``false``). With ``true`` on the ``pve`` system type,
|
||||
the main flow and the ``update`` entry point skip the apt upgrade while ``pvesh get /nodes/localhost/tasks --source active`` lists a
|
||||
``vzdump`` task, and say so. With the default no ``pvesh`` command runs and the upgrade is unchanged.
|
||||
@@ -4,7 +4,7 @@ Installs Docker Engine from the upstream Docker APT repository, optionally updat
|
||||
|
||||
## Supported platforms
|
||||
|
||||
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_facts['distribution_release']`. The apt architecture is derived from the host (`x86_64` gives `amd64`, `aarch64` gives `arm64`); any other architecture fails the play until `docker_apt_arch` is set. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested.
|
||||
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_distribution_release`. The apt architecture is derived from the host (`x86_64` gives `amd64`, `aarch64` gives `arm64`); any other architecture fails the play until `docker_apt_arch` is set. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested.
|
||||
|
||||
The role targets Ubuntu hosts only: it installs from Docker's Ubuntu repository, so it does not cover Debian trixie (Proxmox hosts).
|
||||
|
||||
@@ -91,7 +91,7 @@ With any of `docker_daemon_options`, `docker_live_restore`, `docker_log_driver`,
|
||||
What it shows, with the role's tasks running unchanged:
|
||||
|
||||
- The key is fetched, stored at `docker_keyring_path` with mode `0644`, and apt really verifies the repository against it (an unsigned or wrongly signed repository would leave no install candidate).
|
||||
- The source line has the architecture, the `signed-by` keyring and `ansible_facts['distribution_release']`.
|
||||
- The source line has the architecture, the `signed-by` keyring and `ansible_distribution_release`.
|
||||
- The packages are installed from that repository, the unit is enabled and active, and `docker_users` join `docker_group`.
|
||||
- `docker_remove` with `docker_remove_data` removes the source line, the keyring, the packages, the unit and `/var/lib/docker`.
|
||||
- Both units are installed, enabled, ordered against `docker.service` as stated, the shutdown unit is active, a unit is removed when its input is `false`, and `docker_remove` removes both.
|
||||
|
||||
@@ -6,7 +6,7 @@ argument_specs:
|
||||
- >-
|
||||
Installs Docker Engine from the upstream APT repository, or removes it when C(docker_remove) is true. Optionally updates the packages to
|
||||
the current candidate versions, then adds C(docker_users) to C(docker_group).
|
||||
- Needs gathered facts, because the APT source uses C(ansible_facts['distribution_release']).
|
||||
- Needs gathered facts, because the APT source uses C(ansible_distribution_release).
|
||||
options:
|
||||
docker_remove:
|
||||
type: bool
|
||||
@@ -53,7 +53,7 @@ argument_specs:
|
||||
type: str
|
||||
default: https://download.docker.com/linux/ubuntu
|
||||
description:
|
||||
- Base URL of the repository. The source line uses C(ansible_facts['distribution_release']) and the C(stable) component.
|
||||
- Base URL of the repository. The source line uses C(ansible_distribution_release) and the C(stable) component.
|
||||
docker_apt_arch:
|
||||
type: str
|
||||
default: ""
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ docker_apt_list_path }}"
|
||||
content: |
|
||||
deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_facts['distribution_release'] }} stable
|
||||
deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_distribution_release }} stable
|
||||
mode: "0644"
|
||||
register: __docker_apt_source
|
||||
tags: [docker, install]
|
||||
|
||||
@@ -18,7 +18,7 @@ The role targets Ubuntu hosts that run CI jobs, not Proxmox nodes, so it does no
|
||||
- The registration token is generated on the fly, held in a `no_log` fact and passed to `gitea-runner register` through the `GITEA_RUNNER_REGISTRATION_TOKEN` environment variable, not argv. It is never written to a file by the role.
|
||||
- The role creates `gitea_runner_group` and `gitea_runner_user` when they are missing; an existing account (for example the SSH login user) is reused.
|
||||
- Docker is installed by this role (`tasks/docker.yml`) on first install, not by `mortis.kamino.docker`.
|
||||
- Fact gathering must be on for `gitea_runner_force_register`: the backup name uses `ansible_facts['date_time']`.
|
||||
- Fact gathering must be on for `gitea_runner_force_register`: the backup name uses `ansible_date_time`.
|
||||
- Updates: the update path stages the verified binary and hands the swap to `mortis.kamino._binary_update`, an internal role of this Collection.
|
||||
- `gitea_runner_version` is asserted at role start to be a plain `X.Y.Z` release number, with no leading `v`. Pin it in inventory to move the runner independently of Collection releases; the role default changes only with a release.
|
||||
- The executor and job image of a job come from its label's suffix (`:host` or `docker://<image>`); a label with no suffix runs its jobs on the host. `config.yaml` has no keys for them.
|
||||
|
||||
@@ -19,7 +19,7 @@ argument_specs:
|
||||
C(gitea_runner_token_host), C(gitea_runner_instance_url) and C(gitea_runner_name) have empty role defaults and
|
||||
are asserted only when registration runs, so a run that never registers is not blocked.
|
||||
- >-
|
||||
Reads gathered facts (C(ansible_facts['date_time']), for the forced re-registration backup name) and
|
||||
Reads gathered facts (C(ansible_date_time), for the forced re-registration backup name) and
|
||||
C(ansible_check_mode).
|
||||
options:
|
||||
gitea_runner_remove:
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
src: "{{ gitea_runner_work_dir }}/.runner"
|
||||
dest: "{{ gitea_runner_work_dir }}/.runner.bak.{{ ansible_facts['date_time']['iso8601_basic_short'] }}"
|
||||
dest: "{{ gitea_runner_work_dir }}/.runner.bak.{{ ansible_date_time.iso8601_basic_short }}"
|
||||
remote_src: true
|
||||
owner: "{{ gitea_runner_state.stat.pw_name }}"
|
||||
group: "{{ gitea_runner_state.stat.gr_name }}"
|
||||
|
||||
@@ -12,7 +12,7 @@ The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and P
|
||||
|
||||
## Requirements and run order
|
||||
|
||||
- Facts must be gathered (`gather_facts: true`); `reboot.yml` reads `ansible_facts['os_family']`.
|
||||
- Facts must be gathered (`gather_facts: true`); `reboot.yml` reads `ansible_os_family`.
|
||||
- `system_baseline_system_type` is required and has no default (the role does not read a global such as `system_type`; map it in the inventory). Valid values: `ubuntu_lxc`, `ubuntu_vm` or `pve`.
|
||||
- Use it by its fully qualified name, `mortis.kamino.system_baseline`.
|
||||
- Collections: `community.general` (locale, timezone) and `ansible.posix` (sysctl, mount).
|
||||
@@ -37,6 +37,7 @@ templating error instead of the role's own message.
|
||||
| `system_baseline_remove_packages` | from profile | no | Packages to purge when present |
|
||||
| `system_baseline_apt_periodic_settings` | from profile | no | Keys for `20auto-upgrades` |
|
||||
| `system_baseline_apt_upgrade` | from profile | no | `safe` or `dist`: how the role upgrades packages (`pve`: `dist`, the Ubuntu profiles: `safe`); see "Apt upgrade mode" |
|
||||
| `system_baseline_skip_upgrade_during_vzdump` | `false` | no | `pve` only: skip the apt upgrade while a vzdump backup is running on the node (see "Skipping the upgrade during a backup") |
|
||||
| `system_baseline_unattended_upgrade_settings` | from profile | no | Keys for `50unattended-upgrades` |
|
||||
| `system_baseline_unattended_upgrade_origins` | from profile | no | Pinned `Origins-Pattern` entries; `[]` keeps the distribution default (see below) |
|
||||
| `system_baseline_unattended_upgrade_package_blacklist` | `[]` | no | Packages unattended-upgrades must not touch, as regular expressions (see below) |
|
||||
@@ -131,6 +132,7 @@ The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_
|
||||
- Verify checks the installed and removed packages, the journal size cap, the apt settings in `20auto-upgrades` and `50unattended-upgrades`, the locale, and that systemd loaded the `apt-daily.service` timeout.
|
||||
- Verify checks the tmux snippet: root-owned, valid shell, the session and quoted window command, no effect without a terminal, a session name or window command ending in a newline refused, and the file removed when autostart is off.
|
||||
- Converge also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. Verify reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, and that the connection is reset afterwards: the scenario skips the `update` tag, so the upgrade itself never runs there.
|
||||
- Verify runs the `update` entry point in check mode on the Ubuntu container with `system_baseline_system_type: pve` and a `pvesh` stub, in seven cases (a running, a finished or no vzdump task, the input off, `ubuntu_lxc`), and asserts the fact that decides the upgrade and that `pvesh` was run, with `--source active`, only when it should be. It does not assert that the apt task itself was skipped. The stub stands for the real answer, which no CI image has.
|
||||
- Verify runs the `reboot` entry point with `system_baseline_reboot_if_required: false`, without and with `/var/run/reboot-required`, and checks the fact and that the host did not reboot.
|
||||
- The `pve` origins pin is applied to the Ubuntu container and read back with `apt-config dump`, then removed again. The package blacklist is written, read back as a list, left alone by a second run and removed by an empty list.
|
||||
|
||||
@@ -195,6 +197,15 @@ The profile key `apt_upgrade` (`safe` or `dist`, resolved to `system_baseline_ap
|
||||
- The `update` entry point follows the same input: it upgrades with `dist` when `system_baseline_system_type` is `pve`. Without a `system_baseline_system_type` (the entry point does not require one) it stays on `safe`.
|
||||
- Only the apt upgrade changes. Autoremove and autoclean, the check-mode skip and unattended-upgrades are as before; the example blacklist below keeps unattended-upgrades away from the Proxmox packages.
|
||||
|
||||
### Skipping the upgrade during a backup
|
||||
|
||||
An upgrade of a Proxmox node can restart Proxmox services while a backup holds a snapshot of a guest. With `system_baseline_skip_upgrade_during_vzdump: true` and `system_baseline_system_type: pve`, the role runs `pvesh get /nodes/localhost/tasks --source active --limit 0` before the upgrade (`--source active` lists the running tasks; the default, `archive`, holds only finished ones). When one of the listed tasks has the type `vzdump` and no `endtime`, the upgrade is skipped and a message says why; autoremove, autoclean and the reboot check still run, and the role does not wait for the backup, so run it again afterwards.
|
||||
|
||||
- Off by default. With `false`, or on any other system type, no `pvesh` command runs.
|
||||
- The `update` entry point reads the input as well. In check mode the main flow skips the upgrade itself, so it does not ask for the tasks; the entry point previews the upgrade and so asks.
|
||||
- `localhost` is the node's own alias in the Proxmox API, so the role needs neither a node name nor gathered facts.
|
||||
- A `pvesh` answer that is not a JSON list stops the run, instead of upgrading on a guess.
|
||||
|
||||
### Apt scratch directory
|
||||
|
||||
The upgrade runs over the SSH connection Ansible uses. An `openssh-server` upgrade restarts `ssh.service`, and a unit with `PrivateTmp=yes` (the `systemd_hardening` role sets it) has its own `/tmp` and `/var/tmp`, which systemd deletes when the unit stops. The files apt staged there for the running upgrade then disappear and dpkg fails, leaving packages unpacked but not configured. So the `update` flow creates `system_baseline_apt_tmpdir` (root, mode `0700`), runs the upgrade and the autoremove with `TMPDIR` set to it, and opens a new connection afterwards, so that later tasks get a fresh private `/tmp`.
|
||||
|
||||
@@ -18,6 +18,9 @@ system_baseline_apt_tmpdir: /var/cache/system-baseline-apt-tmp
|
||||
# Run the package update (tasks/update.yml) in the main flow. false skips it, for hosts that are patched by a separate,
|
||||
# operator-run flow; the tasks_from: update entry point does not read it.
|
||||
system_baseline_update: true
|
||||
# Skip the apt upgrade while a vzdump backup is running on the Proxmox node (tasks/update.yml). Only for system_baseline_system_type pve;
|
||||
# both the main flow and the tasks_from: update entry point read it. Off by default.
|
||||
system_baseline_skip_upgrade_during_vzdump: false
|
||||
# Upper bound of the persistent journal (journald SystemMaxUse); older archived files are removed above it.
|
||||
system_baseline_journal_max_use: 200M
|
||||
# Attach an interactive SSH login to a tmux session (see tasks/tmux.yml). Off by default: it changes what every login does.
|
||||
|
||||
@@ -7,7 +7,7 @@ argument_specs:
|
||||
Validates C(system_baseline_system_type) and, when C(system_baseline_tmux_autostart) is true, the tmux session name and
|
||||
windows, then runs the update (unless C(system_baseline_update) is false), packages, unattended-upgrades, locale, timezone,
|
||||
journald, apt-daily timeout (when set), sysctl, tmpfs, tmux and reboot task files, in that order.
|
||||
- Needs gathered facts, because the reboot check reads C(ansible_facts['os_family']).
|
||||
- Needs gathered facts, because the reboot check reads C(ansible_os_family).
|
||||
- >-
|
||||
The resolved inputs C(system_baseline_profile), C(system_baseline_essential_packages),
|
||||
C(system_baseline_remove_packages), C(system_baseline_apt_periodic_settings), C(system_baseline_apt_upgrade),
|
||||
@@ -162,6 +162,18 @@ argument_specs:
|
||||
the reboot.
|
||||
- The C(update) entry point does not read it.
|
||||
- In check mode the main flow skips the upgrade itself (a pending update is not drift); autoremove and autoclean are still checked.
|
||||
system_baseline_skip_upgrade_during_vzdump:
|
||||
type: bool
|
||||
default: false
|
||||
description:
|
||||
- >-
|
||||
Skip the apt upgrade while a vzdump backup is running on the Proxmox node. Acts only when C(system_baseline_system_type) is
|
||||
C(pve): the role runs C(pvesh get /nodes/localhost/tasks --source active), and a C(vzdump) task in that list is a running backup.
|
||||
The upgrade is then skipped with a message, and the rest of the flow (autoremove, the reboot check) goes on. It does not wait for
|
||||
the backup. With false, or on any other system type, no C(pvesh) command runs.
|
||||
- >-
|
||||
The C(update) entry point reads it too, and a C(pvesh) answer that is not a JSON list fails the run instead of upgrading. In check mode the
|
||||
main flow skips the upgrade itself, so it does not ask for the tasks.
|
||||
update:
|
||||
short_description: Update and upgrade apt packages
|
||||
description:
|
||||
@@ -176,6 +188,9 @@ argument_specs:
|
||||
It creates C(system_baseline_apt_tmpdir), runs the upgrade and the autoremove with C(TMPDIR) set to it, and then opens a new
|
||||
connection, so that a restart of C(ssh.service) during the upgrade does not remove the files apt needs. It reads that input
|
||||
although the entry point has no argument specification of its own.
|
||||
- >-
|
||||
It also reads C(system_baseline_skip_upgrade_during_vzdump): with true on C(system_baseline_system_type) C(pve) it skips the upgrade while
|
||||
a vzdump backup is running.
|
||||
reboot:
|
||||
short_description: Compute system_baseline_reboot_required and reboot when allowed
|
||||
description:
|
||||
@@ -187,7 +202,7 @@ argument_specs:
|
||||
never reboots, so a caller can read C(system_baseline_reboot_required) (bool) and reboot on its own terms, for example after
|
||||
draining a node. The fact name and this behaviour are part of the role's interface.
|
||||
- On a non-Debian host the fact is not set; read it with C(default(false)).
|
||||
- Reads C(ansible_facts['os_family']), so facts must be gathered.
|
||||
- Reads C(ansible_os_family), so facts must be gathered.
|
||||
options:
|
||||
system_baseline_reboot_if_required:
|
||||
type: bool
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
---
|
||||
# One case of the vzdump guard: a pvesh stub answers with system_baseline_case_answer, the update entry point runs in check mode, and the
|
||||
# fact that decides the upgrade, and whether pvesh was asked at all, are compared with what the case expects. Kept outside the role's own tasks:
|
||||
# no CI image is a Proxmox node, so the stub stands for the real `pvesh get /nodes/<node>/tasks` answer.
|
||||
- name: Write the pvesh stub
|
||||
check_mode: false
|
||||
ansible.builtin.copy:
|
||||
dest: /usr/local/bin/pvesh
|
||||
mode: "0755"
|
||||
content: |
|
||||
#!/bin/sh
|
||||
echo "$*" >> /var/tmp/pvesh-calls
|
||||
cat <<'JSON'
|
||||
{{ system_baseline_case.answer | to_json }}
|
||||
JSON
|
||||
|
||||
- name: Create the apt scratch directory, which a check mode run does not
|
||||
check_mode: false
|
||||
ansible.builtin.file:
|
||||
path: /var/cache/system-baseline-apt-tmp
|
||||
state: directory
|
||||
mode: "0700"
|
||||
|
||||
- name: Forget earlier calls
|
||||
ansible.builtin.file:
|
||||
path: /var/tmp/pvesh-calls
|
||||
state: absent
|
||||
|
||||
- name: Run the update entry point in check mode
|
||||
check_mode: true
|
||||
block:
|
||||
- name: Include system_baseline, tasks_from update
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
tasks_from: update
|
||||
vars:
|
||||
system_baseline_system_type: "{{ system_baseline_case.type }}"
|
||||
system_baseline_skip_upgrade_during_vzdump: "{{ system_baseline_case.input }}"
|
||||
|
||||
- name: Read the recorded pvesh calls
|
||||
ansible.builtin.slurp:
|
||||
src: /var/tmp/pvesh-calls
|
||||
register: system_baseline_case_calls
|
||||
failed_when: false
|
||||
|
||||
- name: The guard decided as the case expects, and pvesh was asked only when it should be
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- __system_baseline_vzdump_running == system_baseline_case.running
|
||||
- (system_baseline_case_calls.content is defined) == system_baseline_case.asked
|
||||
- not system_baseline_case.asked or
|
||||
"get /nodes/localhost/tasks --source active --limit 0 --output-format json" in (system_baseline_case_calls.content | b64decode)
|
||||
quiet: true
|
||||
|
||||
- name: Remove the pvesh stub and its record
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- /usr/local/bin/pvesh
|
||||
- /var/tmp/pvesh-calls
|
||||
@@ -395,3 +395,22 @@
|
||||
- system_baseline_verify_blacklist_dump_removed.stdout_lines | select('match', 'Unattended-Upgrade::Package-Blacklist::\s') | list == []
|
||||
quiet: true
|
||||
tags: always
|
||||
|
||||
# The vzdump guard (system_baseline_skip_upgrade_during_vzdump): a running backup is a vzdump task without an endtime. With the input off, or on
|
||||
# a system type other than pve, pvesh is never run. Only the decision is asserted: the upgrade itself is not run in CI.
|
||||
- name: The vzdump guard skips the upgrade only for a running backup on a pve node
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Run each case
|
||||
ansible.builtin.include_tasks: tasks/vzdump_guard_case.yml
|
||||
vars:
|
||||
system_baseline_case: "{{ item }}"
|
||||
loop:
|
||||
- {type: pve, input: true, running: true, asked: true, answer: [{type: vzdump, upid: a, starttime: 1}]}
|
||||
- {type: pve, input: true, running: true, asked: true, answer: [{type: vzdump, upid: a, starttime: 1}, {type: qmstart, upid: b, starttime: 1}]}
|
||||
- {type: pve, input: true, running: false, asked: true, answer: [{type: vzdump, upid: a, starttime: 1, endtime: 2}]}
|
||||
- {type: pve, input: true, running: false, asked: true, answer: [{type: qmstart, upid: b, starttime: 1}]}
|
||||
- {type: pve, input: true, running: false, asked: true, answer: []}
|
||||
- {type: pve, input: false, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
|
||||
- {type: ubuntu_lxc, input: true, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
|
||||
@@ -4,7 +4,7 @@
|
||||
ansible.builtin.import_tasks: validate_reboot.yml
|
||||
|
||||
- name: Check if reboot required (Debian)
|
||||
when: ansible_facts['os_family'] == "Debian"
|
||||
when: ansible_os_family == "Debian"
|
||||
block:
|
||||
- name: Check if reboot is required (Debian)
|
||||
ansible.builtin.stat:
|
||||
|
||||
@@ -21,6 +21,58 @@
|
||||
mode: "0700"
|
||||
become: true
|
||||
|
||||
# Opt-in guard (system_baseline_skip_upgrade_during_vzdump, pve only): an upgrade can restart Proxmox services while a backup holds a snapshot
|
||||
# of a guest, so the upgrade waits for the next run when this node has a vzdump task without an end time. Both tasks read state only, so
|
||||
# they run in check mode too; they are skipped where the upgrade is (a dry run of the main flow). `localhost` is the node's own alias, so no
|
||||
# node name and no gathered facts are needed. --source active lists the running tasks: the default, archive, holds only finished ones. The
|
||||
# fact is set on every run, so a guard that is off or skipped never inherits the answer of an earlier run in the same play.
|
||||
- name: List the recent Proxmox tasks of this node
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- pvesh
|
||||
- get
|
||||
- /nodes/localhost/tasks
|
||||
- --source
|
||||
- active
|
||||
- --limit
|
||||
- "0"
|
||||
- --output-format
|
||||
- json
|
||||
register: __system_baseline_pve_tasks
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
become: true
|
||||
when:
|
||||
- system_baseline_skip_upgrade_during_vzdump | bool
|
||||
- system_baseline_system_type | default('') == 'pve'
|
||||
- not (ansible_check_mode and __system_baseline_main_flow | default(false))
|
||||
|
||||
- name: Check that pvesh answered with a list of tasks
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- __system_baseline_pve_tasks.stdout | from_json is sequence
|
||||
- __system_baseline_pve_tasks.stdout | from_json is not string
|
||||
- __system_baseline_pve_tasks.stdout | from_json is not mapping
|
||||
fail_msg: pvesh did not answer with a JSON list of tasks, so the role cannot tell whether a backup is running.
|
||||
quiet: true
|
||||
when: __system_baseline_pve_tasks is not skipped
|
||||
|
||||
- name: Note whether a vzdump backup is running on this node
|
||||
ansible.builtin.set_fact:
|
||||
__system_baseline_vzdump_running: >-
|
||||
{{ __system_baseline_pve_tasks is not skipped
|
||||
and (__system_baseline_pve_tasks.stdout | from_json
|
||||
| selectattr('type', 'equalto', 'vzdump')
|
||||
| rejectattr('endtime', 'defined')
|
||||
| list | length) > 0 }}
|
||||
|
||||
- name: Skip the upgrade while a vzdump backup is running
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
Skipping the apt upgrade on {{ inventory_hostname }}: a vzdump task is running on this node. Run the update again after the backup
|
||||
has finished.
|
||||
when: __system_baseline_vzdump_running | default(false)
|
||||
|
||||
# safe is the apt module's name for the plain upgrade (apt-get upgrade --with-new-pkgs), what `true` meant here before; dist runs
|
||||
# apt-get dist-upgrade (profile key apt_upgrade, `pve` by default).
|
||||
- name: Update & upgrade apt packages
|
||||
@@ -31,7 +83,9 @@
|
||||
environment:
|
||||
TMPDIR: "{{ system_baseline_apt_tmpdir }}"
|
||||
become: true
|
||||
when: not (ansible_check_mode and __system_baseline_main_flow | default(false))
|
||||
when:
|
||||
- not (ansible_check_mode and __system_baseline_main_flow | default(false))
|
||||
- not (__system_baseline_vzdump_running | default(false))
|
||||
|
||||
# autoremove must stay in this task: the apt module accepts autoclean alone only together with one of autoremove, name, update_cache or upgrade.
|
||||
- name: Remove unused packages and clean the apt cache
|
||||
|
||||
@@ -32,8 +32,5 @@ molecule --version
|
||||
# The collection under test first; molecule also installs it into each scenario's ANSIBLE_HOME,
|
||||
# which the run script keeps in the job tree.
|
||||
export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:${extra_collections}/opt/collections"
|
||||
# Facts are not injected as variables (deprecated in ansible-core 2.22, removal scheduled for 2.24, see #364), so a
|
||||
# role that reads a bare `ansible_<fact>` fails its scenario here instead of in a consumer's inventory.
|
||||
export ANSIBLE_INJECT_FACT_VARS=False
|
||||
python3 -I scripts/check_scenarios_load_checkout.py <<< "$selected"
|
||||
exec scripts/run_molecule_scenarios.sh "$AC_ROOT/molecule-runs" <<< "$selected"
|
||||
@@ -42,7 +42,7 @@ exit 0
|
||||
|
||||
# The scenario runner: records its arguments, paths and stdin.
|
||||
RUNNER_STUB = """#!/usr/bin/env bash
|
||||
echo "runner args=$* path=$PATH acp=$ANSIBLE_COLLECTIONS_PATH inject=${ANSIBLE_INJECT_FACT_VARS-unset} stdin=[$(cat | tr '\\n' ' ')]" >> "$STUB_LOG"
|
||||
echo "runner args=$* path=$PATH acp=$ANSIBLE_COLLECTIONS_PATH stdin=[$(cat | tr '\\n' ' ')]" >> "$STUB_LOG"
|
||||
"""
|
||||
|
||||
|
||||
@@ -112,16 +112,6 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
|
||||
self.assertIn(f"acp={self.ac_root}:/opt/collections ", runner)
|
||||
self.assertIn(f"args={self.ac_root}/molecule-runs ", runner)
|
||||
|
||||
def test_scenarios_run_with_fact_injection_off(self):
|
||||
# A role that reads a bare ansible_<fact> must fail its scenario here (#364), whichever way the pins went.
|
||||
for fail in ("", "1"):
|
||||
with self.subTest(pins_differ=bool(fail)):
|
||||
self.log.write_text("")
|
||||
result = self.run_script(STUB_FAIL_sha256sum=fail)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
(runner,) = self.calls("runner")
|
||||
self.assertIn(" inject=False ", runner)
|
||||
|
||||
def test_changed_pins_are_installed_and_put_first(self):
|
||||
result = self.run_script(STUB_FAIL_sha256sum="1")
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
|
||||
Reference in new issue
Block a user