|
1 | 1 | ---
|
2 |
| -- name: Check whether you are using a supported NGINX distribution |
| 2 | +- name: Verify you are using a supported Ansible version on your Ansible host |
3 | 3 | ansible.builtin.assert:
|
4 |
| - that: |
5 |
| - - ansible_facts['distribution'] | lower in nginx_distributions.keys() | list |
6 |
| - - (ansible_facts['distribution_version'] | regex_search('\\d{1,2}\\.\\d{2}') | float in nginx_distributions[ansible_facts['distribution'] | lower]['versions'] | map('float') if ansible_facts['distribution'] | lower in ['alpine', 'ubuntu'] else ansible_facts['distribution_major_version'] in nginx_distributions[ansible_facts['distribution'] | lower]['versions'] | string) |
7 |
| - - ansible_facts['architecture'] in nginx_distributions[ansible_facts['distribution'] | lower]['architectures'] |
8 |
| - success_msg: Your distribution, {{ nginx_distributions[ansible_facts['distribution'] | lower]['name'] }} {{ ansible_facts['distribution_version'] }} ({{ ansible_facts['architecture'] }}), is supported by NGINX {{ (nginx_type == 'opensource') | ternary('Open Source', 'Plus') }}. |
9 |
| - fail_msg: Your distribution, {{ nginx_distributions[ansible_facts['distribution'] | lower]['name'] }} {{ ansible_facts['distribution_version'] }} ({{ ansible_facts['architecture'] }}), is not supported by NGINX {{ (nginx_type == 'opensource') | ternary('Open Source', 'Plus') }}. |
10 |
| - when: |
11 |
| - - nginx_enable | bool |
12 |
| - - (nginx_install_from == "nginx_repository" or nginx_type == "plus") |
| 4 | + that: ansible_version['full'] is version('2.16', '>=') |
| 5 | + success_msg: Ansible {{ ansible_version['full'] }} is supported. |
| 6 | + 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. |
| 7 | + delegate_to: localhost |
13 | 8 | ignore_errors: true # noqa ignore-errors
|
14 | 9 |
|
15 |
| -- name: Check that 'nginx_setup' is an allowed value |
| 10 | +- name: Extract the version of Jinja2 installed on your Ansible host |
| 11 | + ansible.builtin.command: ansible --version |
| 12 | + register: jinja2_version |
| 13 | + changed_when: false |
| 14 | + delegate_to: localhost |
| 15 | + become: false |
| 16 | + |
| 17 | +- name: Verify that you are using a supported Jinja2 version on your Ansible host |
| 18 | + ansible.builtin.assert: |
| 19 | + that: (jinja2_version['stdout'] | regex_search('jinja version = ([\\d.]+)', '\\1') | first) is version('3.1', '>=') |
| 20 | + success_msg: Jinja2 {{ jinja2_version['stdout'] | regex_search('jinja version = ([\d.]+)', '\1') | first }} is supported. |
| 21 | + 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. |
| 22 | + delegate_to: localhost |
| 23 | + become: false |
| 24 | + |
| 25 | +- name: Extract the list of Ansible collections installed on your Ansible host |
| 26 | + ansible.builtin.command: ansible-galaxy collection list |
| 27 | + register: collection_list |
| 28 | + changed_when: false |
| 29 | + delegate_to: localhost |
| 30 | + become: false |
| 31 | + |
| 32 | +- name: Verify that the 'community.general' Ansible collection is installed on your Ansible host |
| 33 | + ansible.builtin.assert: |
| 34 | + that: collection_list is search('community.general') |
| 35 | + success_msg: The 'community.general' Ansible collection is installed. |
| 36 | + fail_msg: The 'community.general' Ansible collection is not installed. Please install the 'community.general' Ansible collection. Check the README for more details. |
| 37 | + changed_when: false |
| 38 | + delegate_to: localhost |
| 39 | + become: false |
| 40 | + |
| 41 | +- name: Verify that the 'ansible.posix' Ansible collection is installed on your Ansible host |
| 42 | + ansible.builtin.assert: |
| 43 | + that: lookup('community.general.collection_version', 'ansible.posix') != 'none' |
| 44 | + success_msg: The 'ansible.posix' Ansible collection is installed. |
| 45 | + fail_msg: The 'ansible.posix' Ansible collection is not installed. Please install the 'ansible.posix' Ansible collection. Check the README for more details. |
| 46 | + delegate_to: localhost |
| 47 | + become: false |
| 48 | + when: nginx_selinux | bool |
| 49 | + |
| 50 | +- name: Verify that the 'community.crypto' Ansible collection is installed on your Ansible host |
| 51 | + ansible.builtin.assert: |
| 52 | + that: lookup('community.general.collection_version', 'community.crypto') != 'none' |
| 53 | + success_msg: The 'community.crypto' Ansible collection is installed. |
| 54 | + fail_msg: The 'community.crypto' Ansible collection is not installed. Please install the 'community.crypto' Ansible collection. Check the README for more details. |
| 55 | + delegate_to: localhost |
| 56 | + become: false |
| 57 | + when: nginx_type == 'plus' |
| 58 | + |
| 59 | +- name: Verify that 'nginx_setup' parameter is a valid value |
16 | 60 | ansible.builtin.assert:
|
17 | 61 | that: nginx_setup in nginx_setup_vars
|
18 |
| - fail_msg: The value you used for 'nginx_setup', {{ nginx_setup }}, is not allowed. The allowed values are [{{ nginx_setup_vars | join(', ') }}]. |
| 62 | + success_msg: The value you used for 'nginx_setup', {{ nginx_setup }}, is valid. |
| 63 | + fail_msg: The value you used for 'nginx_setup', {{ nginx_setup }}, is not valid. The valid values are [{{ nginx_setup_vars | join(', ') }}]. |
| 64 | + delegate_to: localhost |
| 65 | + become: false |
19 | 66 | when: nginx_enable | bool
|
20 | 67 | ignore_errors: true # noqa ignore-errors
|
21 | 68 |
|
22 |
| -- name: Check that 'nginx_branch' is an allowed value |
| 69 | +- name: Verify that 'nginx_branch' parameter is a valid value |
23 | 70 | ansible.builtin.assert:
|
24 | 71 | that: nginx_branch in nginx_branch_vars
|
25 |
| - fail_msg: The value you used for 'nginx_branch', {{ nginx_branch }}, is not allowed. The allowed values are [{{ nginx_branch_vars | join(', ') }}]. |
| 72 | + success_msg: The value you used for 'nginx_branch', {{ nginx_branch }}, is valid. |
| 73 | + fail_msg: The value you used for 'nginx_branch', {{ nginx_branch }}, is not allowed. The valid values are [{{ nginx_branch_vars | join(', ') }}]. |
| 74 | + delegate_to: localhost |
| 75 | + become: false |
26 | 76 | when: nginx_enable | bool
|
27 | 77 | ignore_errors: true # noqa ignore-errors
|
28 | 78 |
|
29 |
| -- name: Check that 'nginx_install_from' is an allowed value |
| 79 | +- name: Verify that 'nginx_install_from' parameter is a valid value |
30 | 80 | ansible.builtin.assert:
|
31 | 81 | that: nginx_install_from in nginx_install_from_vars
|
32 |
| - fail_msg: The value you used for 'nginx_install_from', {{ nginx_install_from }}, is not allowed. The allowed values are [{{ nginx_install_from_vars | join(', ') }}]. |
| 82 | + success_msg: The value you used for 'nginx_install_from', {{ nginx_install_from }} is valid. |
| 83 | + fail_msg: The value you used for 'nginx_install_from', {{ nginx_install_from }}, is not valid. The valid values are [{{ nginx_install_from_vars | join(', ') }}]. |
| 84 | + delegate_to: localhost |
| 85 | + become: false |
33 | 86 | when: nginx_enable | bool
|
34 | 87 | ignore_errors: true # noqa ignore-errors
|
| 88 | + |
| 89 | +- name: Verify whether you are using a supported NGINX distribution |
| 90 | + ansible.builtin.assert: |
| 91 | + that: |
| 92 | + - ansible_facts['distribution'] | lower in nginx_distributions.keys() | list |
| 93 | + - (ansible_facts['distribution_version'] | regex_search('\\d{1,2}\\.\\d{2}') | float in nginx_distributions[ansible_facts['distribution'] | lower]['versions'] | map('float') if ansible_facts['distribution'] | lower in ['alpine', 'ubuntu'] else ansible_facts['distribution_major_version'] in nginx_distributions[ansible_facts['distribution'] | lower]['versions'] | string) |
| 94 | + - ansible_facts['architecture'] in nginx_distributions[ansible_facts['distribution'] | lower]['architectures'] |
| 95 | + success_msg: Your distribution, {{ nginx_distributions[ansible_facts['distribution'] | lower]['name'] }} {{ ansible_facts['distribution_version'] }} ({{ ansible_facts['architecture'] }}), is supported by NGINX {{ (nginx_type == 'opensource') | ternary('Open Source', 'Plus') }}. |
| 96 | + fail_msg: Your distribution, {{ nginx_distributions[ansible_facts['distribution'] | lower]['name'] }} {{ ansible_facts['distribution_version'] }} ({{ ansible_facts['architecture'] }}), is not supported by NGINX {{ (nginx_type == 'opensource') | ternary('Open Source', 'Plus') }}. |
| 97 | + when: |
| 98 | + - nginx_enable | bool |
| 99 | + - (nginx_install_from == "nginx_repository" or nginx_type == "plus") |
| 100 | + ignore_errors: true # noqa ignore-errors |
0 commit comments