Skip to content

Commit 6f19074

Browse files
committed
make pytools role more general
1 parent 1d83ec5 commit 6f19074

File tree

5 files changed

+29
-32
lines changed

5 files changed

+29
-32
lines changed

ansible/roles/pytools/README.md

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,25 @@
1-
stackhpc.slurm_openstack_tools.pytools
1+
pytools
22
=========
33

4-
Installs python-based tools from https://github.com/stackhpc/slurm-openstack-tools.git into `/opt/slurm-tools/bin/`.
5-
6-
Requirements
7-
------------
4+
Install a python package into a venv.
85

96
Role Variables
107
--------------
8+
- `pytools_python_package`: Optional. Name of `dnf` python package to use. Default `python3`.
9+
- `pytools_venv_path`: Required. Path to install at, e.g. `/opt/mytool`.
10+
- `pytools_venv_command`: Optional. Command to run to create venv. Default uses the `pytools_python_package` python's `venv` module.
11+
- `pytools_pip_name`: Required. Name or URL of python package to install, passed to [ansible.builtin.pip:name](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/pip_module.html#parameter-name).
12+
- `pytools_editable`: Optional. Whether to install the package using `pip`'s editable mode (installing source to `{{ pytools_venv_path/src }}`). Bool, default `false`.
13+
- `pytools_user`: Optional. User to install as. Default `root`.
1114

12-
`pytools_editable`: Optional. Whether to install the package using `pip`'s editable mode (installing source to `/opt/slurm-tools/src`) - `true` or `false` (default).
13-
`pytools_gitref`: Optional. Git branch, version, commit etc to install. Default `master`.
14-
`pytools_user`: User to install as. Default `root`.
15-
16-
Dependencies
17-
------------
18-
None.
1915

2016
Example Playbook
2117
----------------
2218

2319
- hosts: compute
2420
tasks:
2521
- import_role:
26-
name: stackhpc.slurm_openstack_tools.pytools
27-
28-
29-
License
30-
-------
31-
32-
Apache-2.0
33-
34-
Author Information
35-
------------------
36-
22+
name: pytools
23+
vars:
24+
pytools_venv_path: /opt/slurm-tools
25+
pytools_pip_name: "git+https://github.com/stackhpc/slurm-openstack-tools.git@main#egg=slurm_openstack_tools"
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
22
# defaults file for pytools
3+
pytools_python_package: python3
4+
#pytools_venv_path:
5+
pytools_venv_command: "{{ pytools_python_package }} -m venv"
6+
#pytools_pip_name:
37
pytools_editable: false
4-
pytools_gitref: master
58
pytools_user: root
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
- name: install python3
3-
package:
4-
name: python3,git
2+
- name: Install packages
3+
dnf:
4+
name: "['git'] + {{ pytools_python_package }}"
55
become: true
66

77
- name: Create virtualenv directory
88
file:
9-
path: /opt/slurm-tools
9+
path: "{{ pytools_venv_path }}"
1010
owner: "{{ pytools_user }}"
1111
group: "{{ pytools_user }}"
1212
state: directory
@@ -21,14 +21,13 @@
2121

2222
- name: Create virtualenv
2323
pip:
24-
name: "git+https://github.com/stackhpc/slurm-openstack-tools.git@{{ pytools_gitref }}#egg=slurm_openstack_tools"
24+
name: "{{ pytools_pip_name }}"
2525
editable: "{{ pytools_editable }}"
2626

2727
module_defaults:
2828
ansible.builtin.pip:
29-
virtualenv: /opt/slurm-tools
30-
virtualenv_command: python3 -m venv
29+
virtualenv: "{{ pytools_venv_path }}"
30+
virtualenv_command: "{{ pytools_venv_command }}"
3131
state: latest
3232
become: true
3333
become_user: "{{ pytools_user }}"
34-
# become_flags: -H #'-s /bin/bash' # as has shell specified as /sbin/nologin

ansible/roles/slurm_stats/defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ slurm_stats_log_rotate_content_rotate: 7
1111

1212
# How frequently are the log files rotated. Can be one of daily, monthly, ...
1313
slurm_stats_log_rotate_content_frequency: daily
14+
15+
# Which branch/tag etc to install from
16+
slurm_stats_gitref: main

ansible/roles/slurm_stats/tasks/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
- name: Setup slurm tools
44
include_role:
55
name: pytools
6+
vars:
7+
pytools_venv_path: /opt/slurm-tools
8+
pytools_pip_name: "git+https://github.com/stackhpc/slurm-openstack-tools.git@{{ slurm_stats_gitref }}#egg=slurm_openstack_tools"
69

710
- name: Create a directory to house the log files
811
file:

0 commit comments

Comments
 (0)