Skip to content

Commit 4a3074b

Browse files
committed
prototype script - hostvars no-op
1 parent f66feb9 commit 4a3074b

File tree

2 files changed

+46
-13
lines changed

2 files changed

+46
-13
lines changed

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

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
become: yes
66
# VARS TO BE SUPPLIED VIA CLOUD INIT METADATA
77
vars:
8-
control_node_ip: "172.16.1.228"
8+
server_node_ip: "172.16.1.154"
99
resolv_conf_nameservers: [1.1.1.1, 8.8.8.8]
1010

11-
nfs_export: "/exports/home"
12-
nfs_client_mnt_options:
13-
nfs_client_mnt_point: "/home"
14-
nfs_client_mnt_state: mounted
15-
nfs_server: "{{ control_node_ip }}"
11+
nfs_configurations:
12+
- nfs_export: "/exports/home"
13+
nfs_client_mnt_options:
14+
nfs_client_mnt_point: "/home"
15+
nfs_client_mnt_state: mounted
16+
nfs_server: "{{ server_node_ip }}"
1617

1718
os_manila_mount_state: mounted
1819
os_manila_mount_opts:
@@ -36,7 +37,7 @@
3637
uid: 1005
3738
basic_users_groups: []
3839

39-
openhpc_conf_server: "{{ control_node_ip }}"
40+
openhpc_conf_server: "{{ server_node_ip }}"
4041

4142
tasks:
4243
- name: Configure resolve.conf
@@ -77,7 +78,7 @@
7778
- name: Mount /mnt/cluster
7879
mount:
7980
path: /mnt/cluster
80-
src: "{{ vars.control_node_ip }}:/exports/cluster"
81+
src: "{{ vars.server_node_ip }}:/exports/cluster"
8182
fstype: nfs
8283
opts: rw,sync
8384
state: mounted
@@ -90,20 +91,35 @@
9091
group: root
9192
mode: 0644
9293

94+
# - name: Include hostvars from NFS share
95+
# block:
96+
# - name: Extract short hostname using a shell block
97+
# shell: |
98+
# HOSTNAME=$(hostname)
99+
# echo "${HOSTNAME%.test.invalid}"
100+
# register: short_hostname
101+
102+
# - name: Include vars from NFS mount
103+
# include_vars:
104+
# file: "/mnt/cluster/{{ short_hostname.stdout }}/hostvars.yml"
105+
93106

94107
- name: NFS client mount
95108
block:
96109
- name: ensure mount directory exists
97110
file:
98-
path: "{{ nfs_client_mnt_point }}"
111+
path: "{{ item.get('nfs_client_mnt_point', nfs_client_mnt_point) }}"
99112
state: directory
113+
loop: "{{ nfs_configurations }}"
100114

101115
- name: mount the filesystem
102116
mount:
103-
path: "{{ nfs_client_mnt_point }}"
104-
src: "{{ nfs_server }}:{{ nfs_export }}"
117+
path: "{{ item.get('nfs_client_mnt_point', nfs_client_mnt_point) }}"
118+
src: "{{ item.get('nfs_server', nfs_server) }}:{{ item.get('nfs_export', nfs_export) }}"
119+
opts: "{{ item['nfs_client_mnt_options'] | default(nfs_client_mnt_options, true) | default(omit, true) }}" # for some reason items.get() here fails with "an incorrect mount option was specified"
105120
fstype: nfs
106-
state: "{{ nfs_client_mnt_state }}"
121+
state: "{{ item.get('nfs_client_mnt_state', nfs_client_mnt_state) }}"
122+
loop: "{{ nfs_configurations }}"
107123

108124

109125
- name: Manila mount

ansible/roles/compute_init/tasks/main.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22

33
- name: Ensure directories exist
4-
file:
4+
file:
55
path: "/etc/ansible-init/{{ item }}"
66
state: directory
77
owner: root
@@ -122,6 +122,23 @@
122122
owner: munge
123123
group: munge
124124
mode: 0400
125+
126+
# - name: Ensure /exports/cluster/inventory_hostname directory exists
127+
# file:
128+
# path: /exports/cluster/{{ inventory_hostname }}
129+
# state: directory
130+
# owner: root
131+
# group: root
132+
# mode: 0755
133+
134+
# - name: Template hostvars
135+
# template:
136+
# src: ../templates/hostvars.j2
137+
# dest: "/exports/cluster/{{ inventory_hostname }}/hostvars.yml"
138+
# owner: root
139+
# group: root
140+
# mode: 0644
141+
125142
delegate_to: "{{ groups['control'] | first }}"
126143

127144
- name: Inject compute initialisation playbook

0 commit comments

Comments
 (0)