Skip to content

Commit ae1c4d9

Browse files
authored
Merge pull request #316 from stackhpc/feat/dev-qol
Development quality-of-life improvements
2 parents 439076e + 42b77eb commit ae1c4d9

File tree

7 files changed

+58
-8
lines changed

7 files changed

+58
-8
lines changed

.github/workflows/fatimage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
. environments/.stackhpc/activate
4848
cd packer/
4949
packer init .
50-
PACKER_LOG=1 packer build -only openstack.openhpc -on-error=ask -var-file=$PKR_VAR_environment_root/${{ vars.CI_CLOUD }}.pkrvars.hcl openstack.pkr.hcl
50+
PACKER_LOG=1 packer build -only openstack.openhpc -on-error=${{ vars.PACKER_ON_ERROR }} -var-file=$PKR_VAR_environment_root/${{ vars.CI_CLOUD }}.pkrvars.hcl openstack.pkr.hcl
5151
5252
- name: Get created image name from manifest
5353
id: manifest

ansible/ci/retrieve_inventory.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
gather_facts: no
88
vars:
99
cluster_prefix: "{{ undef(hint='cluster_prefix must be defined') }}" # e.g. ci4005969475
10-
cluster_network: WCDC-iLab-60
10+
ci_vars_file: "{{ appliances_environment_root + '/terraform/' + lookup('env', 'CI_CLOUD') }}.tfvars"
11+
cluster_network: "{{ lookup('ansible.builtin.ini', 'cluster_net', file=ci_vars_file, type='properties') | trim('\"') }}"
1112
tasks:
1213
- name: Get control host IP
1314
set_fact:

ansible/roles/mysql/tasks/configure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
community.mysql.mysql_info:
2222
login_user: root
2323
login_password: "{{ mysql_root_password }}"
24-
# no_log: true # TODO: FIXME
24+
no_log: "{{ no_log | default(true) }}"
2525
register: _mysql_info
2626
until: "'version' in _mysql_info"
2727
retries: 90

dev/delete-cluster.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Delete infrastructure for a cluster without using Terraform. Useful for CI clusters.
5+
6+
Usage:
7+
delete-cluster.py PREFIX
8+
9+
Where PREFIX is the string at the start of the resource's names.
10+
It will list matching resources and prompt to confirm deletion.
11+
"""
12+
13+
import sys, json, subprocess, pprint
14+
15+
16+
CLUSTER_RESOURCES = ['server', 'port', 'volume']
17+
18+
def delete_cluster(cluster_prefix):
19+
to_delete = {}
20+
for resource_type in CLUSTER_RESOURCES:
21+
to_delete[resource_type] = []
22+
resource_list = subprocess.run(f'openstack {resource_type} list --format json', stdout=subprocess.PIPE, shell=True)
23+
resources = json.loads(resource_list.stdout)
24+
for item in resources:
25+
try:
26+
if item['Name'] is not None and item['Name'].startswith(cluster_prefix):
27+
print(resource_type, item['Name'], item['ID'])
28+
to_delete[resource_type].append(item)
29+
except:
30+
print(resource_type, item)
31+
raise
32+
if input('Delete these (y/n)?:') == 'y':
33+
for resource_type in CLUSTER_RESOURCES:
34+
items = [v['ID'] for v in to_delete[resource_type]]
35+
if items:
36+
# delete all resources of each type in a single call for speed:
37+
subprocess.run(f"openstack {resource_type} delete {' '.join(items)}", stdout=subprocess.PIPE, shell=True)
38+
print(f'Deleted {len(items)} {resource_type}s')
39+
else:
40+
print('Cancelled - no resources deleted')
41+
42+
if __name__ == '__main__':
43+
if len(sys.argv) != 2:
44+
print('ERROR: Incorrect argument(s).\n' + __doc__)
45+
exit(1)
46+
delete_cluster(sys.argv[1])

dev/setup-env.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/bin/bash
22

3-
/usr/bin/python3.8 -m venv venv # use `sudo yum install python38` on Rocky Linux 8 to install this
3+
if [[ ! -d "venv" ]]; then
4+
/usr/bin/python3.8 -m venv venv # use `sudo yum install python38` on Rocky Linux 8 to install this
5+
fi
46
. venv/bin/activate
57
pip install -U pip
68
pip install -r requirements.txt
79
ansible --version
8-
# Install ansible dependencies ...
9-
ansible-galaxy role install -r requirements.yml -p ansible/roles
10-
ansible-galaxy collection install -r requirements.yml -p ansible/collections
10+
# Install or update ansible dependencies ...
11+
ansible-galaxy role install -fr requirements.yml -p ansible/roles
12+
ansible-galaxy collection install -fr requirements.yml -p ansible/collections

environments/.stackhpc/ansible.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
any_errors_fatal = True
33
stdout_callback = debug
44
stderr_callback = debug
5+
callbacks_enabled = ansible.posix.profile_tasks
56
gathering = smart
67
forks = 30
78
host_key_checking = False

environments/.stackhpc/hooks/pre.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
mode: 0400
1111
owner: root
1212
group: root
13-
no_log: true
13+
no_log: "{{ no_log | default(true) }}"
1414
loop:
1515
- "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}/inventory/hosts"
1616
- "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}/inventory/group_vars/all/secrets.yml"

0 commit comments

Comments
 (0)