Skip to content

Commit bb0b388

Browse files
authored
Merge pull request #560 from stackhpc/upstream/master-2026-05-11
Synchronise master with upstream
2 parents 7bc4d04 + 1486c00 commit bb0b388

8 files changed

Lines changed: 41 additions & 14 deletions

File tree

ansible/control-host-configure.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- import_playbook: "network.yml"
1616
- import_playbook: "firewall.yml"
1717
- import_playbook: "fail2ban.yml"
18+
- import_playbook: "etc-hosts.yml"
1819
- import_playbook: "tuned.yml"
1920
- import_playbook: "sysctl.yml"
2021
- import_playbook: "time.yml"

ansible/etc-hosts.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Ensure /etc/hosts is configured
3-
hosts: overcloud
3+
hosts: seed-hypervisor:seed:overcloud:infra-vms:ansible-control
44
max_fail_percentage: >-
55
{{ etc_hosts_max_fail_percentage |
66
default(host_configure_max_fail_percentage) |
@@ -9,12 +9,5 @@
99
tags:
1010
- etc-hosts
1111
tasks:
12-
# NOTE(mgoddard): Need to ensure that all hosts have facts available.
13-
- import_role:
14-
name: gather-facts-delegated
15-
tags:
16-
- gather-facts-delegated
17-
when: etc_hosts_gather_facts | default(true)
18-
1912
- import_role:
2013
name: etc-hosts

ansible/infra-vm-host-configure.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- import_playbook: "network.yml"
1616
- import_playbook: "firewall.yml"
1717
- import_playbook: "fail2ban.yml"
18+
- import_playbook: "etc-hosts.yml"
1819
- import_playbook: "tuned.yml"
1920
- import_playbook: "sysctl.yml"
2021
- import_playbook: "disable-glean.yml"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
# Which hosts to add to /etc/hosts
3+
etc_hosts_hosts: "{{ groups['overcloud'] }}"
4+
5+
# Which network to use for the IP address in /etc/hosts
6+
etc_hosts_network: "{{ internal_net_name }}"

ansible/roles/etc-hosts/defaults/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
customize_etc_hosts: true
44

55
# List of hosts to add to /etc/hosts.
6-
etc_hosts_hosts: "{{ groups['overcloud'] }}"
6+
etc_hosts_hosts: []
7+
8+
# Which network to use for host entries in /etc/hosts
9+
etc_hosts_network: "{{ undef() }}"
710

811
# Dictionary of custom /etc/hosts entries.
912
# Each key is added as a hostname,

ansible/roles/etc-hosts/tasks/etc-hosts.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
---
2+
# NOTE(mgoddard): Need to ensure that all hosts have facts available.
3+
- include_role:
4+
name: gather-facts-delegated
5+
tags:
6+
- gather-facts-delegated
7+
vars:
8+
gather_facts_delegated_limit_hosts: "{{ etc_hosts_hosts }}"
9+
when:
10+
- etc_hosts_gather_facts | default(true)
11+
- etc_hosts_hosts | length > 0
12+
213
- name: Ensure localhost in /etc/hosts
314
lineinfile:
415
dest: /etc/hosts
@@ -26,18 +37,28 @@
2637
marker: "# {mark} ANSIBLE GENERATED HOSTS"
2738
block: |
2839
{% for host in etc_hosts_hosts %}
29-
{% if hostvars[host].internal_net_name in hostvars[host].network_interfaces %}
40+
{% if hostvars[host]['etc_hosts_network'] in hostvars[host].network_interfaces %}
3041
{% set hostnames = [hostvars[host].ansible_facts.nodename, hostvars[host].ansible_facts.hostname] %}
31-
{{ hostvars[host].internal_net_name | net_ip(inventory_hostname=host) }} {{ hostnames | unique | join(' ') }}
42+
{{ hostvars[host]['etc_hosts_network'] | net_ip(inventory_hostname=host) }} {{ hostnames | unique | join(' ') }}
3243
{% endif %}
3344
{% endfor %}
45+
become: True
46+
when:
47+
- etc_hosts_hosts | length > 0
48+
- etc_hosts_network | mandatory is truthy
49+
# Skip hosts that do not have a valid internal network interface.
50+
- etc_hosts_network in network_interfaces
51+
52+
- name: Add custom entries to /etc/hosts
53+
blockinfile:
54+
dest: /etc/hosts
55+
marker: "# {mark} ANSIBLE GENERATED CUSTOM HOSTS"
56+
block: |
3457
{% for item in custom_etc_hosts_entries | dict2items %}
3558
{{ item.value }} {{ item.key }}
3659
{% endfor %}
3760
become: True
38-
when:
39-
# Skip hosts that do not have a valid internal network interface.
40-
- internal_net_name in network_interfaces
61+
when: custom_etc_hosts_entries | length > 0
4162

4263
# NOTE(osmanlicilegi): The distribution might come with cloud-init installed, and manage_etc_hosts
4364
# configuration enabled. If so, it will override the file /etc/hosts from cloud-init templates at

ansible/seed-host-configure.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- import_playbook: "network.yml"
1616
- import_playbook: "firewall.yml"
1717
- import_playbook: "fail2ban.yml"
18+
- import_playbook: "etc-hosts.yml"
1819
- import_playbook: "tuned.yml"
1920
- import_playbook: "sysctl.yml"
2021
- import_playbook: "ip-routing.yml"

ansible/seed-hypervisor-host-configure.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- import_playbook: "network.yml"
1616
- import_playbook: "firewall.yml"
1717
- import_playbook: "fail2ban.yml"
18+
- import_playbook: "etc-hosts.yml"
1819
- import_playbook: "tuned.yml"
1920
- import_playbook: "sysctl.yml"
2021
- import_playbook: "ip-routing.yml"

0 commit comments

Comments
 (0)