Skip to content

Commit 36de796

Browse files
committed
add resolv_conf role to compute script
1 parent 054cb73 commit 36de796

File tree

6 files changed

+123
-2
lines changed

6 files changed

+123
-2
lines changed

ansible/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,6 @@ roles/*
5858
!roles/squid/**
5959
!roles/tuned/
6060
!roles/tuned/**
61+
!roles/compute_init/
62+
!roles/compute_init/**
6163

ansible/extras.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@
3636
tasks:
3737
- import_role:
3838
name: persist_hostkeys
39+
40+
- name: Inject ansible-init compute script
41+
hosts: compute_init
42+
tags: compute_init
43+
become: yes
44+
tasks:
45+
- import_role:
46+
name: compute_init
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
3+
- name: Compute node initialisation
4+
hosts: localhost
5+
become: yes
6+
vars:
7+
control_node_ip: "172.16.1.228"
8+
nfs_export: "/exports/hosts"
9+
resolv_conf_nameservers: []
10+
11+
tasks:
12+
- name: Configure resolve.conf
13+
block:
14+
- name: Set nameservers in /etc/resolv.conf
15+
ansible.builtin.template:
16+
src: /etc/ansible-init/templates/resolv.conf.j2
17+
dest: /etc/resolv.conf
18+
owner: root
19+
group: root
20+
mode: u=rw,og=r
21+
22+
- name: Disable NetworkManager control of resolv.conf
23+
ansible.builtin.copy:
24+
src: /etc/ansible-init/files/NetworkManager-dns-none.conf
25+
dest: /etc/NetworkManager/conf.d/90-dns-none.conf
26+
owner: root
27+
group: root
28+
mode: u=rw,og=r
29+
register: _copy_nm_config
30+
31+
- name: Reload NetworkManager
32+
ansible.builtin.systemd:
33+
name: NetworkManager
34+
state: reloaded
35+
when: _copy_nm_config.changed | default(false)
36+
37+
- name: Mount /etc/hosts on compute nodes
38+
block:
39+
- name: Ensure the mount directory exists
40+
file:
41+
path: /mnt/hosts
42+
state: directory
43+
mode: 0755
44+
45+
- name: Mount NFS export
46+
mount:
47+
path: /mnt/hosts
48+
src: "{{ vars.control_node_ip }}:{{ nfs_export }}"
49+
fstype: nfs
50+
opts: rw,sync
51+
state: mounted
52+
53+
- name: Copy /exports/hosts contents to /etc/hosts
54+
copy:
55+
src: /mnt/hosts/hosts
56+
dest: /etc/hosts
57+
owner: root
58+
group: root
59+
mode: 0644
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
3+
- name: Ensure templates directory exists
4+
file:
5+
path: /etc/ansible-init/templates
6+
state: directory
7+
owner: root
8+
group: root
9+
mode: 0644
10+
11+
- name: Inject templates
12+
copy:
13+
src: '{{ item }}'
14+
dest: '/etc/ansible-init/templates/{{ item | basename }}'
15+
owner: root
16+
group: root
17+
mode: 0644
18+
loop:
19+
- ../../resolv_conf/templates/resolv.conf.j2
20+
21+
- name: Ensure files directory exists
22+
file:
23+
path: /etc/ansible-init/files
24+
state: directory
25+
owner: root
26+
group: root
27+
mode: 0644
28+
29+
- name: Inject files
30+
copy:
31+
src: '{{ item }}'
32+
dest: '/etc/ansible-init/files/{{ item | basename }}'
33+
owner: root
34+
group: root
35+
mode: 0644
36+
loop:
37+
- ../../resolv_conf/files/NetworkManager-dns-none.conf
38+
39+
- name: Inject compute initialisation playbook
40+
copy:
41+
src: compute-init.yml
42+
dest: /etc/ansible-init/playbooks/compute-init.yml
43+
owner: root
44+
group: root
45+
mode: 0644

environments/common/inventory/groups

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,7 @@ freeipa_client
134134
# Hosts to run TuneD configuration
135135

136136
[ansible_init]
137-
# Hosts to run linux-anisble-init
137+
# Hosts to run linux-anisble-init
138+
139+
[compute_init]
140+
# Hosts to deploy compute initialisation ansible-init script to.

environments/common/layouts/everything

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,8 @@ openhpc
8080

8181
[ansible_init:children]
8282
# Hosts to run ansible-init
83-
cluster
83+
cluster
84+
85+
[compute_init:children]
86+
# Hosts to deploy compute initialisation ansible-init script to.
87+
compute

0 commit comments

Comments
 (0)