Ensure management_address is used instead of ansible_host

ansible_host in deployments is designed to represent SSH address.
In cases, when address that used for SSH is different from management
network, this might lead to undpredictable results on bare metal hosts.

Thus we're ensuring that management (container) address is used
for services to listen on and to interact through.

Related-Bug: #2002645
Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/870113
Change-Id: I8a5e817d024eef5453fa072d8fee5aeca9bed67b
This commit is contained in:
Dmitriy Rabotyagov 2023-01-23 16:07:48 +01:00
parent 83979e7575
commit 6a0646470a
6 changed files with 17 additions and 17 deletions

View File

@ -21,7 +21,7 @@ rabbitmq_use_ssl: True
rabbitmq_servers: >- rabbitmq_servers: >-
{{ {{
groups[rabbitmq_host_group] groups[rabbitmq_host_group]
| map('extract', hostvars, 'ansible_host') | map('extract', hostvars, 'management_address')
| list | join(',') | list | join(',')
}} }}
rabbitmq_policies: rabbitmq_policies:
@ -42,7 +42,7 @@ galera_use_ssl: "{{ not (ansible_facts['os_family'] | lower == 'redhat' and ins
memcached_port: 11211 memcached_port: 11211
memcached_servers: >- memcached_servers: >-
{{ {{
(groups['memcached'] | map('extract', hostvars, 'ansible_host') | list) (groups['memcached'] | map('extract', hostvars, 'management_address') | list)
| map('regex_replace', '(.+)' ,'\1:' ~ memcached_port) | map('regex_replace', '(.+)' ,'\1:' ~ memcached_port)
| list | list
| join(',') | join(',')
@ -56,6 +56,6 @@ qdrouterd_use_ssl: False
qdrouterd_servers: >- qdrouterd_servers: >-
{{ {{
groups[qdrouterd_host_group] groups[qdrouterd_host_group]
| map('extract', hostvars, 'ansible_host') | map('extract', hostvars, 'management_address')
| list | join(',') | list | join(',')
}} }}

View File

@ -33,7 +33,7 @@ galera_disable_privatedevices: "{{ not is_metal }}"
galera_monitoring_allowed_source: >- galera_monitoring_allowed_source: >-
{{ {{
groups['galera_all'] | union(groups['haproxy']) groups['galera_all'] | union(groups['haproxy'])
| map('extract', hostvars, 'ansible_host') | map('extract', hostvars, 'management_address')
| list | list
| join(' ') ~ ' 127.0.0.1' | join(' ') ~ ' 127.0.0.1'
}} }}
@ -43,7 +43,7 @@ galera_monitoring_allowed_source: >-
galera_server_proxy_protocol_networks: >- galera_server_proxy_protocol_networks: >-
{{ {{
groups['haproxy'] groups['haproxy']
| map('extract', hostvars, 'ansible_host') | map('extract', hostvars, 'management_address')
| list | list
| join(',') ~ ', localhost, ::1' | join(',') ~ ', localhost, ::1'
}} }}

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
memcached_listen: "{{ ansible_host }}" memcached_listen: "{{ management_address }}"
# Ensure that the package state matches the global setting # Ensure that the package state matches the global setting
memcached_package_state: "{{ package_state }}" memcached_package_state: "{{ package_state }}"

View File

@ -28,7 +28,7 @@
{% set _prio = 50 %} {% set _prio = 50 %}
{% endif %} {% endif %}
{% set _ = _var.append({ {% set _ = _var.append({
'host': hostvars[host]['ansible_host'], 'host': hostvars[host]['management_address'],
'priority': _prio 'priority': _prio
}) })
%} %}

View File

@ -167,7 +167,7 @@
block: block:
- name: Wait for cluster ready state - name: Wait for cluster ready state
command: | command: |
mysql -h {{ ansible_host }} \ mysql -h {{ management_address }} \
-u "{{ galera_root_user | default('root') }}" \ -u "{{ galera_root_user | default('root') }}" \
-p"{{ galera_root_password }}" \ -p"{{ galera_root_password }}" \
-e "show status like 'wsrep_incoming_addresses';" \ -e "show status like 'wsrep_incoming_addresses';" \
@ -185,7 +185,7 @@
state: restarted state: restarted
- name: Wait for cluster ready state - name: Wait for cluster ready state
command: | command: |
mysql -h {{ ansible_host }} \ mysql -h {{ management_address }} \
-u "{{ galera_root_user | default('root') }}" \ -u "{{ galera_root_user | default('root') }}" \
-p"{{ galera_root_password }}" \ -p"{{ galera_root_password }}" \
-e "show status like 'wsrep_incoming_addresses';" \ -e "show status like 'wsrep_incoming_addresses';" \
@ -199,7 +199,7 @@
- name: Check cluster local state - name: Check cluster local state
command: | command: |
mysql -h {{ ansible_host }} \ mysql -h {{ management_address }} \
-u "{{ galera_root_user | default('root') }}" \ -u "{{ galera_root_user | default('root') }}" \
-p"{{ galera_root_password }}" \ -p"{{ galera_root_password }}" \
-e "show status like 'wsrep_local_state_comment';" \ -e "show status like 'wsrep_local_state_comment';" \
@ -212,7 +212,7 @@
- name: Check cluster evs state - name: Check cluster evs state
command: | command: |
mysql -h {{ ansible_host }} \ mysql -h {{ management_address }} \
-u "{{ galera_root_user | default('root') }}" \ -u "{{ galera_root_user | default('root') }}" \
-p"{{ galera_root_password }}" \ -p"{{ galera_root_password }}" \
-e "show status like 'wsrep_evs_state';" \ -e "show status like 'wsrep_evs_state';" \
@ -233,7 +233,7 @@
community.mysql.mysql_db: community.mysql.mysql_db:
login_user: "{{ galera_root_user | default('root') }}" login_user: "{{ galera_root_user | default('root') }}"
login_password: "{{ galera_root_password }}" login_password: "{{ galera_root_password }}"
login_host: "{{ ansible_host }}" login_host: "{{ management_address }}"
name: "OSA-test" name: "OSA-test"
state: "present" state: "present"
when: inventory_hostname == groups['galera_all'][0] when: inventory_hostname == groups['galera_all'][0]
@ -244,7 +244,7 @@
community.mysql.mysql_user: community.mysql.mysql_user:
login_user: "{{ galera_root_user | default('root') }}" login_user: "{{ galera_root_user | default('root') }}"
login_password: "{{ galera_root_password }}" # noqa no-log-password login_password: "{{ galera_root_password }}" # noqa no-log-password
login_host: "{{ ansible_host }}" login_host: "{{ management_address }}"
name: "osa-tester" name: "osa-tester"
password: "tester-secrete" # noqa no-log-password password: "tester-secrete" # noqa no-log-password
host: "{{ item }}" host: "{{ item }}"
@ -269,7 +269,7 @@
community.mysql.mysql_user: community.mysql.mysql_user:
login_user: "{{ galera_root_user | default('root') }}" login_user: "{{ galera_root_user | default('root') }}"
login_password: "{{ galera_root_password }}" # noqa no-log-password login_password: "{{ galera_root_password }}" # noqa no-log-password
login_host: "{{ ansible_host }}" login_host: "{{ management_address }}"
name: "osa-tester" name: "osa-tester"
state: "absent" state: "absent"
host: "{{ item }}" host: "{{ item }}"
@ -282,7 +282,7 @@
community.mysql.mysql_db: community.mysql.mysql_db:
login_user: "{{ galera_root_user | default('root') }}" login_user: "{{ galera_root_user | default('root') }}"
login_password: "{{ galera_root_password }}" # noqa no-log-password login_password: "{{ galera_root_password }}" # noqa no-log-password
login_host: "{{ ansible_host }}" login_host: "{{ management_address }}"
name: "OSA-test" name: "OSA-test"
state: "absent" state: "absent"
when: inventory_hostname == groups['galera_all'][0] when: inventory_hostname == groups['galera_all'][0]
@ -368,7 +368,7 @@
tasks: tasks:
- name: Probing TCP connection to zookeeper - name: Probing TCP connection to zookeeper
wait_for: wait_for:
host: "{{ hostvars[item]['ansible_host'] }}" host: "{{ hostvars[item]['management_address'] }}"
port: "{{ coordination_port | default(2181) }}" port: "{{ coordination_port | default(2181) }}"
with_items: "{{ groups[coordination_host_group | default('zookeeper_all')] }}" with_items: "{{ groups[coordination_host_group | default('zookeeper_all')] }}"

View File

@ -53,7 +53,7 @@
- name: Wait for mariadb port 3306 to be available - name: Wait for mariadb port 3306 to be available
wait_for: wait_for:
port: "3306" port: "3306"
host: "{{ ansible_host | default(ansible_ssh_host | default(inventory_hostname)) }}" host: "{{ management_address | default(ansible_ssh_host | default(inventory_hostname)) }}"
retries: 10 retries: 10
delay: 10 delay: 10
delegate_to: "{{ groups['utility_all'][0] }}" delegate_to: "{{ groups['utility_all'][0] }}"