-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Open
Copy link
Labels
enhancementNew feature or requestNew feature or request
Description
I would like to improve the existing playbook examples which require variables.
Below is an example of the improvement. Essentially, we define external available variables, which can be easily overwritten or defined in the Web UI. In the playbook, we catch any non-defined variables by assigning the external variable values to a internal variable and define where possiable a default value. This is similar to what we do already.
The first Task should then do an assertion that we have all data if required and if not, return an error
- name: Nodegrid Software Upgrade Playbook
hosts: all
gather_facts: False
# Following Variables are required to be defined for the Target Nodegrid devices
# vars:
# nodegrid_iso_folder: "/var/local/file_manager/datastore/"
# nodegrid_iso_file: "Nodegrid_Platform_v5.10.1_20230530.iso"
# nodegrid_target_version: "5.10.1"
vars:
target_version: "{{ nodegrid_target_version | default('nodegrid_target_version NOT DEFINED') }}"
iso_src: "{{ nodegrid_iso_folder | default('/var/local/file_manager/datastore/') }}/{{ nodegrid_iso_file }}" # path on control node
iso_dest: "/var/sw/nodegrid.iso"
force_upgrade: "{{ nodegrid_iso_force_upgrade | default('FALSE') }}"
tasks:
- name: Validate checksums match
assert:
that:
- "nodegrid_iso_file is defined"
- "nodegrid_target_version is defined"
fail_msg: "Required variables are not defined for host. Define nodegrid_iso_file and nodegrid_target_version"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request