Skip to content

Commit 7551559

Browse files
committed
Merge branch 'main' into refactor/ci
2 parents b74321a + d3e99b0 commit 7551559

File tree

26 files changed

+266
-62
lines changed

26 files changed

+266
-62
lines changed

.github/workflows/stackhpc.yml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,44 +54,57 @@ jobs:
5454
env:
5555
arcus_CLOUDS_YAML: ${{ secrets.ARCUS_CLOUDS_YAML }}
5656

57-
- name: Provision infrastructure
58-
id: provision
57+
- name: Provision ports, inventory and other infrastructure apart from nodes
58+
run: |
59+
. venv/bin/activate
60+
. environments/${{ matrix.cloud }}/activate
61+
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
62+
TF_VAR_create_nodes=false terraform apply -auto-approve
63+
64+
- name: Setup environment-specific inventory/terraform inputs
65+
run: |
66+
. venv/bin/activate
67+
. environments/${{ matrix.cloud }}/activate
68+
ansible-playbook ansible/adhoc/generate-passwords.yml
69+
echo vault_testuser_password: "$TESTUSER_PASSWORD" > $APPLIANCES_ENVIRONMENT_ROOT/inventory/group_vars/all/test_user.yml
70+
ansible-playbook ansible/adhoc/template-cloud-init.yml
71+
env:
72+
TESTUSER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
73+
74+
- name: Provision servers
75+
id: provision_servers
5976
run: |
6077
. venv/bin/activate
6178
. environments/${{ matrix.cloud }}/activate
6279
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
6380
terraform apply -auto-approve
64-
81+
6582
- name: Get server provisioning failure messages
6683
id: provision_failure
6784
run: |
6885
. venv/bin/activate
6986
. environments/${{ matrix.cloud }}/activate
7087
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
7188
TF_FAIL_MSGS="$(../../skeleton/\{\{cookiecutter.environment\}\}/terraform/getfaults.py $PWD)"
72-
echo $TF_FAIL_MSGS
89+
echo TF failure messages: $TF_FAIL_MSGS
7390
echo "::set-output name=messages::${TF_FAIL_MSGS}"
74-
if: always() && steps.provision.outcome == 'failure'
91+
if: always() && steps.provision_servers.outcome == 'failure'
7592

7693
- name: Delete infrastructure if failed due to lack of hosts
7794
run: |
7895
. venv/bin/activate
7996
. environments/${{ matrix.cloud }}/activate
8097
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
8198
terraform destroy -auto-approve
82-
if: ${{ always() && steps.provision.outcome == 'failure' && contains('not enough hosts available', steps.provision_failure.messages) }}
99+
if: ${{ always() && steps.provision_servers.outcome == 'failure' && contains(steps.provision_failure.messages, 'not enough hosts available') }}
83100

84101
- name: Directly configure cluster
85102
run: |
86103
. venv/bin/activate
87104
. environments/${{ matrix.cloud }}/activate
88105
ansible all -m wait_for_connection
89-
ansible-playbook ansible/adhoc/generate-passwords.yml
90-
echo vault_testuser_password: "$TEST_USER_PASSWORD" > $APPLIANCES_ENVIRONMENT_ROOT/inventory/group_vars/basic_users/defaults.yml
91106
ansible-playbook -v ansible/site.yml
92107
ansible-playbook -v ansible/ci/check_slurm.yml
93-
env:
94-
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
95108
96109
- name: Run MPI-based tests
97110
run: |
@@ -124,23 +137,20 @@ jobs:
124137
--server-response \
125138
--no-check-certificate \
126139
--http-user=testuser \
127-
--http-password=${TEST_USER_PASSWORD} https://${openondemand_servername} \
140+
--http-password=${TESTUSER_PASSWORD} https://${openondemand_servername} \
128141
2>&1)
129142
(echo $statuscode | grep "200 OK") || (echo $statuscode && exit 1)
130143
env:
131-
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
144+
TESTUSER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
132145

133146
- name: Build packer images
134147
id: packer_build
135148
run: |
136149
. venv/bin/activate
137150
. environments/${{ matrix.cloud }}/activate
138-
echo vault_testuser_password: "$TEST_USER_PASSWORD" > $APPLIANCES_ENVIRONMENT_ROOT/inventory/group_vars/basic_users/defaults.yml
139151
cd packer/
140152
PACKER_LOG=1 packer build -on-error=ask -var-file=$PKR_VAR_environment_root/builder.pkrvars.hcl openstack.pkr.hcl
141153
../dev/output_manifest.py packer-manifest.json # Sets NEW_{COMPUTE,CONTROL,LOGIN}_IMAGE_ID outputs
142-
env:
143-
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
144154
145155
- name: Test reimage of login nodes (via rebuild adhoc)
146156
run: |

ansible/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ roles/*
2626
!roles/slurm_exporter/**
2727
!roles/firewalld/
2828
!roles/firewalld/**
29+
!roles/etc_hosts/
30+
!roles/etc_hosts/**
31+
!roles/cloud_init/
32+
!roles/cloud_init/**
2933
!roles/mysql/
3034
!roles/mysql/**
3135
!roles/systemd/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- hosts: cloud_init
2+
become: no
3+
gather_facts: no
4+
tasks:
5+
- name: Template out cloud-init userdata
6+
import_role:
7+
name: cloud_init
8+
tasks_from: template.yml
9+
delegate_to: localhost

ansible/bootstrap.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
to update these variable names. ** NB: The actual secrets will not be changed.**
1414
when: "'secrets_openhpc_' in (hostvars[inventory_hostname] | join)"
1515

16+
- hosts: etc_hosts
17+
gather_facts: false
18+
tags: etc_hosts
19+
become: yes
20+
tasks:
21+
- name: Template /etc/hosts
22+
copy:
23+
content: "{{ etc_hosts_template }}"
24+
dest: /etc/hosts
25+
owner: root
26+
group: root
27+
mode: u=rw,og=r
28+
1629
- hosts: cluster
1730
gather_facts: false
1831
tasks:

ansible/roles/cloud_init/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# cloud_init
2+
3+
Create cloud init userdata for instance groups.
4+
5+
# Requirements
6+
Image and cloud environment supporting cloud-init.
7+
8+
# Role Variables
9+
10+
- `cloud_init_output_path`: Required. Path to output userdata files to.
11+
- `cloud_init_userdata_templates`: Optional list. Each element is a dict with keys/values as follows:
12+
- `module`: Required str. Name of cloud_init [module](https://cloudinit.readthedocs.io/en/latest/topics/modules.html)
13+
- `group`: Optional str. Name of inventory group to which this config applies - if no group is specified then it applies to all groups. This allows defining `cloud_init_userdata_templates` for group `all`.
14+
- `template`: Jinja template for cloud_init module [configuration](https://cloudinit.readthedocs.io/en/latest/topics/modules.html).
15+
16+
Elements may repeat `module`; the resulting userdata cloud-config file will will contain configuration from all applicable (by group) elements for that module.
17+
18+
Note that the appliance [constructs](../../../environments/common/inventory/group_vars/all/cloud_init.yml) `cloud_init_userdata_templates` from `cloud_init_userdata_templates_default` and `cloud_init_userdata_templates_extra` to
19+
allow easier customisation in specific environments.
20+
21+
# Dependencies
22+
None.
23+
24+
# Example Playbook
25+
See `ansible/adhoc/rebuild.yml`.
26+
27+
# License
28+
Apache 2.0
29+
30+
# Author Information
31+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#cloud_init_output_path:
2+
cloud_init_userdata_templates: []
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
- name: Template out cloud-init userdata
3+
ansible.builtin.template:
4+
src: userdata.yml.j2
5+
dest: "{{ cloud_init_output_path }}/{{ inventory_hostname }}.userdata.yml"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#cloud-config
2+
disable_ec2_metadata: true
3+
4+
{% for module, tmpls in cloud_init_userdata_templates | groupby(attribute='module') %}
5+
{% for tmpl in tmpls %}
6+
{% if not 'group' in tmpl or tmpl.group in group_names %}
7+
{% if loop.first %}
8+
{{ module }}:
9+
{% endif %}
10+
{{ tmpl.template }}
11+
{% endif %}
12+
{% endfor %}
13+
{% endfor %}

ansible/roles/etc_hosts/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# etc_hosts
2+
3+
This role provides documentation only.
4+
5+
Hosts in the `etc_hosts` groups get `/etc/hosts` created via `cloud-init`. The generated file defines all hosts in this group using `ansible_host` as the IP address and `inventory_hostname` as the canonical hostname. This may need overriding for multi-homed hosts. See `environments/common/inventory/group_vars/all/cloud_init.yml` for configuration.

environments/arcus/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
partitions.yml
22
secrets.yml
33
hosts
4+
terraform.tfvars
5+
.terraform.lock.hcl
6+
logs/
7+
hpctests/
8+
inventory/group_vars/all/test_user.yml

0 commit comments

Comments
 (0)