Skip to content

Commit

Permalink
make pytools role more general
Browse files Browse the repository at this point in the history
  • Loading branch information
sjpb committed Jan 15, 2025
1 parent 1d83ec5 commit 6f19074
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 32 deletions.
35 changes: 12 additions & 23 deletions ansible/roles/pytools/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
stackhpc.slurm_openstack_tools.pytools
pytools
=========

Installs python-based tools from https://github.com/stackhpc/slurm-openstack-tools.git into `/opt/slurm-tools/bin/`.

Requirements
------------
Install a python package into a venv.

Role Variables
--------------
- `pytools_python_package`: Optional. Name of `dnf` python package to use. Default `python3`.
- `pytools_venv_path`: Required. Path to install at, e.g. `/opt/mytool`.
- `pytools_venv_command`: Optional. Command to run to create venv. Default uses the `pytools_python_package` python's `venv` module.
- `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).
- `pytools_editable`: Optional. Whether to install the package using `pip`'s editable mode (installing source to `{{ pytools_venv_path/src }}`). Bool, default `false`.
- `pytools_user`: Optional. User to install as. Default `root`.

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

Dependencies
------------
None.

Example Playbook
----------------

- hosts: compute
tasks:
- import_role:
name: stackhpc.slurm_openstack_tools.pytools

License
-------

Apache-2.0

Author Information
------------------

name: pytools
vars:
pytools_venv_path: /opt/slurm-tools
pytools_pip_name: "git+https://github.com/stackhpc/slurm-openstack-tools.git@main#egg=slurm_openstack_tools"
5 changes: 4 additions & 1 deletion ansible/roles/pytools/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
# defaults file for pytools
pytools_python_package: python3
#pytools_venv_path:
pytools_venv_command: "{{ pytools_python_package }} -m venv"
#pytools_pip_name:
pytools_editable: false
pytools_gitref: master
pytools_user: root
15 changes: 7 additions & 8 deletions ansible/roles/pytools/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- name: install python3
package:
name: python3,git
- name: Install packages
dnf:
name: "['git'] + {{ pytools_python_package }}"
become: true

- name: Create virtualenv directory
file:
path: /opt/slurm-tools
path: "{{ pytools_venv_path }}"
owner: "{{ pytools_user }}"
group: "{{ pytools_user }}"
state: directory
Expand All @@ -21,14 +21,13 @@

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

module_defaults:
ansible.builtin.pip:
virtualenv: /opt/slurm-tools
virtualenv_command: python3 -m venv
virtualenv: "{{ pytools_venv_path }}"
virtualenv_command: "{{ pytools_venv_command }}"
state: latest
become: true
become_user: "{{ pytools_user }}"
# become_flags: -H #'-s /bin/bash' # as has shell specified as /sbin/nologin
3 changes: 3 additions & 0 deletions ansible/roles/slurm_stats/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ slurm_stats_log_rotate_content_rotate: 7

# How frequently are the log files rotated. Can be one of daily, monthly, ...
slurm_stats_log_rotate_content_frequency: daily

# Which branch/tag etc to install from
slurm_stats_gitref: main
3 changes: 3 additions & 0 deletions ansible/roles/slurm_stats/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
- name: Setup slurm tools
include_role:
name: pytools
vars:
pytools_venv_path: /opt/slurm-tools
pytools_pip_name: "git+https://github.com/stackhpc/slurm-openstack-tools.git@{{ slurm_stats_gitref }}#egg=slurm_openstack_tools"

- name: Create a directory to house the log files
file:
Expand Down

0 comments on commit 6f19074

Please sign in to comment.