diff --git a/ansible/roles/pytools/README.md b/ansible/roles/pytools/README.md index dec1b2c59..9066115aa 100644 --- a/ansible/roles/pytools/README.md +++ b/ansible/roles/pytools/README.md @@ -1,21 +1,17 @@ stackhpc.slurm_openstack_tools.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 ---------------- @@ -23,14 +19,7 @@ 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" diff --git a/ansible/roles/pytools/defaults/main.yml b/ansible/roles/pytools/defaults/main.yml index 2e88ac1a8..c06f194c7 100644 --- a/ansible/roles/pytools/defaults/main.yml +++ b/ansible/roles/pytools/defaults/main.yml @@ -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 diff --git a/ansible/roles/pytools/tasks/main.yml b/ansible/roles/pytools/tasks/main.yml index 89bfb663b..1c38a9cb8 100644 --- a/ansible/roles/pytools/tasks/main.yml +++ b/ansible/roles/pytools/tasks/main.yml @@ -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 @@ -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 diff --git a/ansible/roles/slurm_stats/defaults/main.yml b/ansible/roles/slurm_stats/defaults/main.yml index 4aaa75784..7b1bb1e43 100644 --- a/ansible/roles/slurm_stats/defaults/main.yml +++ b/ansible/roles/slurm_stats/defaults/main.yml @@ -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 diff --git a/ansible/roles/slurm_stats/tasks/main.yml b/ansible/roles/slurm_stats/tasks/main.yml index d681b7f3c..a108593ea 100644 --- a/ansible/roles/slurm_stats/tasks/main.yml +++ b/ansible/roles/slurm_stats/tasks/main.yml @@ -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: