|
1 | | -- name: Verify minimum Ansible version is {{ required_ansible_version }} |
| 1 | +--- |
| 2 | +# 1. Check minimum Ansible version |
| 3 | +# ----------------------------------------------------------------------------- |
| 4 | +- name: "Verify minimum Ansible version is {{ required_ansible_version }}" |
2 | 5 | assert: |
3 | 6 | that: "ansible_version.full is version_compare(required_ansible_version, '>=')" |
4 | 7 | fail_msg: "This collection is only supported on Ansible version {{ required_ansible_version }} or greater, your current Ansible version is {{ ansible_version.full }}" |
| 8 | + |
| 9 | + |
| 10 | +# 2. Check minimum mas-devop python package version |
| 11 | +# ----------------------------------------------------------------------------- |
| 12 | +- name: "Check if mas-devops package is installed and meets minimum version" |
| 13 | + command: pip show mas-devops |
| 14 | + register: mas_devops_package_info |
| 15 | + changed_when: false |
| 16 | + failed_when: false |
| 17 | + |
| 18 | +- name: "Get installed version of mas-devops" |
| 19 | + when: mas_devops_package_info.stdout != "" |
| 20 | + set_fact: |
| 21 | + mas_devops_version: "{{ mas_devops_package_info.stdout | regex_search('Version: (.+)', '\\1', multiline=True) }}" |
| 22 | + |
| 23 | +- name: "Verify minimum mas-devops is installed" |
| 24 | + assert: |
| 25 | + that: |
| 26 | + - mas_devops_version is defined |
| 27 | + - mas_devops_version != "" |
| 28 | + fail_msg: "The mas-devops python package is not installed." |
| 29 | + |
| 30 | +- name: "Verify minimum mas-devops version is {{ required_mas_devops_python_version }}" |
| 31 | + assert: |
| 32 | + that: |
| 33 | + - mas_devops_version is defined |
| 34 | + - mas_devops_version[0] is defined |
| 35 | + - mas_devops_version[0] is version_compare(required_mas_devops_python_version, '>=') |
| 36 | + fail_msg: "The version of mas-devops python package installed is too old (minimum version is {{ required_mas_devops_python_version }})." |
0 commit comments