Compare commits

..

3 commits

Author SHA1 Message Date
77916b47be
fixup
Some checks failed
/ Ansible Lint (push) Failing after 3m52s
/ Ansible Lint (pull_request) Failing after 2m45s
2025-07-01 03:59:34 +02:00
c868adc1bd
wip: ansible pull
Some checks failed
/ Ansible Lint (push) Failing after 2m0s
/ Ansible Lint (pull_request) Failing after 1m51s
2025-07-01 03:52:55 +02:00
2e9a9e0339
reboot(role): intro. reboot role, which handles local conns. gracefully
Also use this role instead of plain ansible.builtin.reboot.
This is in preparation for using ansible_pull as we don't want to have
ansible.builtin.reboot fail local playbook runs.
2025-07-01 03:52:55 +02:00
2 changed files with 2 additions and 15 deletions

View file

@ -1,5 +1,6 @@
- name: reboot the system - name: reboot the system
ansible.builtin.include_tasks: "../../reboot/tasks/main.yaml" ansible.builtin.import_role:
role: reboot
vars: vars:
# Simply don't reboot on local connections and rely on proper handling of /var/run/reboot-required. # Simply don't reboot on local connections and rely on proper handling of /var/run/reboot-required.
reboot__local_handling: ignore reboot__local_handling: ignore

View file

@ -10,17 +10,3 @@ A role for rebooting a host, which also handles local connections gracefully.
- `ignore`: Just doesn't reboot on local connections. - `ignore`: Just doesn't reboot on local connections.
- `file`: Doesn't reboot on local connections and instead touches the file defined by `reboot__local_handling_file`. - `file`: Doesn't reboot on local connections and instead touches the file defined by `reboot__local_handling_file`.
- `reboot__local_handling_file`: The file to touch, if `reboot__local_handling` is `file`. Defaults to `/var/run/ansible-reboot-required`. - `reboot__local_handling_file`: The file to touch, if `reboot__local_handling` is `file`. Defaults to `/var/run/ansible-reboot-required`.
## Usage in a Handler
Since a reboot should often be triggered from a handler and since handlers can't include or import roles, this roles logic can also be run by including the `main.yaml` task using `ansible.builtin.include_tasks` as a workaround.
When doing so, arguments should be specified explicitly as necessary (so at least `reboot__local_handling`) as the default role inclusion mechanisms like setting default values don't work.
An example handler would look like this:
```yaml
- name: reboot the system
ansible.builtin.include_tasks: "../../reboot/tasks/main.yaml"
vars:
reboot__local_handling: ignore
```