added 2nd molecule test and they work now
This commit is contained in:
parent
84c0b6d243
commit
99429ad930
@ -17,3 +17,26 @@
|
|||||||
- stat_etc_hosts.stat.isreg
|
- stat_etc_hosts.stat.isreg
|
||||||
- stat_etc_hosts.stat.pw_name == 'root'
|
- stat_etc_hosts.stat.pw_name == 'root'
|
||||||
- stat_etc_hosts.stat.gr_name == 'root'
|
- stat_etc_hosts.stat.gr_name == 'root'
|
||||||
|
|
||||||
|
- name: "Test: packages ansible-core"
|
||||||
|
block:
|
||||||
|
- name: "Get pipx installed packages"
|
||||||
|
ansible.builtin.command: "pipx list --json"
|
||||||
|
changed_when: false
|
||||||
|
register: pipx_installed_packages
|
||||||
|
|
||||||
|
- name: "Set fact"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
pipx_simple_list: "{{ pipx_simple_list | default({}) | combine({item.key: item.value.metadata.main_package.package_version}) }}"
|
||||||
|
loop: "{{ pipx_installed_packages.stdout | from_json | json_query('venvs') | dict2items }}"
|
||||||
|
|
||||||
|
- name: "Verify packages ansible-core"
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- pipx_simple_list['yamllint'] is not defined
|
||||||
|
- pipx_simple_list['ansible-core'] is defined
|
||||||
|
- pipx_simple_list['vault-cli'] is not defined
|
||||||
|
|
||||||
|
- name: "Print installed packages"
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ pipx_simple_list }}"
|
||||||
|
@ -18,29 +18,25 @@
|
|||||||
- stat_etc_hosts.stat.pw_name == 'root'
|
- stat_etc_hosts.stat.pw_name == 'root'
|
||||||
- stat_etc_hosts.stat.gr_name == 'root'
|
- stat_etc_hosts.stat.gr_name == 'root'
|
||||||
|
|
||||||
- name: "Test: packages pip, vault-cli, yamllint, docker"
|
- name: "Test: packages pip, vault-cli, yamllint, ansible-core"
|
||||||
block:
|
block:
|
||||||
- name: "Get pip3 up-to-date packages"
|
- name: "Get pipx installed packages"
|
||||||
ansible.builtin.command: "pip3 list -u --format=json"
|
ansible.builtin.command: "pipx list --json"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: pip_updated_packages
|
register: pipx_installed_packages
|
||||||
|
|
||||||
- name: "Get pip3 out-of-date packages"
|
- name: "Set fact"
|
||||||
ansible.builtin.command: "pip3 list -o --format=json"
|
ansible.builtin.set_fact:
|
||||||
changed_when: false
|
pipx_simple_list: "{{ pipx_simple_list | default({}) | combine({item.key: item.value.metadata.main_package.package_version}) }}"
|
||||||
register: pip_outdated_packages
|
loop: "{{ pipx_installed_packages.stdout | from_json | json_query('venvs') | dict2items }}"
|
||||||
|
|
||||||
- name: "Verify packages pip, vault-cli, yamllint, docker"
|
- name: "Verify packages pip, vault-cli, yamllint, ansible-core"
|
||||||
vars:
|
|
||||||
pip_up_to_date_list: "{{ pip_updated_packages.stdout | from_json | json_query('[].name') }}"
|
|
||||||
pip_out_of_date_list: "{{ pip_outdated_packages.stdout | from_json | json_query('[].name') }}"
|
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "'pip' in pip_up_to_date_list"
|
- pipx_simple_list['yamllint'] is defined
|
||||||
- "'pip' not in pip_out_of_date_list"
|
- pipx_simple_list['ansible-core'] is defined
|
||||||
- "'vault-cli' not in pip_up_to_date_list"
|
- pipx_simple_list['vault-cli'] is defined
|
||||||
- "'vault-cli' in pip_out_of_date_list"
|
|
||||||
- "'yamllint' not in pip_up_to_date_list"
|
- name: "Print installed packages"
|
||||||
- "'yamllint' in pip_out_of_date_list"
|
ansible.builtin.debug:
|
||||||
- "'docker' in pip_up_to_date_list"
|
msg: "{{ pipx_simple_list }}"
|
||||||
- "'docker' not in pip_out_of_date_list"
|
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
community.general.pipx:
|
community.general.pipx:
|
||||||
name: "{{ item.name }}{% if item.version_constraint not in [None, '', 'latest'] %}{{ item.version_constraint }}{% endif %}"
|
name: "{{ item.name }}{% if item.version_constraint not in [None, '', 'latest'] %}{{ item.version_constraint }}{% endif %}"
|
||||||
state: "{{ item.state }}"
|
state: "{{ item.state }}"
|
||||||
# environment:
|
environment:
|
||||||
# PIPX_BIN_DIR: "{{ manage_pipx_packages_path }}"
|
PIPX_BIN_DIR: "{{ manage_pipx_packages_path }}"
|
||||||
loop: "{{ manage_pipx_packages_list }}"
|
loop: "{{ manage_pipx_packages_list }}"
|
||||||
when: manage_pipx_packages_list is defined
|
when: manage_pipx_packages_list is defined
|
||||||
and manage_pipx_packages_list not in [None, '']
|
and manage_pipx_packages_list not in [None, '']
|
||||||
|
Loading…
Reference in New Issue
Block a user