Use ansible_facts[] instead of fact variables
See https://github.com/ansible/ansible/issues/73654 Change-Id: I949a17a8e77e96b6933e625914ea337eb94e53c2
This commit is contained in:
parent
00fd774c71
commit
9c585b7257
@ -24,7 +24,7 @@ openstack_distrib_description: "OpenStack-Ansible"
|
||||
openstack_distrib_file: yes
|
||||
openstack_distrib_file_path: "/etc/openstack-release"
|
||||
|
||||
is_container: "{{ ansible_virtualization_type in ['lxc', 'systemd-nspawn'] }}"
|
||||
is_container: "{{ ansible_facts['virtualization_type'] in ['lxc', 'systemd-nspawn'] }}"
|
||||
|
||||
openstack_host_sysstat_enabled: true
|
||||
openstack_host_sysstat_interval: 1
|
||||
@ -72,7 +72,7 @@ openstack_hosts_package_repos_keys: "{{ _package_repos_keys + (user_external_rep
|
||||
# Used for setting the net.ipv4/6.neigh.default.gc_thresh* values. This assumes that facts were
|
||||
# gathered to obtain the total amount of memory available on a given host. If no facts are gathered
|
||||
# the default set will be 1024 unless its defined by the user.
|
||||
gc_val: "{{ ansible_memtotal_mb | default(1024) | bit_length_power_of_2 }}"
|
||||
gc_val: "{{ ansible_facts['memtotal_mb'] | default(1024) | bit_length_power_of_2 }}"
|
||||
# The ste value has a Max allowable value of 8192 unless set by the user.
|
||||
set_gc_val: "{{ gc_val if (gc_val | int <= 8192) else 8192 }}"
|
||||
|
||||
@ -154,8 +154,8 @@ openstack_host_sysstat_cron_mode: '0755'
|
||||
# NOTE(mhayden): Ensure that the full path to the 'centos' directory is used.
|
||||
openstack_hosts_centos_mirror_url: 'http://mirror.centos.org/centos'
|
||||
openstack_hosts_rdo_mirror_url: 'https://trunk.rdoproject.org'
|
||||
openstack_hosts_rdo_repo_url: "{{ openstack_hosts_rdo_mirror_url }}/centos{{ ansible_distribution_major_version }}-master/current-passed-ci/"
|
||||
openstack_hosts_rdo_deps_url: "{{ openstack_hosts_rdo_mirror_url }}/centos{{ ansible_distribution_major_version }}-master/deps/latest/"
|
||||
openstack_hosts_rdo_repo_url: "{{ openstack_hosts_rdo_mirror_url }}/centos{{ ansible_facts['distribution_major_version'] }}-master/current-passed-ci/"
|
||||
openstack_hosts_rdo_deps_url: "{{ openstack_hosts_rdo_mirror_url }}/centos{{ ansible_facts['distribution_major_version'] }}-master/deps/latest/"
|
||||
openstack_hosts_power_tool_enable: "{{ ('manila_all' in groups or 'gnocchi_all' in groups or install_method | default('source') == 'distro') }}"
|
||||
|
||||
# Keep a history of systemd journals on disk after reboots
|
||||
|
@ -38,4 +38,4 @@ galaxy_info:
|
||||
dependencies:
|
||||
- role: apt_package_pinning
|
||||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
||||
- ansible_facts['pkg_mgr'] == 'apt'
|
||||
|
@ -17,10 +17,10 @@
|
||||
fail:
|
||||
msg: >
|
||||
Wrong kernel Version found
|
||||
[ {{ ansible_kernel }} < {{ openstack_host_required_kernel }} ]
|
||||
[ {{ ansible_facts['kernel'] }} < {{ openstack_host_required_kernel }} ]
|
||||
Resolve this issue before continuing.
|
||||
when:
|
||||
- ansible_kernel is version(openstack_host_required_kernel, '<')
|
||||
- ansible_facts['kernel'] is version(openstack_host_required_kernel, '<')
|
||||
|
||||
- name: Install distro packages for bare metal nodes
|
||||
package:
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
- name: check how kernel modules are implemented (statically builtin, dynamic, not set)
|
||||
slurp:
|
||||
src: "/boot/config-{{ ansible_kernel }}"
|
||||
src: "/boot/config-{{ ansible_facts['kernel'] }}"
|
||||
register: modules
|
||||
when:
|
||||
- openstack_host_specific_kernel_modules | length > 0
|
||||
@ -111,5 +111,5 @@
|
||||
name: ebtables
|
||||
path: /usr/sbin/ebtables-legacy
|
||||
when:
|
||||
- ansible_distribution == 'Debian'
|
||||
- ansible_distribution_major_version == '10'
|
||||
- ansible_facts['distribution'] == 'Debian'
|
||||
- ansible_facts['distribution_major_version'] == '10'
|
||||
|
@ -16,11 +16,11 @@
|
||||
- name: Gather variables for each operating system
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
|
||||
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
||||
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
||||
- "{{ ansible_distribution | lower }}.yml"
|
||||
- "{{ ansible_os_family | lower }}.yml"
|
||||
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml"
|
||||
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
|
||||
- "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
|
||||
- "{{ ansible_facts['distribution'] | lower }}.yml"
|
||||
- "{{ ansible_facts['os_family'] | lower }}.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
@ -65,7 +65,7 @@
|
||||
# It is also used for installing common packages to
|
||||
# all nodes
|
||||
- name: Apply package management distro specific configuration
|
||||
include_tasks: "openstack_hosts_configure_{{ ansible_pkg_mgr | lower }}.yml"
|
||||
include_tasks: "openstack_hosts_configure_{{ ansible_facts['pkg_mgr'] | lower }}.yml"
|
||||
|
||||
# Configure bare metal nodes: Kernel, sysctl, sysstat, hosts files, metal packages
|
||||
- import_tasks: configure_metal_hosts.yml
|
||||
@ -107,4 +107,4 @@
|
||||
- import_tasks: openstack_update_environment.yml
|
||||
tags:
|
||||
- openstack_hosts-config
|
||||
when: ansible_distribution == 'CentOS'
|
||||
when: ansible_facts['distribution'] == 'CentOS'
|
||||
|
@ -15,15 +15,15 @@
|
||||
|
||||
- name: Ensure ssh directory
|
||||
file:
|
||||
path: "{{ ansible_env.HOME }}/.ssh"
|
||||
path: "{{ ansible_facts['env']['HOME'] }}/.ssh"
|
||||
state: "directory"
|
||||
group: "{{ ansible_user_id }}"
|
||||
owner: "{{ ansible_user_id }}"
|
||||
group: "{{ ansible_facts['user_id'] }}"
|
||||
owner: "{{ ansible_facts['user_id'] }}"
|
||||
mode: "0700"
|
||||
|
||||
- name: Update SSH keys
|
||||
authorized_key:
|
||||
user: "{{ ansible_user }}"
|
||||
user: "{{ ansible_facts['user'] }}"
|
||||
state: present
|
||||
key: "{{ item }}"
|
||||
with_url: "{{ ssh_key_url }}"
|
||||
|
@ -23,11 +23,11 @@
|
||||
- name: Update CA store - Ubuntu/OpenSUSE
|
||||
command: update-ca-certificates
|
||||
when:
|
||||
- (ansible_pkg_mgr == 'apt') or (ansible_pkg_mgr == 'zypper') or (ansible_pkg_mgr == 'portage')
|
||||
- ansible_facts['pkg_mgr'] == 'apt'
|
||||
- openstack_host_ca_cert_copy is changed
|
||||
|
||||
- name: Update CA store - Centos
|
||||
command: update-ca-trust
|
||||
when:
|
||||
- ansible_pkg_mgr == 'yum'
|
||||
- ansible_facts['pkg_mgr'] == 'yum'
|
||||
- openstack_host_ca_cert_copy is changed
|
||||
|
@ -19,7 +19,7 @@
|
||||
dest: "{{ openstack_host_sysstat_file }}"
|
||||
mode: "0644"
|
||||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
||||
- ansible_facts['pkg_mgr'] == 'apt'
|
||||
notify: Restart sysstat
|
||||
|
||||
- name: Enable sysstat cron
|
||||
@ -27,7 +27,7 @@
|
||||
src: "{{ openstack_host_cron_template }}"
|
||||
dest: "{{ openstack_host_sysstat_cron_file }}"
|
||||
mode: "{{ openstack_host_sysstat_cron_mode }}"
|
||||
setype: "{{ (ansible_selinux.status == 'enabled') | ternary('system_cron_spool_t', omit) }}"
|
||||
setype: "{{ (ansible_facts['selinux']['status'] == 'enabled') | ternary('system_cron_spool_t', omit) }}"
|
||||
|
||||
- name: Start and enable the sysstat service
|
||||
service:
|
||||
@ -35,4 +35,4 @@
|
||||
state: started
|
||||
enabled: yes
|
||||
when:
|
||||
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper']
|
||||
- ansible_facts['pkg_mgr'] in ['yum', 'dnf', 'zypper']
|
||||
|
@ -21,7 +21,7 @@
|
||||
{% for item in groups['all'] %}
|
||||
{% set record = [] %}
|
||||
{% set _target_rfc_name = item|replace('_', '-') %}
|
||||
{% set _ans_hostname = hostvars[item]['ansible_hostname'] | default(_target_rfc_name) %}
|
||||
{% set _ans_hostname = hostvars[item]['ansible_facts']['hostname'] | default(_target_rfc_name) %}
|
||||
{% set _ = record.append(hostvars[item]['ansible_host'] | default('127.0.0.1')) %}
|
||||
{% set _ = record.append(_ans_hostname ~ '.' ~ openstack_domain) %}
|
||||
{% set _ = record.append(_target_rfc_name) %}
|
||||
|
@ -25,7 +25,7 @@
|
||||
- gnutls-utils
|
||||
state: present
|
||||
when:
|
||||
- ansible_distribution == "CentOS"
|
||||
- ansible_facts['distribution'] == "CentOS"
|
||||
|
||||
- name: Install ssl packages (ubuntu)
|
||||
package:
|
||||
@ -33,7 +33,7 @@
|
||||
- gnutls-bin
|
||||
state: present
|
||||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
||||
- ansible_facts['pkg_mgr'] == 'apt'
|
||||
|
||||
- name: Create certificate directories
|
||||
file:
|
||||
|
@ -109,7 +109,7 @@
|
||||
|
||||
- name: Check for ssh dir
|
||||
stat:
|
||||
path: "{{ ansible_env.HOME }}/.ssh"
|
||||
path: "{{ ansible_facts['env']['HOME'] }}/.ssh"
|
||||
register: ssh_dir
|
||||
|
||||
- name: Check for extra host package present on host
|
||||
@ -129,15 +129,17 @@
|
||||
changed_when: false
|
||||
|
||||
- name: Check role functions
|
||||
vars:
|
||||
ans_hostname: "{{ ansible_facts['hostname'] }}"
|
||||
assert:
|
||||
that:
|
||||
- "'dm_multipath' in modules_content"
|
||||
- "'ebtables' in modules_content"
|
||||
- "'vm.swappiness' in sysctl_content"
|
||||
- "'127.0.0.1 {{ ansible_hostname }}.openstack.local localhost {{ ansible_hostname }}' in hosts_content"
|
||||
- "'127.111.111.101 {{ ansible_hostname }}.openstack.local test1 {{ ansible_hostname }}' in hosts_content"
|
||||
- "'127.111.111.102 {{ ansible_hostname }}.openstack.local test2 {{ ansible_hostname }}' in hosts_content"
|
||||
- "'127.111.111.103 {{ ansible_hostname }}.openstack.local test3 {{ ansible_hostname }}' in hosts_content"
|
||||
- "'127.0.0.1 {{ ans_hostname }}.openstack.local localhost {{ ans_hostname }}' in hosts_content"
|
||||
- "'127.111.111.101 {{ ans_hostname }}.openstack.local test1 {{ ans_hostname }}' in hosts_content"
|
||||
- "'127.111.111.102 {{ ans_hostname }}.openstack.local test2 {{ ans_hostname }}' in hosts_content"
|
||||
- "'127.111.111.103 {{ ans_hostname }}.openstack.local test3 {{ ans_hostname }}' in hosts_content"
|
||||
- "'127.111.111.103 test3.additional' not in hosts_content"
|
||||
- "release_file.stat.exists"
|
||||
- "systat_file.stat.exists"
|
||||
|
@ -40,12 +40,12 @@ openstack_host_kernel_modules:
|
||||
- name: nbd
|
||||
- name: nf_conntrack
|
||||
# NOTE(mnaser): 4.19 kernel merged nf_conntrack_ipv{4,6} into nf_conntrack
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv4', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv6', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_facts']['kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv4', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_facts']['kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv6', '') }}"
|
||||
- name: nf_defrag_ipv4
|
||||
- name: nf_nat
|
||||
# NOTE(mnaser): 5.2 kernel merged nf_nat_ipv4 into nf_nat
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_kernel'] is version('5.2.0', '<')) | ternary('nf_nat_ipv4', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_facts']['kernel'] is version('5.2.0', '<')) | ternary('nf_nat_ipv4', '') }}"
|
||||
- name: vhost_net
|
||||
- name: x_tables
|
||||
|
||||
@ -86,10 +86,10 @@ _package_repos_keys:
|
||||
_package_list: []
|
||||
|
||||
_package_repos:
|
||||
- repo: "deb {{ apt_repo_url | default('http://osbpo.debian.net/osbpo/ ' ~ ansible_distribution_release ~ '-victoria-backports main') }}"
|
||||
- repo: "deb {{ apt_repo_url | default('http://osbpo.debian.net/osbpo/ ' ~ ansible_facts['distribution_release'] ~ '-victoria-backports main') }}"
|
||||
state: present
|
||||
filename: "osbpo"
|
||||
- repo: "deb {{ apt_repo_url | default('http://osbpo.debian.net/osbpo/ ' ~ ansible_distribution_release ~ '-victoria-backports-nochange main') }}"
|
||||
- repo: "deb {{ apt_repo_url | default('http://osbpo.debian.net/osbpo/ ' ~ ansible_facts['distribution_release'] ~ '-victoria-backports-nochange main') }}"
|
||||
state: present
|
||||
filename: "osbpo"
|
||||
|
||||
|
@ -40,11 +40,11 @@ openstack_host_kernel_modules:
|
||||
- name: ip_vs
|
||||
- name: iscsi_tcp
|
||||
- name: nf_conntrack
|
||||
- name: "{{ ansible_distribution_version is version('8.3', '<') | ternary('nf_conntrack_ipv4', '') }}"
|
||||
- name: "{{ ansible_distribution_version is version('8.3', '<') | ternary('nf_conntrack_ipv6', '') }}"
|
||||
- name: "{{ ansible_facts['distribution_version'] is version('8.3', '<') | ternary('nf_conntrack_ipv4', '') }}"
|
||||
- name: "{{ ansible_facts['distribution_version'] is version('8.3', '<') | ternary('nf_conntrack_ipv6', '') }}"
|
||||
- name: nf_defrag_ipv4
|
||||
- name: nf_nat
|
||||
- name: "{{ ansible_distribution_version is version('8.3', '<') | ternary('nf_nat_ipv4', '') }}"
|
||||
- name: "{{ ansible_facts['distribution_version'] is version('8.3', '<') | ternary('nf_nat_ipv4', '') }}"
|
||||
- name: vhost_net
|
||||
|
||||
## Base packages
|
||||
|
@ -40,11 +40,11 @@ openstack_host_kernel_modules:
|
||||
- name: nbd
|
||||
- name: nf_conntrack
|
||||
#NOTE: 4.19 kernel merged nf_conntrack_ipv{4,6} into nf_conntrack
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv4', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv6', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_facts']['kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv4', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_facts']['kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv6', '') }}"
|
||||
- name: nf_defrag_ipv4
|
||||
- name: nf_nat
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_kernel'] is version('5.0.0', '<=')) | ternary('nf_nat_ipv4', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_facts']['kernel'] is version('5.0.0', '<=')) | ternary('nf_nat_ipv4', '') }}"
|
||||
- name: vhost_net
|
||||
- name: x_tables
|
||||
|
||||
|
@ -40,11 +40,11 @@ openstack_host_kernel_modules:
|
||||
- name: nbd
|
||||
- name: nf_conntrack
|
||||
#NOTE: 4.19 kernel merged nf_conntrack_ipv{4,6} into nf_conntrack
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv4', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv6', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_facts']['kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv4', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_facts']['kernel'] is version('4.19.0', '<=')) | ternary('nf_conntrack_ipv6', '') }}"
|
||||
- name: nf_defrag_ipv4
|
||||
- name: nf_nat
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_kernel'] is version('5.0.0', '<=')) | ternary('nf_nat_ipv4', '') }}"
|
||||
- name: "{{ (hostvars[inventory_hostname]['ansible_facts']['kernel'] is version('5.0.0', '<=')) | ternary('nf_nat_ipv4', '') }}"
|
||||
- name: vhost_net
|
||||
- name: x_tables
|
||||
|
||||
@ -95,6 +95,6 @@ _package_repos: []
|
||||
# state: present
|
||||
# filename: "uca"
|
||||
|
||||
_uca_repo: "deb {{ uca_apt_repo_url | default('http://ubuntu-cloud.archive.canonical.com/ubuntu') }} {{ ansible_lsb.codename }}-updates/victoria main"
|
||||
_uca_repo: "deb {{ uca_apt_repo_url | default('http://ubuntu-cloud.archive.canonical.com/ubuntu') }} {{ ansible_facts['lsb']['codename'] }}-updates/victoria main"
|
||||
|
||||
_openstack_host_ca_location: /usr/local/share/ca-certificates/
|
||||
|
Loading…
Reference in New Issue
Block a user