Handle host with unset ansible_host
We are having all machines in DNS and want to be able to change IP addresses in DNS. So we do not use ansible_host in our host_vars/machine.yml As os_keystone is the first Ansible role we use. We will make similar changes to other roles later on. Change-Id: Ic9f43cc3f6b62b5098e85afcf55f008c022517f6
This commit is contained in:
parent
6e84e3a4c7
commit
54a4e496b9
@ -21,7 +21,7 @@
|
||||
-avz
|
||||
--delete
|
||||
{{ keystone_credential_key_repository }}/
|
||||
{{ keystone_system_user_name }}@{{ hostvars[item]['ansible_host'] }}:{{ keystone_credential_key_repository }}/
|
||||
{{ keystone_system_user_name }}@{{ hostvars[item]['ansible_host'] | default(item) }}:{{ keystone_credential_key_repository }}/
|
||||
become: yes
|
||||
become_user: "{{ keystone_system_user_name }}"
|
||||
changed_when: false
|
||||
|
@ -21,7 +21,7 @@
|
||||
-avz
|
||||
--delete
|
||||
{{ keystone_fernet_tokens_key_repository }}/
|
||||
{{ keystone_system_user_name }}@{{ hostvars[item]['ansible_host'] }}:{{ keystone_fernet_tokens_key_repository }}/
|
||||
{{ keystone_system_user_name }}@{{ hostvars[item]['ansible_host'] | default(item) }}:{{ keystone_fernet_tokens_key_repository }}/
|
||||
become: yes
|
||||
become_user: "{{ keystone_system_user_name }}"
|
||||
changed_when: false
|
||||
|
@ -40,13 +40,17 @@ function autorotate {
|
||||
{% for host in groups['keystone_all'] %}
|
||||
|
||||
{% if inventory_hostname != host %}
|
||||
|
||||
{% if 'ansible_host' in hostvars[host] %}
|
||||
{% set destination_host = hostvars[host]['ansible_host'] %}
|
||||
{% else %}
|
||||
{% set destination_host = inventory_hostname %}
|
||||
{% endif %}
|
||||
# Fernet sync job to "{{ host }}"
|
||||
rsync -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
|
||||
-avz \
|
||||
--delete \
|
||||
{{ keystone_credential_key_repository }}/ \
|
||||
{{ keystone_system_user_name }}@{{ hostvars[host]['ansible_host'] }}:{{ keystone_credential_key_repository }}/
|
||||
{{ keystone_system_user_name }}@{{ destination_host }}:{{ keystone_credential_key_repository }}/
|
||||
|
||||
{%- endif %}
|
||||
|
||||
|
@ -29,18 +29,23 @@ function autorotate {
|
||||
{% for host in groups['keystone_all'] %}
|
||||
|
||||
{% if inventory_hostname != host %}
|
||||
{% if 'ansible_host' in hostvars[host] %}
|
||||
{% set destination_host = hostvars[host]['ansible_host'] %}
|
||||
{% else %}
|
||||
{% set destination_host = inventory_hostname %}
|
||||
{% endif %}
|
||||
|
||||
# Fernet sync job to "{{ host }}"
|
||||
scp -o UserKnownHostsFile=/dev/null \
|
||||
-o StrictHostKeyChecking=no \
|
||||
$(ls -dtr {{ keystone_fernet_tokens_key_repository }}/* | sort -Vr) \
|
||||
{{ keystone_system_user_name }}@{{ hostvars[host]['ansible_host'] }}:{{ keystone_fernet_tokens_key_repository }}/
|
||||
{{ keystone_system_user_name }}@{{ destination_host }}:{{ keystone_fernet_tokens_key_repository }}/
|
||||
|
||||
rsync -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
|
||||
-avz \
|
||||
--delete \
|
||||
{{ keystone_fernet_tokens_key_repository }}/ \
|
||||
{{ keystone_system_user_name }}@{{ hostvars[host]['ansible_host'] }}:{{ keystone_fernet_tokens_key_repository }}/
|
||||
{{ keystone_system_user_name }}@{{ destination_host }}:{{ keystone_fernet_tokens_key_repository }}/
|
||||
|
||||
{%- endif %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user