Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
---
language: python
python: "2.7"

# Use the new container infrastructure
sudo: false

# Install ansible
addons:
apt:
packages:
- python-pip

sudo: required
services:
- docker
before_install:
- sudo apt-get -qq update
install:
# Install ansible
- pip install ansible ansible-lint

- python3 -m pip install ansible
- python3 -m pip install ansible-lint
- python3 -m pip install molecule
- python3 -m pip install docker

# Check ansible version
- ansible --version

Expand All @@ -34,5 +32,8 @@ script:
# Test the custom filters
- ansible-playbook tests/filter.yml -i tests/inventory -i tests/inventory-mock-groups

# Run molecule tests
- molecule test

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
33 changes: 33 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# Based on ansible-lint config
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ Role Variables
Otherwise, `groups` can be omitted and the following attributes can be defined in the partition object:
* `name`: The name of the nodes within this group.
* `cluster_name`: Optional. An override for the top-level definition `openhpc_cluster_name`.
* `num_nodes`: Nodes within the group are assumed to number `0:num_nodes-1`.
* `ram_mb`: Optional. The physical RAM available in each server of this group ([slurm.conf](https://slurm.schedmd.com/slurm.conf.html) parameter `RealMemory`).
* `ram_mb`: Optional. The physical RAM available in each server of this group ([slurm.conf](https://slurm.schedmd.com/slurm.conf.html) parameter `RealMemory`). This is set to the Slurm default of `1` if not defined.

For each group (if used) or partition there must be an ansible inventory group `{cluster_name}_{group_name}`. The compute nodes in this group must have hostnames in the form `{cluster_name}-{group_name}-{0..num_nodes-1}`. Note the inventory group uses "_" and the instances use "-".
For each group (if used) or partition there must be an ansible inventory group `<cluster_name>_<group_name>`. All nodes in this inventory group will be added to the group/partition. Nodes may have arbitrary hostnames but these should be lowercase to avoid a mismatch between inventory and actual hostname.

* `default`: Optional. A boolean flag for whether this partion is the default. Valid settings are `YES` and `NO`.
* `maxtime`: Optional. A partition-specific time limit in hours, minutes and seconds ([slurm.conf](https://slurm.schedmd.com/slurm.conf.html) parameter `MaxTime`). The default value is
Expand Down Expand Up @@ -82,16 +81,10 @@ To deploy, create a playbook which looks like this:
openhpc_slurm_control_host: "{{ groups['cluster_control'] | first }}"
openhpc_slurm_partitions:
- name: "compute"
num_nodes: 8
openhpc_cluster_name: openhpc
openhpc_packages: []
...

Note that the "compute" of the openhpc_slurm_partition name and the
openhpc_cluster_name are used to generate the compute node in the
slurm config of openhpc-compute-[0:7]. Your inventory entries
for that partition must match that convention.

To drain nodes, for example, before scaling down the cluster to 6 nodes:

---
Expand Down
2 changes: 1 addition & 1 deletion filter_plugins/group_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _group_hosts(hosts):
r.append(int(suffix))
else:
unmatchable.append(v)
return ['{}[{}]'.format(k, _group_numbers(v)) for k, v in results.iteritems()] + unmatchable
return ['{}[{}]'.format(k, _group_numbers(v)) for k, v in results.items()] + unmatchable

def _group_numbers(numbers):
units = []
Expand Down
39 changes: 39 additions & 0 deletions molecule/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Molecule tests for the role.

# Test Matrix

Test options "flow down" through table unless changed.

Test | # Partitions | Groups in partitions? | Other
--- | --- | --- | ---
test1 | 1 | N | 2x compute node, sequential names (default test)
test1b | 1 | N | 1x compute node
test1c | 1 | N | 2x compute nodes, nonsequential names
test2 | 2 | N | 4x compute node, sequential names
test3 | 1 | Y | -

# Local Installation & Running

Local installation on a Centos7 machine looks like:

sudo yum install -y gcc python3-pip python3-devel openssl-devel python3-libselinux
sudo yum install -y docker-ce docker-ce-cli containerd.io
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io
pip3 install -r molecule/requirements.txt --user

sudo systemctl start docker
sudo usermod -aG docker ${USER}
newgrp docker
docker run hello-world # test docker works without sudo

sudo yum install -y git
git clone git@github.com:stackhpc/ansible-role-openhpc.git
cd ansible-role-openhpc/

Then to run all tests:

cd ansible-role-openhpc/
molecule test --all

1 change: 1 addition & 0 deletions molecule/default
4 changes: 4 additions & 0 deletions molecule/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pip
setuptools
molecule[lint]
docker
22 changes: 22 additions & 0 deletions molecule/test1/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*******
Docker driver installation guide
*******

Requirements
============

* Docker Engine

Install
=======

Please refer to the `Virtual environment`_ documentation for installation best
practices. If not using a virtual environment, please consider passing the
widely recommended `'--user' flag`_ when invoking ``pip``.

.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site

.. code-block:: bash

$ python3 -m pip install 'molecule[docker]'
22 changes: 22 additions & 0 deletions molecule/test1/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
- name: Converge
hosts: all
tasks:
- name: Install OpenHPC repository
yum:
name: "https://github.com/openhpc/ohpc/releases/download/v1.3.GA/ohpc-release-1.3-1.el7.x86_64.rpm"
state: present
- name: "Include ansible-role-openhpc"
include_role:
name: "ansible-role-openhpc/"
vars:
openhpc_enable:
control: "{{ inventory_hostname in groups['testohpc_login'] }}"
batch: "{{ inventory_hostname in groups['testohpc_compute'] }}"
runtime: true
openhpc_slurm_service_enabled: true
openhpc_slurm_control_host: "{{ groups['testohpc_login'] | first }}"
openhpc_slurm_partitions:
- name: "compute"
openhpc_cluster_name: testohpc

48 changes: 48 additions & 0 deletions molecule/test1/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: single partition, group is partition
driver:
name: docker
platforms:
- name: testohpc-login-0
image: docker.io/pycontribs/centos:7
pre_build_image: true
groups:
- testohpc_login
command: /sbin/init
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
networks:
- name: net1
- name: testohpc-compute-0
image: docker.io/pycontribs/centos:7
pre_build_image: true
groups:
- testohpc_compute
command: /sbin/init
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
networks:
- name: net1
- name: testohpc-compute-1
image: docker.io/pycontribs/centos:7
pre_build_image: true
groups:
- testohpc_compute
command: /sbin/init
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
networks:
- name: net1
provisioner:
name: ansible
verifier:
name: ansible
12 changes: 12 additions & 0 deletions molecule/test1/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

- name: Check slurm hostlist
hosts: testohpc_login
tasks:
- name: Get slurm partition info
command: sinfo -h
register: sinfo
- name:
assert: # PARTITION AVAIL TIMELIMIT NODES STATE NODELIST
that: "sinfo.stdout_lines == ['compute* up 60-00:00:0 2 idle testohpc-compute-[0-1]']"
fail_msg: "FAILED - actual value: {{ sinfo.stdout_lines }}"
22 changes: 22 additions & 0 deletions molecule/test1b/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*******
Docker driver installation guide
*******

Requirements
============

* Docker Engine

Install
=======

Please refer to the `Virtual environment`_ documentation for installation best
practices. If not using a virtual environment, please consider passing the
widely recommended `'--user' flag`_ when invoking ``pip``.

.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site

.. code-block:: bash

$ python3 -m pip install 'molecule[docker]'
22 changes: 22 additions & 0 deletions molecule/test1b/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
- name: Converge
hosts: all
tasks:
- name: Install OpenHPC repository
yum:
name: "https://github.com/openhpc/ohpc/releases/download/v1.3.GA/ohpc-release-1.3-1.el7.x86_64.rpm"
state: present
- name: "Include ansible-role-openhpc"
include_role:
name: "ansible-role-openhpc/"
vars:
openhpc_enable:
control: "{{ inventory_hostname in groups['testohpc_login'] }}"
batch: "{{ inventory_hostname in groups['testohpc_compute'] }}"
runtime: true
openhpc_slurm_service_enabled: true
openhpc_slurm_control_host: "{{ groups['testohpc_login'] | first }}"
openhpc_slurm_partitions:
- name: "compute"
openhpc_cluster_name: testohpc

37 changes: 37 additions & 0 deletions molecule/test1b/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: single partition, group is partition, single node
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: testohpc-login-0
image: docker.io/pycontribs/centos:7
pre_build_image: true
groups:
- testohpc_login
command: /sbin/init
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
networks:
- name: net1
- name: testohpc-compute-0
image: docker.io/pycontribs/centos:7
pre_build_image: true
groups:
- testohpc_compute
command: /sbin/init
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
networks:
- name: net1
provisioner:
name: ansible
verifier:
name: ansible
12 changes: 12 additions & 0 deletions molecule/test1b/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

- name: Check slurm hostlist
hosts: testohpc_login
tasks:
- name: Get slurm partition info
command: sinfo -h
register: sinfo
- name:
assert: # PARTITION AVAIL TIMELIMIT NODES STATE NODELIST
that: "sinfo.stdout_lines == ['compute* up 60-00:00:0 1 idle testohpc-compute-0']"
fail_msg: "FAILED - actual value: {{ sinfo.stdout_lines }}"
22 changes: 22 additions & 0 deletions molecule/test1c/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*******
Docker driver installation guide
*******

Requirements
============

* Docker Engine

Install
=======

Please refer to the `Virtual environment`_ documentation for installation best
practices. If not using a virtual environment, please consider passing the
widely recommended `'--user' flag`_ when invoking ``pip``.

.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site

.. code-block:: bash

$ python3 -m pip install 'molecule[docker]'
Loading