Skip to content

Commit cebd210

Browse files
committed
Merge branch 'twans_fix' into 'development'
Generic improvements to ensure correct hostnames, selinux state and external_fqdn See merge request clustervision/trinityx-combined!304
2 parents 59ce78e + 8dcc828 commit cebd210

File tree

18 files changed

+122
-43
lines changed

18 files changed

+122
-43
lines changed

site/roles/trinity/bind/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
sefcontext:
2525
target: "{{ bind_db_path }}/dynamic(/.*)?"
2626
setype: named_cache_t
27-
when: enable_selinux|default(True)
27+
when: ansible_selinux.status == "enabled"
2828

2929
- name: Ensure {{ bind_db_path }} exists
3030
file:
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
if [ ! "$(which host)" ]; then
4+
dnf -y install bind-utils 1>&2
5+
fi
6+
7+
if [ ! "$(which host)" ]; then
8+
echo "Cannot find host and cannot install it" 1>&2
9+
exit 1
10+
fi
11+
12+
HOST=$1
13+
DNS=$2
14+
15+
RES=$(host -v $HOST|grep -A1 'ANSWER SECTION'|grep PTR|awk '{ print $5 }'|sed -e 's/\.$//')
16+
17+
if [ ! "$RES" ]; then
18+
RES=$(host $HOST|grep 'domain name pointer'|awk '{ print $5 }'|sed -e 's/\.$//')
19+
fi
20+
21+
if [ ! "$RES" ] && [ "$DNS" ]; then
22+
RES=$(host -v $HOST $DNS|grep -A1 'ANSWER SECTION'|grep PTR|awk '{ print $5 }'|sed -e 's/\.$//')
23+
24+
if [ ! "$RES" ]; then
25+
RES=$(host $HOST $DNS|grep 'domain name pointer'|awk '{ print $5 }'|sed -e 's/\.$//')
26+
fi
27+
fi
28+
29+
if [ "$RES" ]; then
30+
echo $RES
31+
exit
32+
fi
33+
34+
echo "could not resolve $HOST" 1>&2
35+
# yes it should be non-zero exit, but ansible console output will be cluttered
36+
exit
37+

site/roles/trinity/init/tasks/main.yml

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,6 @@
149149

150150
- debug:
151151
msg: "Primary: {{ primary }}, on_controller: {{ on_controller }}, in_cloud: {{ in_cloud }}"
152-
153-
- name: Setting trix_external_fqdn
154-
set_fact:
155-
trix_external_fqdn: '{{ ansible_fqdn }}'
156-
when: (trix_external_fqdn is not defined) or trix_external_fqdn==""
157-
158-
- debug:
159-
msg: "trix_external_fqdn: {{ trix_external_fqdn }}"
160152
tags: always
161153

162154

@@ -335,6 +327,7 @@
335327
tags: always
336328
when: ansible_connection not in 'chroot' and on_controller
337329

330+
338331
- block:
339332
- block:
340333
- name: Trying to figure out external interface
@@ -377,6 +370,53 @@
377370
tags: always
378371
when: ansible_connection not in 'chroot' and on_controller
379372

373+
374+
- block:
375+
- name: Copy resolv.sh script to /tmp
376+
copy:
377+
src: 'resolve.sh'
378+
dest: '/tmp/resolve.sh'
379+
mode: 0755
380+
381+
- name: Resolving trix_external_fqdn
382+
command: "/tmp/resolve.sh {{ trix_ctrl_external_ip }} {{ trix_dns_forwarders | default([]) | first }}"
383+
register: trix_resolved_host_fqdn
384+
ignore_errors: true
385+
when: trix_ctrl_external_ip is defined
386+
387+
- name: Setting trix_external_fqdn
388+
set_fact:
389+
trix_external_fqdn: "{{ trix_resolved_host_fqdn.stdout }}"
390+
when:
391+
- (trix_external_fqdn is not defined) or trix_external_fqdn==""
392+
- trix_resolved_host_fqdn is defined
393+
394+
- block:
395+
- fail:
396+
msg: 'trix_external_fqdn is not configured and it could not be resolved. I can continue but OpenOndemand might not work properly'
397+
ignore_errors: true
398+
399+
- name: Wait 10s before continuing with a default
400+
wait_for:
401+
timeout: 10
402+
403+
- name: Setting trix_external_fqdn
404+
set_fact:
405+
trix_external_fqdn: '{{ ansible_fqdn }}'
406+
ignore_errors: true
407+
when: (trix_external_fqdn is not defined) or trix_external_fqdn==""
408+
tags: always
409+
when:
410+
- ansible_connection not in 'chroot' and on_controller
411+
- (trix_external_fqdn is not defined) or trix_external_fqdn==""
412+
413+
- debug:
414+
msg: "trix_external_fqdn: {{ trix_external_fqdn }}"
415+
when:
416+
- ansible_connection not in 'chroot' and on_controller
417+
- trix_external_fqdn is defined
418+
419+
380420
- block:
381421
- name: Resolve admin group
382422
getent:
@@ -401,26 +441,28 @@
401441
num_ctrl: "{{ all_ctrl_ip | length }}"
402442
tags: always
403443

404-
- name: Fetch selinux state
405-
shell: getenforce || echo 'Disabled'
406-
register: init_selinux_state
407-
ignore_errors: true
444+
- block:
445+
- name: Fetch selinux state
446+
shell: getenforce || echo 'Disabled'
447+
register: init_selinux_state
448+
ignore_errors: true
408449

409-
- name: Verify if selinux matches with preferred state
410-
fail:
411-
msg: "Selinux enabled, but the system needs a reboot first to take effect. Please re-run after reboot"
412-
when:
413-
- enable_selinux|default(True)
414-
- init_selinux_state.stdout is defined
415-
- init_selinux_state.stdout == 'Disabled'
450+
- name: Verify if selinux matches with preferred state
451+
fail:
452+
msg: "Selinux enabled, but the system needs a reboot first to take effect. Please re-run after reboot"
453+
when:
454+
- enable_selinux|default(True)
455+
- init_selinux_state.stdout is defined
456+
- init_selinux_state.stdout == 'Disabled'
416457

417-
- name: Verify if selinux matches with preferred state
418-
fail:
419-
msg: "Selinux disabled, but the system needs a reboot first to take effect. Please re-run after reboot"
420-
when:
421-
- not enable_selinux|default(True)
422-
- init_selinux_state.stdout is defined
423-
- init_selinux_state.stdout == 'Enforcing'
458+
- name: Verify if selinux matches with preferred state
459+
fail:
460+
msg: "Selinux disabled, but the system needs a reboot first to take effect. Please re-run after reboot"
461+
when:
462+
- not enable_selinux|default(True)
463+
- init_selinux_state.stdout is defined
464+
- init_selinux_state.stdout == 'Enforcing'
465+
when: ansible_connection not in 'chroot' and on_controller
424466

425467
- name: Toggle selinux state
426468
selinux:

site/roles/trinity/luna2/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@
397397
sefcontext:
398398
target: "/etc/named.luna.zones"
399399
setype: named_zone_t
400-
when: enable_selinux|default(True)
400+
when: ansible_selinux.status == "enabled"
401401

402402
- name: Check File exists or not
403403
stat:

site/roles/trinity/mariadb/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
setype: mysqld_db_t
2828
seuser: system_u
2929
state: present
30-
when: enable_selinux|default(True)
30+
when: ansible_selinux.status == "enabled"
3131

3232
- name: Ensure {{ mariadb_db_path }} exists
3333
file:

site/roles/trinity/openldap/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
sefcontext:
8888
target: "{{ openldap_server_conf_path }}(/.*)?"
8989
setype: slapd_db_t
90-
when: enable_selinux|default(True)
90+
when: ansible_selinux.status == "enabled"
9191

9292
- name: Hash OpenLDAP root password
9393
command: slappasswd -h {SSHA} -s {{ openldap_root_pwd }}

site/roles/trinity/prometheus-alertmanager/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
become: true
3232
tags:
3333
- prometheus-alertmanager-selinux
34-
when: enable_selinux|default(True)
34+
when: ansible_selinux.status == "enabled"
3535
tags:
3636
- prometheus-alertmanager-selinux
3737

site/roles/trinity/prometheus-ha-exporter/tasks/configure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
state: present
1717
when:
1818
- ansible_version.full is version_compare('2.4', '>=')
19-
- enable_selinux|default(True)
19+
- ansible_selinux.status == "enabled"
2020

2121
- name: Create prometheus_ha_exporter_sd_file if not exists
2222
file:

site/roles/trinity/prometheus-infiniband-exporter/tasks/configure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
state: present
1717
when:
1818
- ansible_version.full is version_compare('2.4', '>=')
19-
- enable_selinux|default(True)
19+
- ansible_selinux.status == "enabled"
2020

2121
- name: Create prometheus_infiniband_exporter_sd_file if not exists
2222
file:

site/roles/trinity/prometheus-ipmi-exporter/tasks/configure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
state: present
1717
when:
1818
- ansible_version.full is version_compare('2.4', '>=')
19-
- enable_selinux|default(True)
19+
- ansible_selinux.status == "enabled"
2020

2121
- name: Create prometheus_ipmi_exporter_sd_file if not exists
2222
file:

0 commit comments

Comments
 (0)