tests should pass now
This commit is contained in:
parent
99429ad930
commit
2f74674486
24
README.md
24
README.md
@ -13,9 +13,29 @@ Role Variables
|
|||||||
Available variables are listed below, along with default values. A sample file for the default values is available in `default/manage_pipx_packages.yml.sample` in case you need it for any `group_vars` or `host_vars` configuration.
|
Available variables are listed below, along with default values. A sample file for the default values is available in `default/manage_pipx_packages.yml.sample` in case you need it for any `group_vars` or `host_vars` configuration.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
your_defaults_here: default_value # by default, set to default_value
|
manage_pipx_packages_install_prereqs: true # by default, set to true
|
||||||
```
|
```
|
||||||
A quick description of the variable, what it does, and how to use it.
|
This variable defines if the prerequisites for the role should be installed. This should be left to true, unless you install python and pipx from another role prior to running this one.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
manage_pipx_packages_home: "/opt/pipx" # by default, set to /opt/pipx
|
||||||
|
```
|
||||||
|
This variable define where the pipx packages should be installed. By default, this is a generic path, in order to not tie the installs to a specific user.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
manage_pipx_packages_path: "/usr/local/bin" # by default, set to /usr/local/bin
|
||||||
|
```
|
||||||
|
This variable defines the path on which to make the package available. Please note that the actual installation will be done on the `manage_pipx_packages_home` path. The path given here will be simlinked to the installed package.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
manage_pipx_packages_list: # by default, set to install ansible-core
|
||||||
|
- name: ansible-core
|
||||||
|
version_constraint: latest
|
||||||
|
state: present
|
||||||
|
```
|
||||||
|
This variable is a list of packages, with their name, desired version and state. `version_constraint` can be multiple constraints,separated by commas (example: `>1.10`, `>1.10,<1.15,!=1.12`,`==1.13`).
|
||||||
|
[!WARNING]
|
||||||
|
Test ?
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
---
|
---
|
||||||
# defaults file for manage_pipx_packages
|
# defaults file for manage_pipx_packages
|
||||||
manage_pipx_packages_install_prereqs: true
|
manage_pipx_packages_install_prereqs: true
|
||||||
|
manage_pipx_packages_home: "/opt/pipx"
|
||||||
manage_pipx_packages_path: "/usr/local/bin"
|
manage_pipx_packages_path: "/usr/local/bin"
|
||||||
manage_pipx_packages_list:
|
manage_pipx_packages_list:
|
||||||
- name: ansible-core
|
- name: ansible-lint
|
||||||
version_constraint: latest
|
version_constraint: latest
|
||||||
state: present
|
state: present
|
||||||
|
8
defaults/manage_pipx_packages.yml.sample
Normal file
8
defaults/manage_pipx_packages.yml.sample
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
manage_pipx_packages_install_prereqs: true
|
||||||
|
manage_pipx_packages_home: "/opt/pipx"
|
||||||
|
manage_pipx_packages_path: "/usr/local/bin"
|
||||||
|
manage_pipx_packages_list:
|
||||||
|
- name: ansible-lint
|
||||||
|
version_constraint: latest
|
||||||
|
state: present
|
@ -18,10 +18,12 @@
|
|||||||
- 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"
|
- name: "Test: packages ansible-lint"
|
||||||
block:
|
block:
|
||||||
- name: "Get pipx installed packages"
|
- name: "Get pipx installed packages"
|
||||||
ansible.builtin.command: "pipx list --json"
|
ansible.builtin.command: "pipx list --json"
|
||||||
|
environment:
|
||||||
|
PIPX_HOME: "/opt/pipx"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: pipx_installed_packages
|
register: pipx_installed_packages
|
||||||
|
|
||||||
@ -30,12 +32,10 @@
|
|||||||
pipx_simple_list: "{{ pipx_simple_list | default({}) | combine({item.key: item.value.metadata.main_package.package_version}) }}"
|
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 }}"
|
loop: "{{ pipx_installed_packages.stdout | from_json | json_query('venvs') | dict2items }}"
|
||||||
|
|
||||||
- name: "Verify packages ansible-core"
|
- name: "Verify packages ansible-lint"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- pipx_simple_list['yamllint'] is not defined
|
- pipx_simple_list['ansible-lint'] is defined
|
||||||
- pipx_simple_list['ansible-core'] is defined
|
|
||||||
- pipx_simple_list['vault-cli'] is not defined
|
|
||||||
|
|
||||||
- name: "Print installed packages"
|
- name: "Print installed packages"
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
manage_pipx_packages_install_prereqs: true
|
manage_pipx_packages_install_prereqs: true
|
||||||
|
manage_pipx_packages_home: "/opt/pipx"
|
||||||
manage_pipx_packages_path: "/usr/local/bin"
|
manage_pipx_packages_path: "/usr/local/bin"
|
||||||
manage_pipx_packages_list:
|
manage_pipx_packages_list:
|
||||||
- name: ansible-core
|
- name: ansible-core
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
block:
|
block:
|
||||||
- name: "Get pipx installed packages"
|
- name: "Get pipx installed packages"
|
||||||
ansible.builtin.command: "pipx list --json"
|
ansible.builtin.command: "pipx list --json"
|
||||||
|
environment:
|
||||||
|
PIPX_HOME: "/opt/pipx"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: pipx_installed_packages
|
register: pipx_installed_packages
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
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_HOME: "{{ manage_pipx_packages_home }}"
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user