Ansible Role linuxfabrik.lfops.shared¶
This role bundles helper tasks reused across other LFOps roles and playbooks. It is not designed to be run as a whole; instead, callers import individual tasks via import_role / include_role with tasks_from:.
Available since LFOps 2.0.1.
Available Tasks¶
log-start.yml and log-end.yml
- Append a
START/ENDline to/var/log/linuxfabrik-lfops.logon the target host. Includes the playbook name as well as run/skip tags. No-op in--checkmode and on Windows. Used aspre_tasks/post_tasksin every LFOps playbook. - Parameters: none.
print-messages.yml
- Prints the messages roles collected in
__shared__end_of_play_messagesas one block, so the operator sees every manual step in one place directly above thePLAY RECAPinstead of scattered over a long run. Skipped when nothing was collected, and clears the list afterwards so the next play of aplaybooks/all.ymlrun does not repeat it. Used aspost_tasksin every LFOps playbook, next tolog-end.yml. - Parameters: none. Reads
__shared__end_of_play_messages, see the "Reporting a Manual Step to the Operator" section of the CONTRIBUTING.md.
platform-variables.yml
- Loads OS-family / distribution / version-specific
vars/<name>.ymlfiles of the calling role, in order from least to most specific (e.g.RedHat.yml->RedHat8.yml->Rocky.yml->Rocky8.yml->Rocky8.10.yml). Missing files are skipped silently. - Parameters: none. Relies on
ansible_parent_role_paths[0](i.e. it must be imported from another role).
global-variables.yml
- Loads LFOps-wide platform variables from the shared role's own
vars/<name>.ymlfiles (role_path, not the calling role), using the same least-to-most-specific order asplatform-variables.yml. Imported in every playbook'spre_tasksso the variables are available to all roles in the play. - Parameters: none.
assert-reboot-possible.yml and request-reboot.yml
- The two halves of the reboot pattern, see the "Reboots" section of the CONTRIBUTING.md.
assert-reboot-possible.ymlbelongs in the calling role's validation block: it refuseslfops__reboot_nowon a host without/usr/local/sbin/schedule-rebootbefore the role writes anything, and registers the stat result the other file reads.request-reboot.ymlfiles the reboot request, performs the reboot right away whenlfops__reboot_nowis set, or reports the pending reboot to the operator when the mechanism is not deployed. Include it gated on the calling role's own "a reboot is needed" condition. - Parameters of
assert-reboot-possible.yml: none. -
Parameters of
request-reboot.yml:shared__reboot_reason: Mandatory. Spool file name, by convention the role name.shared__reboot_detail: Mandatory. What changed, in lower case. Goes into the notification mail, followed by the name of the calling role, and into the message the operator sees.
validate-role-arguments.yml
- Validates the variables of several roles against their
meta/argument_specs.ymlat once, see "Preflight Checks" in the CONTRIBUTING.md. Import it in thepre_tasksof a playbook that runs many roles, taggedalways, so that a missing or wrongly typed variable of a late role aborts the run before the first role changes the host. Roles withoutmeta/argument_specs.ymlare skipped. -
Parameters:
shared__validate_role_arguments_roles: Mandatory. List of role names, without the collection prefix.
clone-lib-repo.yml
- Clones the Linuxfabrik Python Libraries to
/tmp/ansible.lib-repoon the Ansible controller (delegate_to: localhost, serialized withthrottle: 1,--check-safe). Includes a rescue path that wipes the directory and retries on failure (e.g. when an existing checkout is on a different ref). -
Parameters:
shared__lib_version: Mandatory. The git ref to check out. Accepts'dev'(resolved tomain), a tag like'v1.2.3', or a bare version like'1.2.3'(auto-prefixed withv).
clone-monitoring-plugins-repo.yml
- Same as
clone-lib-repo.ymlbut for the Linuxfabrik Monitoring Plugins. Target on the controller:/tmp/ansible.monitoring-plugins-repo. -
Parameters:
shared__monitoring_plugins_version: Mandatory. Same semantics asshared__lib_version.
remove-rpmnew-rpmsave.yml
- Removes
<file>.rpmnew,<file>.rpmsave,<file>.dpkg-distand<file>.ucf-distfor a single config file. Only runs whenlfops__remove_rpmnew_rpmsaveistrue(LFOps-wide opt-in, see the main README). -
Parameters:
shared__remove_rpmnew_rpmsave_config_file: Mandatory. Absolute path of the deployed config file (without the.rpmnew/.rpmsavesuffix).
Usage Example¶
- name: 'Set LFOps-wide platform variables'
ansible.builtin.import_role:
name: 'shared'
tasks_from: 'global-variables.yml'
tags:
- 'always'
- name: 'Set platform/version specific variables'
ansible.builtin.import_role:
name: 'shared'
tasks_from: 'platform-variables.yml'
tags:
- 'always'
- name: 'Remove rpmnew / rpmsave'
ansible.builtin.include_role:
name: 'shared'
tasks_from: 'remove-rpmnew-rpmsave.yml'
vars:
shared__remove_rpmnew_rpmsave_config_file: '/etc/example/example.conf'