Skip to content

Commit 3a583a9

Browse files
committed
load hostvars
1 parent c9ebd48 commit 3a583a9

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

ansible/roles/compute_init/files/compute-init.yml

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,10 @@
88
server_node_ip: "{{ os_metadata.meta.k3s_server }}"
99
compute_groups: "{{ os_metadata.meta.compute_groups | default([]) }}"
1010

11-
# TODO: "role defaults"
11+
# TODO: "= role defaults" - could be moved to a vars_file: on play with similar precedence effects
12+
# this is a good example: common environment actually defines this (non-functional w/o compute groups), but role default is empty
1213
resolv_conf_nameservers: []
13-
14-
# nfs_configurations:
15-
# - nfs_export: "/exports/home"
16-
# nfs_client_mnt_options:
17-
# nfs_client_mnt_point: "/home"
18-
# nfs_client_mnt_state: mounted
19-
# nfs_server: "{{ server_node_ip }}"
20-
21-
# os_manila_mount_state: mounted
22-
# os_manila_mount_opts:
23-
# - x-systemd.device-timeout=30
24-
# - x-systemd.mount-timeout=30
25-
# - noatime
26-
# - _netdev # prevents mount blocking early boot before networking available
27-
# - rw
28-
# os_manila_mount_ceph_conf_path: /etc/ceph
29-
30-
# basic_users_manage_homedir: false
31-
# basic_users_userdefaults:
32-
# state: present
33-
# create_home: "{{ basic_users_manage_homedir }}"
34-
# generate_ssh_key: "{{ basic_users_manage_homedir }}"
35-
# ssh_key_comment: "{{ item.name }}"
36-
# test_user_password: "zXpcWyGQL7jtZnqylQra4g=="
37-
# basic_users_users:
38-
# - name: testuser # can't use rocky as $HOME isn't shared!
39-
# password: "{{ test_user_password | password_hash('sha512', 65534 | random(seed=inventory_hostname) | string) }}" # idempotent
40-
# uid: 1005
41-
# basic_users_groups: []
42-
43-
# openhpc_conf_server: "{{ server_node_ip }}"
44-
14+
4515
tasks:
4616
- block:
4717
- name: Report skipping initialization if not compute node
@@ -80,3 +50,12 @@
8050

8151
- meta: end_play
8252
when: _mount_mnt_cluster.failed
53+
54+
- name: Load hostvars from NFS
55+
# this is higher priority than vars block = normal ansible's hostvars
56+
include_vars:
57+
file: "/mnt/cluster/hostvars/{{ ansible_hostname }}/hostvars.yml" # can't use inventory_hostname
58+
59+
- name: Demonstrate hostvars have loaded
60+
debug:
61+
var: prometheus_version

docs/experimental/compute-init.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ On deploy host:
77

88
On compute node:
99

10-
[root@rl9-compute-0 rocky]# rm /var/lib/ansible-init.done
11-
[root@rl9-compute-0 rocky]# systemctl restart ansible-init
10+
[root@rl9-compute-0 rocky]# rm -f /var/lib/ansible-init.done && systemctl restart ansible-init
1211
[root@rl9-compute-0 rocky]# systemctl status ansible-init
1312

1413

@@ -97,4 +96,26 @@ Now run site.yml, then restart ansible-init again:
9796
[root@rl9-compute-0 rocky]# ls /mnt/cluster/hostvars/rl9-compute-
9897
rl9-compute-0/ rl9-compute-1/
9998
[root@rl9-compute-0 rocky]# ls /mnt/cluster/hostvars/rl9-compute-0/
100-
hostvars.yml
99+
hostvars.yml
100+
101+
This commit - shows that hostvars have loaded:
102+
103+
[root@rl9-compute-0 rocky]# systemctl status ansible-init
104+
● ansible-init.service
105+
Loaded: loaded (/etc/systemd/system/ansible-init.service; enabled; preset: disabled)
106+
Active: active (exited) since Fri 2024-12-13 21:06:20 UTC; 5s ago
107+
Process: 27585 ExecStart=/usr/bin/ansible-init (code=exited, status=0/SUCCESS)
108+
Main PID: 27585 (code=exited, status=0/SUCCESS)
109+
CPU: 8.161s
110+
111+
Dec 13 21:06:20 rl9-compute-0.rl9.invalid ansible-init[27769]: TASK [Demonstrate hostvars have loaded] ****************************************
112+
Dec 13 21:06:20 rl9-compute-0.rl9.invalid ansible-init[27769]: ok: [127.0.0.1] => {
113+
Dec 13 21:06:20 rl9-compute-0.rl9.invalid ansible-init[27769]: "prometheus_version": "2.27.0"
114+
Dec 13 21:06:20 rl9-compute-0.rl9.invalid ansible-init[27769]: }
115+
Dec 13 21:06:20 rl9-compute-0.rl9.invalid ansible-init[27769]: PLAY RECAP *********************************************************************
116+
Dec 13 21:06:20 rl9-compute-0.rl9.invalid ansible-init[27769]: 127.0.0.1 : ok=5 changed=0 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0
117+
Dec 13 21:06:20 rl9-compute-0.rl9.invalid ansible-init[27585]: [INFO] executing remote playbooks for stage - post
118+
Dec 13 21:06:20 rl9-compute-0.rl9.invalid ansible-init[27585]: [INFO] writing sentinel file /var/lib/ansible-init.done
119+
Dec 13 21:06:20 rl9-compute-0.rl9.invalid ansible-init[27585]: [INFO] ansible-init completed successfully
120+
Dec 13 21:06:20 rl9-compute-0.rl9.invalid systemd[1]: Finished ansible-init.service.
121+

0 commit comments

Comments
 (0)