Skip to content

Commit 81c8ca2

Browse files
sjpbbertiethorpe
andcommitted
Support ansible-init for remote collections (#411)
* Add ansible-init role to requirements.yml * Add ansible-init to groups and plays * Configure cluster_infra ansible-init metadata * Only run site.yml once ansible-init has completed * Wait for ansible init to finish before running bootstrap * revert to using cluster_infra metadata defaults * update image * revert sausage bastion changes * set ansible_init_wait as common var * use run_number as a shorter ID for CI * install ood apps in fatimage * add ood jupyter install to fatimage * bump image * jupyter_compute ood into fatimage * bump fatimage for jupyter_compute ood * Update stackhpc.yml * duplicate tuned inventory group name * Fix invalid group name for slurmci * Update stackhpc.yml undo groupname changes * slurmci group name warning * rm ood changes * bump fatimage * change azimuth collection in bootstrap * update azimuth image utils version * update requirements * Update bastion.yml * Use azimuth image utils collection for ansible-init * bump fatimage --------- Co-authored-by: bertie <[email protected]> Co-authored-by: bertiethorpe <[email protected]>
1 parent 83d2c79 commit 81c8ca2

File tree

9 files changed

+92
-3
lines changed

9 files changed

+92
-3
lines changed

ansible/bootstrap.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
---
22

3+
- hosts: cluster
4+
gather_facts: false
5+
become: yes
6+
tasks:
7+
- name: Check if ansible-init is installed
8+
stat:
9+
path: /etc/systemd/system/ansible-init.service
10+
register: _stat_ansible_init_unitfile
11+
12+
- name: Wait for ansible-init to finish
13+
wait_for:
14+
path: /var/lib/ansible-init.done
15+
timeout: "{{ ansible_init_wait }}" # seconds
16+
when: _stat_ansible_init_unitfile.stat.exists
17+
318
- hosts: localhost
419
gather_facts: false
520
become: false
@@ -235,3 +250,11 @@
235250
tasks:
236251
- include_role:
237252
name: ofed
253+
254+
- hosts: ansible_init
255+
gather_facts: yes
256+
become: yes
257+
tags: linux_ansible_init
258+
tasks:
259+
- include_role:
260+
name: azimuth_cloud.image_utils.linux_ansible_init

ansible/fatimage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@
6868
tasks_from: install-package.yml
6969
vars_from: "Rocky/{{ ansible_distribution_major_version }}.yml"
7070
# # FUTURE: install-apps.yml - this is git clones
71+
7172
- name: Open Ondemand server (apps)
7273
include_role:
7374
name: osc.ood
7475
tasks_from: install-apps.yml
7576
vars_from: "Rocky/{{ ansible_distribution_major_version }}.yml"
77+
7678
- name: Open Ondemand remote desktop
7779
import_role:
7880
name: openondemand
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ansible_init_collections: []
2+
ansible_init_playbooks: []

ansible/roles/cluster_infra/templates/resources.tf.j2

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,23 @@ resource "openstack_compute_instance_v2" "login" {
370370
- "${openstack_compute_keypair_v2.cluster_keypair.public_key}"
371371
{%- endif %}
372372
EOF
373+
374+
metadata = {
375+
{% for playbook in ansible_init_playbooks %}
376+
ansible_init_pb_{{ loop.index0 }}_name = "{{ playbook.name }}"
377+
{% if playbook.stage is defined %}
378+
ansible_init_pb_{{ loop.index0 }}_stage = "{{ playbook.stage }}"
379+
{% endif %}
380+
{% endfor %}
381+
{% for collection in ansible_init_collections %}
382+
ansible_init_coll_{{ loop.index0 }}_name = "{{ collection.name }}"
383+
ansible_init_coll_{{ loop.index0 }}_type = "{{ collection.type }}"
384+
ansible_init_coll_{{ loop.index0 }}_version = "{{ collection.version }}"
385+
{% if collection.source is defined %}
386+
ansible_init_coll_{{ loop.index0 }}_source = "{{ collection.source }}"
387+
{% endif %}
388+
{% endfor %}
389+
}
373390
}
374391

375392
resource "openstack_compute_instance_v2" "control" {
@@ -446,6 +463,23 @@ resource "openstack_compute_instance_v2" "control" {
446463
- [LABEL=home, /exports/home, auto]
447464
{% endif %}
448465
EOF
466+
467+
metadata = {
468+
{% for playbook in ansible_init_playbooks %}
469+
ansible_init_pb_{{ loop.index0 }}_name = "{{ playbook.name }}"
470+
{% if playbook.stage is defined %}
471+
ansible_init_pb_{{ loop.index0 }}_stage = "{{ playbook.stage }}"
472+
{% endif %}
473+
{% endfor %}
474+
{% for collection in ansible_init_collections %}
475+
ansible_init_coll_{{ loop.index0 }}_name = "{{ collection.name }}"
476+
ansible_init_coll_{{ loop.index0 }}_type = "{{ collection.type }}"
477+
ansible_init_coll_{{ loop.index0 }}_version = "{{ collection.version }}"
478+
{% if collection.source is defined %}
479+
ansible_init_coll_{{ loop.index0 }}_source = "{{ collection.source }}"
480+
{% endif %}
481+
{% endfor %}
482+
}
449483
}
450484

451485
{% for partition in openhpc_slurm_partitions %}
@@ -498,6 +532,23 @@ resource "openstack_compute_instance_v2" "{{ partition.name }}" {
498532
- "${openstack_compute_keypair_v2.cluster_keypair.public_key}"
499533
{%- endif %}
500534
EOF
535+
536+
metadata = {
537+
{% for playbook in ansible_init_playbooks %}
538+
ansible_init_pb_{{ loop.index0 }}_name = "{{ playbook.name }}"
539+
{% if playbook.stage is defined %}
540+
ansible_init_pb_{{ loop.index0 }}_stage = "{{ playbook.stage }}"
541+
{% endif %}
542+
{% endfor %}
543+
{% for collection in ansible_init_collections %}
544+
ansible_init_coll_{{ loop.index0 }}_name = "{{ collection.name }}"
545+
ansible_init_coll_{{ loop.index0 }}_type = "{{ collection.type }}"
546+
ansible_init_coll_{{ loop.index0 }}_version = "{{ collection.version }}"
547+
{% if collection.source is defined %}
548+
ansible_init_coll_{{ loop.index0 }}_source = "{{ collection.source }}"
549+
{% endif %}
550+
{% endfor %}
551+
}
501552
}
502553

503554
{% endfor %}

environments/.stackhpc/terraform/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ variable "cluster_image" {
2929
description = "single image for all cluster nodes, keyed by os_version - a convenience for CI"
3030
type = map(string)
3131
default = {
32-
# https://github.com/stackhpc/ansible-slurm-appliance/pull/414
33-
RL8: "openhpc-RL8-240723-0907-b560bf4c"
34-
RL9: "openhpc-ofed-RL9-240723-0907-b560bf4c"
32+
# https://github.com/stackhpc/ansible-slurm-appliance/pull/411
33+
RL8: "openhpc-RL8-240725-1710-325c7b47"
34+
RL9: "openhpc-ofed-RL9-240725-1710-325c7b47"
3535
}
3636
}
3737

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ansible_init_wait: 1200 # seconds

environments/common/inventory/groups

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,6 @@ freeipa_client
132132

133133
[tuned]
134134
# Hosts to run TuneD configuration
135+
136+
[ansible_init]
137+
# Hosts to run linux-anisble-init

environments/common/layouts/everything

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@ openhpc
7878

7979
[tuned:children]
8080
# Hosts to run TuneD configuration
81+
82+
[ansible_init:children]
83+
# Hosts to run ansible-init
84+
cluster

requirements.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ collections:
4646
- name: https://github.com/stackhpc/ansible-collection-terraform
4747
type: git
4848
version: 0.2.0
49+
- name: https://github.com/azimuth-cloud/ansible-collection-image-utils
50+
type: git
51+
version: main # update on release
4952
...

0 commit comments

Comments
 (0)