-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathvalidation.yaml
More file actions
41 lines (39 loc) · 1.36 KB
/
validation.yaml
File metadata and controls
41 lines (39 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
- name: Playbook Validation
hosts: localhost
become: false
gather_facts: false
tags: always
tasks:
- name: Validate tags
ansible.builtin.fail:
msg: |
Improper usage of '--tags' flag:
{% set invalid_tags = ansible_run_tags | difference(global_map.tags.role) %}
{% if invalid_tags | length > 0 %}
- invalid tag{% if invalid_tags | length > 1 %}s{% endif %}: {{ invalid_tags | join(', ') }}
{% endif %}
- valid tags: {{ global_map.tags.role | join(', ') }}
when:
- ansible_run_tags not in [(), ('all',)]
- ansible_run_tags | difference(global_map.tags.role) | length > 0
- name: Validate version
ansible.builtin.fail:
msg: Invalid Ansible version, minimum requirement is '{{ global_map.ansible.version }}'.
when: ansible_version.full is not version(global_map.ansible.version, '>=')
- name: Cluster Validation
hosts: cluster
become: true
gather_facts: true
tags: always
tasks:
- name: Validate global settings
ansible.builtin.include_role:
apply:
tags: '{{ validation }}'
name: '{{ validation }}'
tasks_from: validation
loop: '{{ global_map.tags.role }}'
loop_control:
loop_var: validation
when: (ansible_run_tags in [(), ('all',)]) or (validation in ansible_run_tags)