-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Ansible/Jinja2/Collections validation (#456)
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
- name: Verify you are using a supported Ansible version on your Ansible host | ||
ansible.builtin.assert: | ||
that: ansible_version['full'] is version(nginx_config_ansible_version, '>=') | ||
success_msg: Ansible {{ ansible_version['full'] }} is supported. | ||
fail_msg: Ansible {{ ansible_version['full'] }} has reached End of Life (EoL). Please upgrade to a supported Ansible release. Check the README for more details. | ||
delegate_to: localhost | ||
ignore_errors: true # noqa ignore-errors | ||
|
||
- name: Extract the version of Jinja2 installed on your Ansible host | ||
ansible.builtin.command: ansible --version | ||
register: jinja2_version | ||
changed_when: false | ||
delegate_to: localhost | ||
become: false | ||
|
||
- name: Verify that you are using a supported Jinja2 version on your Ansible host | ||
ansible.builtin.assert: | ||
that: (jinja2_version['stdout'] | regex_search('jinja version = ([\\d.]+)', '\\1') | first) is version(nginx_config_jinja2_version, '>=') | ||
success_msg: Jinja2 {{ jinja2_version['stdout'] | regex_search('jinja version = ([\d.]+)', '\1') | first }} is supported. | ||
fail_msg: Jinja2 {{ jinja2_version['stdout'] | regex_search('jinja version = ([\d.]+)', '\1') | first }} is not supported. Please upgrade to Jinja2 3.1. Check the README for more details. | ||
delegate_to: localhost | ||
become: false | ||
|
||
- name: Verify that the 'community.general' and 'ansible.posix' Ansible collections are installed on your Ansible host | ||
when: nginx_config_selinux | bool | ||
delegate_to: localhost | ||
become: false | ||
block: | ||
- name: Extract the list of Ansible collections installed on your Ansible host | ||
ansible.builtin.command: ansible-galaxy collection list | ||
register: collection_list | ||
changed_when: false | ||
|
||
- name: Verify that the 'community.general' Ansible collection is installed on your Ansible host | ||
ansible.builtin.assert: | ||
that: collection_list is search('community.general') | ||
success_msg: The 'community.general' Ansible collection is installed. | ||
fail_msg: The 'community.general' Ansible collection is not installed. Please install the 'community.general' Ansible collection. Check the README for more details. | ||
|
||
- name: Verify that the 'ansible.posix' Ansible collection is installed on your Ansible host | ||
ansible.builtin.assert: | ||
that: lookup('community.general.collection_version', 'ansible.posix') != 'none' | ||
success_msg: The 'ansible.posix' Ansible collection is installed. | ||
fail_msg: The 'ansible.posix' Ansible collection is not installed. Please install the 'ansible.posix' Ansible collection. Check the README for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
--- | ||
# Set the minimum version required for Ansible and Jinja2 | ||
nginx_config_ansible_version: 2.16 | ||
nginx_config_jinja2_version: 3.1 |