Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge "Use ansible_facts instead"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Feb 23, 2021
2 parents f0a0816 + 8d1fc85 commit 72b6067
Show file tree
Hide file tree
Showing 24 changed files with 52 additions and 51 deletions.
6 changes: 3 additions & 3 deletions common/deploy-steps-tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,19 @@
# Bootstrap tasks - run any tasks that have been defined
########################################################

- name: "Clean container_puppet_tasks for {{ansible_hostname | lower}} step {{step}}"
- name: "Clean container_puppet_tasks for {{ansible_facts['hostname'] | lower}} step {{step}}"
become: true
file:
path: /var/lib/container-puppet/container-puppet-tasks{{step}}.json
state: absent
tags:
- container_config_tasks

- name: Calculate container_puppet_tasks for {{ansible_hostname | lower}} step {{step}}
- name: Calculate container_puppet_tasks for {{ansible_facts['hostname'] | lower}} step {{step}}
set_fact:
"{{'host_container_puppet_tasks_' ~ step}}": "{{lookup('vars', 'host_container_puppet_tasks_' ~ step, default=[]) | union([item])}}"
loop: "{{container_puppet_tasks.get('step_' ~ step, [])}}"
when: (groups[item.service_name] | default ([]) | map('extract', hostvars, 'inventory_hostname') | sort | first | lower) == ansible_hostname | lower
when: (groups[item.service_name] | default ([]) | map('extract', hostvars, 'inventory_hostname') | sort | first | lower) == ansible_facts['hostname'] | lower
vars:
container_puppet_tasks: "{{ lookup('file', tripleo_role_name + '/container_puppet_tasks.yaml', errors='ignore') | default({}, True) | from_yaml }}"
tags:
Expand Down
8 changes: 4 additions & 4 deletions common/deploy-steps.j2
Original file line number Diff line number Diff line change
Expand Up @@ -1123,9 +1123,9 @@ outputs:
loop_control:
loop_var: step
tags: always
# we use ansible_hostname to determine if the host is alive
# we use ansible_facts['hostname'] to determine if the host is alive
# or not.
when: ansible_hostname is defined
when: ansible_facts['hostname'] is defined
# We don't want to run the scale tasks on dead nodes, to allow
# the operator to scale down the cloud no matter the state of
# the servers.
Expand All @@ -1136,9 +1136,9 @@ outputs:
msg: "Node is unreachable. No scale tasks will be run."
ignore_errors: True
tags: always
# we use ansible_hostname to determine if the host is alive
# we use ansible_facts['hostname'] to determine if the host is alive
# or not.
when: ansible_hostname is not defined
when: ansible_facts['hostname'] is not defined
tags:
- scale
post_update_steps_tasks: |
Expand Down
2 changes: 1 addition & 1 deletion common/generate-config-tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
net_host: true
no_archive: false
puppet_config: "/var/lib/container-puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}container-puppet.json"
short_hostname: "{{ ansible_hostname | lower }}"
short_hostname: "{{ ansible_facts['hostname'] | lower }}"
step: "{{ step }}"

- name: "Manage Puppet containers (generate config) for step {{ step }} with tripleo-ansible"
Expand Down
4 changes: 2 additions & 2 deletions common/host-container-puppet-tasks.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- name: Write container-puppet-tasks json file for {{ansible_hostname | lower}} step {{step}}
- name: Write container-puppet-tasks json file for {{ansible_facts['hostname'] | lower}} step {{step}}
no_log: True
copy:
content: "{{lookup ('vars', 'host_container_puppet_tasks_' ~ step, default=[]) | to_nice_json}}"
Expand All @@ -21,7 +21,7 @@
net_host: true
no_archive: true
puppet_config: "/var/lib/container-puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}container-puppet-tasks{{ step }}.json"
short_hostname: "{{ ansible_hostname | lower }}"
short_hostname: "{{ ansible_facts['hostname'] | lower }}"
step: "{{ step }}"

- name: "Manage Puppet containers (bootstrap tasks) for step {{ step }} with tripleo-ansible"
Expand Down
2 changes: 1 addition & 1 deletion deployment/cinder/cinder-backup-pacemaker-puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ outputs:
cinder_backup_pcs_res: "{{cinder_backup_pcs_res_result.rc == 0}}"
- name: set is_cinder_backup_bootstrap_node fact
tags: common
set_fact: is_cinder_backup_bootstrap_node={{cinder_backup_short_bootstrap_node_name|lower == ansible_hostname|lower}}
set_fact: is_cinder_backup_bootstrap_node={{cinder_backup_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower}}
- name: Update cinder_backup pcs resource bundle for new container image
when:
- step|int == 1
Expand Down
2 changes: 1 addition & 1 deletion deployment/cinder/cinder-volume-pacemaker-puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ outputs:
cinder_volume_pcs_res: "{{cinder_volume_pcs_res_result.rc == 0}}"
- name: set is_cinder_volume_bootstrap_node fact
tags: common
set_fact: is_cinder_volume_bootstrap_node={{cinder_volume_short_bootstrap_node_name|lower == ansible_hostname|lower}}
set_fact: is_cinder_volume_bootstrap_node={{cinder_volume_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower}}
- name: Update cinder_volume pcs resource bundle for new container image
when:
- step|int == 1
Expand Down
2 changes: 1 addition & 1 deletion deployment/database/mysql-pacemaker-puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ outputs:
galera_pcs_res: "{{galera_pcs_res_result.rc == 0}}"
- name: set is_mysql_bootstrap_node fact
tags: common
set_fact: is_mysql_bootstrap_node={{mysql_short_bootstrap_node_name|lower == ansible_hostname|lower}}
set_fact: is_mysql_bootstrap_node={{mysql_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower}}
- name: Update galera pcs resource bundle for new container image
when:
- step|int == 1
Expand Down
2 changes: 1 addition & 1 deletion deployment/database/redis-pacemaker-puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ outputs:
- name: Set upgrade redis facts
set_fact:
redis_pcs_res: "{{redis_pcs_res_result.rc == 0}}"
is_redis_bootstrap_node: "{{redis_short_bootstrap_node_name|lower == ansible_hostname|lower}}"
is_redis_bootstrap_node: "{{redis_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower}}"
- name: Update redis-bundle pcs resource bundle for new container image
when:
- step|int == 1
Expand Down
6 changes: 3 additions & 3 deletions deployment/deprecated/novajoin/novajoin-container-puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ outputs:
# openssl-perl is installed which provides /etc/pki/CA on RHEL8
- name: Ensure openssl-perl package is present on RHEL8
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == '8'
- ansible_facts['os_family'] == 'RedHat'
- ansible_facts['distribution_major_version'] is version('8', '==')
package:
name: openssl-perl
state: present
Expand All @@ -262,6 +262,6 @@ outputs:
creates: /etc/ipa/default.conf
when: ipa_otp != ''
- name: Request kerberos keytab
shell: "/usr/bin/kinit -kt /etc/krb5.keytab && ipa-getkeytab -s $(grep xmlrpc_uri /etc/ipa/default.conf | cut -d/ -f3) -p nova/{{ ansible_nodename }} -k /etc/novajoin/krb5.keytab"
shell: "/usr/bin/kinit -kt /etc/krb5.keytab && ipa-getkeytab -s $(grep xmlrpc_uri /etc/ipa/default.conf | cut -d/ -f3) -p nova/{{ ansible_facts['nodename'] }} -k /etc/novajoin/krb5.keytab"
args:
creates: /etc/novajoin/krb5.keytab
4 changes: 2 additions & 2 deletions deployment/haproxy/haproxy-pacemaker-puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ outputs:
block: &haproxy_update_upgrade_facts
- name: set is_haproxy_bootstrap_node fact
tags: common
set_fact: is_haproxy_bootstrap_node={{haproxy_short_bootstrap_node_name|lower == ansible_hostname|lower}}
set_fact: is_haproxy_bootstrap_node={{haproxy_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower}}
when:
- haproxy_short_bootstrap_node_name|default(false)
- name: Mount TLS cert if needed
Expand Down Expand Up @@ -458,7 +458,7 @@ outputs:
- name: Set upgrade haproxy facts
set_fact:
haproxy_pcs_res: "{{haproxy_pcs_res_result.rc == 0}}"
is_haproxy_bootstrap_node: "{{haproxy_short_bootstrap_node_name|lower == ansible_hostname|lower}}"
is_haproxy_bootstrap_node: "{{haproxy_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower}}"

- name: Update haproxy pcs resource bundle for new container image
when:
Expand Down
2 changes: 1 addition & 1 deletion deployment/haproxy/haproxy-public-tls-inject.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ outputs:
path: "{{cert_path}}"

- name: set is_haproxy_bootstrap_node fact
set_fact: is_haproxy_bootstrap_node={{haproxy_short_bootstrap_node_name | lower == ansible_hostname | lower}}
set_fact: is_haproxy_bootstrap_node={{haproxy_short_bootstrap_node_name | lower == ansible_facts['hostname'] | lower}}
when:
- haproxy_short_bootstrap_node_name|default(false)

Expand Down
4 changes: 2 additions & 2 deletions deployment/ipa/ipaservices-baremetal-ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ outputs:
if:
- idm_server_provided
- IPA_HOST: {get_param: IdMServer}
IPA_USER: "nova/{{ ansible_fqdn }}"
IPA_USER: "nova/{{ ansible_facts['fqdn'] }}"
KRB5_CLIENT_KTNAME: {get_param: IdMNovaKeytab}
- IPA_USER: "nova/{{ ansible_fqdn }}"
- IPA_USER: "nova/{{ ansible_facts['fqdn'] }}"
KRB5_CLIENT_KTNAME: {get_param: IdMNovaKeytab}
deploy_steps_tasks:
- name: enroll the node as an ipa client
Expand Down
2 changes: 1 addition & 1 deletion deployment/manila/manila-share-pacemaker-puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ outputs:
manila_share_pcs_res: "{{manila_share_pcs_res_result.rc == 0}}"
- name: set is_manila_share_bootstrap_node fact
tags: common
set_fact: is_manila_share_bootstrap_node={{manila_share_short_bootstrap_node_name|lower == ansible_hostname|lower}}
set_fact: is_manila_share_bootstrap_node={{manila_share_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower}}
- name: Update openstack-manila-share pcs resource bundle for new container image
when:
- step|int == 1
Expand Down
16 changes: 8 additions & 8 deletions deployment/nova/nova-compute-container-puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ outputs:
register: iha_nodes
- name: If instance HA is enabled on the node activate the evacuation completed check
file: path=/var/lib/nova/instanceha/enabled state=touch
when: iha_nodes.stdout|lower is search('"'+ansible_hostname|lower+'"')
when: iha_nodes.stdout|lower is search('"'+ansible_facts['hostname']|lower+'"')
- name: Do we prepend nova startup with a delay
set_fact:
nova_compute_delay: {get_param: NovaComputeStartupDelay}
Expand Down Expand Up @@ -1571,21 +1571,21 @@ outputs:
name: qemu-kvm-common-ev
state: present
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version == '7'
- ansible_facts['distribution'] == 'CentOS'
- ansible_facts['distribution_major_version'] is version('7', '==')
- name: make sure package providing ksmtuned is installed (RHEL7)
package:
name: qemu-kvm-common-rhev
state: present
when:
- ansible_distribution == 'RedHat'
- ansible_distribution_major_version == '7'
- ansible_facts['distribution'] == 'RedHat'
- ansible_facts['distribution_major_version'] is version('7', '==')
- name: make sure package providing ksmtuned is installed (RHEL8 or CentOS8)
package:
name: qemu-kvm-common
state: present
when:
- ansible_distribution_major_version == '8'
- ansible_facts['distribution_major_version'] is version('8', '==')
- name: enable ksmtunded
service:
name: "{{ item }}"
Expand Down Expand Up @@ -1641,13 +1641,13 @@ outputs:
is_additional_cell: {get_param: NovaAdditionalCell}
- name: Set fact for nova_compute services
set_fact:
nova_compute_service: "{{ nova_compute_service_result.stdout | from_yaml | selectattr('Host', 'match', ansible_fqdn ~ '.*') | list }}"
nova_compute_service: "{{ nova_compute_service_result.stdout | from_yaml | selectattr('Host', 'match', ansible_facts['fqdn'] ~ '.*') | list }}"
delegate_to: localhost
check_mode: no
- name: Check search output
fail:
msg: >-
Found multiple `{{ ansible_fqdn }}`, which is unexpected.
Found multiple `{{ ansible_facts['fqdn'] }}`, which is unexpected.
This means that the FQDN of the selected device to disable is
either wrong or is sharing a name with another host, which is
also wrong. Please correct this issue before continuing. Nova
Expand Down
4 changes: 2 additions & 2 deletions deployment/octavia/octavia-deployment-config.j2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ outputs:
{%- if 'octavia_' ~ octavia_groups %}
{% for host in groups['octavia_' ~ octavia_group] -%}
{{ hostvars.raw_get(host)['ansible_hostname'] | lower}}:
{{ hostvars.raw_get(host)['ansible_facts']['hostname'] | lower}}:
ansible_user: {{ hostvars.raw_get(host)['ansible_ssh_user'] | default('heat-admin') }}
ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) | lower }}
canonical_hostname: {{ hostvars.raw_get(host)['canonical_hostname'] | default(host) | lower }}
Expand All @@ -314,7 +314,7 @@ outputs:
Undercloud:
hosts:
{% for host in groups['Undercloud'] -%}
{{ hostvars.raw_get(host)['ansible_hostname'] | lower}}:
{{ hostvars.raw_get(host)['ansible_facts']['hostname'] | lower}}:
ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) | lower }}
ansible_become: false
ansible_connection: local
Expand Down
4 changes: 2 additions & 2 deletions deployment/octavia/octavia-worker-container-puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ outputs:
- python2-openstackclient
- openssl
state: present
when: ansible_distribution_major_version is version(8, '<')
when: ansible_facts['distribution_major_version'] is version(8, '<')

- name: Ensure packages required for configuring octavia are present for CentOS/RHEL 8
package:
Expand All @@ -156,7 +156,7 @@ outputs:
- python3-openstackclient
- openssl
state: present
when: ansible_distribution_major_version is version(8, '>=')
when: ansible__facts['distribution_major_version'] is version(8, '>=')
when: {get_param: EnablePackageInstall}
- name: enable virt_sandbox_use_netlink for healthcheck
seboolean:
Expand Down
6 changes: 3 additions & 3 deletions deployment/ovn/ovn-dbs-pacemaker-puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ outputs:
- name: Update ovn-dbs-bundle resource to use pcmklatest tag image if not used
when:
- step|int == 5
- ovn_dbs_short_bootstrap_node_name|lower == ansible_hostname|lower
- ovn_dbs_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower
block:
- name: Get the present image used by ovn-dbs-bundle
shell: "pcs resource config ovn-dbs-bundle | grep -Eo 'image=[^ ]+' | awk -F= '{print $2;}'"
Expand Down Expand Up @@ -442,7 +442,7 @@ outputs:
- name: Update ovn_dbs pcs resource bundle for new container image
when:
- step|int == 1
- ovn_dbs_short_bootstrap_node_name|lower == ansible_hostname|lower
- ovn_dbs_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower
- ovn_dbs_pcs_res|bool
- ovn_dbs_image_current != ovn_dbs_image_latest
block:
Expand Down Expand Up @@ -524,7 +524,7 @@ outputs:
- name: Restart ovn-dbs service (pacemaker)
when:
- step|int == 1
- ovn_dbs_short_bootstrap_node_name|lower == ansible_hostname|lower
- ovn_dbs_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower
pacemaker_resource:
resource: ovn-dbs-bundle
state: restart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ outputs:
set_fact:
rabbitmq_pcs_res: "{{rabbitmq_pcs_res_result.rc == 0}}"
- name: set is_notify_rabbitmq_bootstrap_node fact
set_fact: is_notify_rabbitmq_bootstrap_node={{oslo_messaging_notify_short_bootstrap_node_name|lower == ansible_hostname|lower}}
set_fact: is_notify_rabbitmq_bootstrap_node={{oslo_messaging_notify_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower}}
- name: Update rabbitmq-bundle pcs resource bundle for new container image
when:
- step|int == 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ outputs:
rabbitmq_pcs_res: "{{rabbitmq_pcs_res_result.rc == 0}}"
- name: set is_rabbitmq_bootstrap_node fact
tags: common
set_fact: is_rabbitmq_bootstrap_node={{rabbitmq_short_bootstrap_node_name|lower == ansible_hostname|lower}}
set_fact: is_rabbitmq_bootstrap_node={{rabbitmq_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower}}
- name: Update rabbitmq-bundle pcs resource bundle for new container image
when:
- step|int == 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ outputs:
set_fact:
rabbitmq_pcs_res: "{{rabbitmq_pcs_res_result.rc == 0}}"
- name: set is_rpc_rabbitmq_bootstrap_node fact
set_fact: is_rpc_rabbitmq_bootstrap_node={{oslo_messaging_rpc_short_bootstrap_node_name|lower == ansible_hostname|lower}}
set_fact: is_rpc_rabbitmq_bootstrap_node={{oslo_messaging_rpc_short_bootstrap_node_name|lower == ansible_facts['hostname']|lower}}
- name: Update rabbitmq-bundle pcs resource bundle for new container image
when:
- step|int == 1
Expand Down
3 changes: 2 additions & 1 deletion deployment/swift/swift-storage-container-puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,12 @@ outputs:
- '!all'
- '!min'
- 'hardware'
filter: 'ansible_device_links'
when: swift_raw_disks|length > 0
- name: Mount devices defined in SwiftRawDisks
mount:
name: /srv/node/{{ item }}
src: "{% if lsblk.results['uuids'][item] is defined %}UUID={{ ansible_device_links['uuids'][item][0] }}{% else %}{{ swift_raw_disks[item]['base_dir']|default('/dev') }}/{{ item }}{% endif %}"
src: "{% if lsblk.results['uuids'][item] is defined %}UUID={{ ansible_facts['device_links']['uuids'][item][0] }}{% else %}{{ swift_raw_disks[item]['base_dir']|default('/dev') }}/{{ item }}{% endif %}"
fstype: xfs
opts: noatime
state: mounted
Expand Down
6 changes: 3 additions & 3 deletions deployment/tls/undercloud-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ outputs:
# openssl-perl is installed which provides /etc/pki/CA on RHEL8
- name: Ensure openssl-perl package is present on RHEL8
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == '8'
- ansible_facts['os_family'] == 'RedHat'
- ansible_facts['distribution_major_version'] is version('8', '==')
package:
name: openssl-perl
state: present
Expand All @@ -68,7 +68,7 @@ outputs:
when: ipa_otp != ''
- name: Set keytab permission facts
set_fact:
nova_service: "nova/{{ ansible_nodename }}"
nova_service: "nova/{{ ansible_facts['nodename'] }}"
nova_keytab: "/etc/novajoin/krb5.keytab"
nova_keytab_group: "tripleo-admin"
- name: Add directory for keytab
Expand Down
Loading

0 comments on commit 72b6067

Please sign in to comment.