mirror of
https://github.com/iiab/iiab.git
synced 2025-02-12 19:22:24 +00:00
Cleaner 0-init/tasks/validate_vars.yml
This commit is contained in:
parent
96c843eeb4
commit
b596360b8d
1 changed files with 7 additions and 6 deletions
|
@ -32,7 +32,8 @@
|
|||
# I want to perform input validation for Ansible playbooks"
|
||||
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
|
||||
|
||||
- name: Set vars_checklist for 46 + 46 vars ("XYZ_install" + "XYZ_enabled") to be checked
|
||||
# 2020-01-21: checks 46+46 vars...for now!
|
||||
- name: Set vars_checklist for ~46 + ~46 vars ("XYZ_install" + "XYZ_enabled") to be checked
|
||||
set_fact:
|
||||
vars_checklist:
|
||||
- hostapd
|
||||
|
@ -82,35 +83,35 @@
|
|||
- calibre
|
||||
- calibreweb
|
||||
|
||||
- name: Assert that 46 "XYZ_install" vars are defined
|
||||
- name: Assert that {{ vars_checklist | length }} "XYZ_install" vars are all... defined
|
||||
assert:
|
||||
that: "{{ item }}_install is defined"
|
||||
quiet: yes
|
||||
loop: "{{ vars_checklist }}"
|
||||
#register: install_vars_defined
|
||||
|
||||
- name: Assert that 46 "XYZ_enabled" vars are defined
|
||||
- name: Assert that {{ vars_checklist | length }} "XYZ_enabled" vars are all... defined
|
||||
assert:
|
||||
that: "{{ item }}_enabled is defined"
|
||||
quiet: yes
|
||||
loop: "{{ vars_checklist }}"
|
||||
#register: enabled_vars_defined
|
||||
|
||||
- name: Assert that 46 "XYZ_install" vars are type boolean (not type string, which can invert logic!)
|
||||
- name: Assert that {{ vars_checklist | length }} "XYZ_install" vars are all... type boolean (not type string, which can invert logic!)
|
||||
assert:
|
||||
that: "{{ item }}_install | type_debug == 'bool'"
|
||||
quiet: yes
|
||||
loop: "{{ vars_checklist }}"
|
||||
#register: install_vars_boolean
|
||||
|
||||
- name: Assert that 46 "XYZ_enabled" vars are type boolean (not type string, which can invert logic!)
|
||||
- name: Assert that {{ vars_checklist | length }} "XYZ_enabled" vars are all... type boolean (not type string, which can invert logic!)
|
||||
assert:
|
||||
that: "{{ item }}_enabled | type_debug == 'bool'"
|
||||
quiet: yes
|
||||
loop: "{{ vars_checklist }}"
|
||||
#register: enabled_vars_boolean
|
||||
|
||||
- name: 'DISALLOW "XYZ_install: False" WITH "XYZ_enabled: True" for 46 var pairs'
|
||||
- name: 'DISALLOW "XYZ_install: False" WITH "XYZ_enabled: True" ...for all {{ vars_checklist | length }} var pairs'
|
||||
assert:
|
||||
that: "{{ item }}_install or not {{ item }}_enabled"
|
||||
#fail_msg: '{{ item }}_install or not {{ item }}_enabled {{ item }}_install is {{ {{ item }}_install }} {{ item }}_enabled is {{ {{ item }}_enabled }}' # Is there a way to output var values ?
|
||||
|
|
Loading…
Reference in a new issue