Clean up jinja2 templates on conditional checks
Starting in Ansible 2.3, jinja2 templates with conditionals were no longer supported. Users should have always directly stated the variables and not treated it as a string of jinja2 text to be expanded. In order to support newer ansible versions, the conditionals have been updated accordingly. Change-Id: Ib74c1783241436258dc0bd52a8a6990c00785775
This commit is contained in:
parent
0fb46c5d6b
commit
6f0eaaff4e
@ -28,8 +28,8 @@
|
||||
set_fact:
|
||||
prealloc: "--prealloc-metadata"
|
||||
when:
|
||||
- "{{ ansible_os_family == 'Debian' }}"
|
||||
- "{{ test_vm_libvirt_uri == 'qemu:///system' }}"
|
||||
- ansible_os_family == 'Debian'
|
||||
- test_vm_libvirt_uri == 'qemu:///system'
|
||||
|
||||
- name: list info on pools
|
||||
virt_pool:
|
||||
@ -51,7 +51,7 @@
|
||||
vol-create-as {{ test_vm_storage_pool }} {{ vm_name }}.qcow2
|
||||
{{ test_vm_disk_gib | int + 1 }}G
|
||||
--format qcow2 {{ prealloc|default("") }}
|
||||
when: "{{ vm_name + '.qcow2' not in ansible_libvirt_pools[test_vm_storage_pool].volumes }}"
|
||||
when: (vm_name + '.qcow2') not in ansible_libvirt_pools[test_vm_storage_pool].volumes
|
||||
|
||||
- name: set path to the volume created
|
||||
set_fact:
|
||||
@ -61,7 +61,7 @@
|
||||
file:
|
||||
state: touch
|
||||
path: "{{ vm_volume_path }}"
|
||||
when: "{{ test_vm_libvirt_uri == 'qemu:///system' }}"
|
||||
when: test_vm_libvirt_uri == 'qemu:///system'
|
||||
|
||||
# NOTE(TheJulia): CentOS default installs with an XFS root, and chattr
|
||||
# fails to set +C on XFS. This could be more elegant, however the use
|
||||
@ -70,8 +70,8 @@
|
||||
command: chattr +C {{ vm_volume_path }}
|
||||
ignore_errors: yes
|
||||
when:
|
||||
- "{{ ansible_distribution != 'CentOS' }}"
|
||||
- "{{ test_vm_libvirt_uri == 'qemu:///system' }}"
|
||||
- ansible_distribution != 'CentOS'
|
||||
- test_vm_libvirt_uri == 'qemu:///system'
|
||||
|
||||
- name: create_vm
|
||||
virt:
|
||||
@ -91,7 +91,7 @@
|
||||
fail: >
|
||||
msg="VM creation step failed, please review dmesg
|
||||
output for additional details"
|
||||
when: "{{ vm_name not in existing_vms.list_vms }}"
|
||||
when: vm_name not in existing_vms.list_vms
|
||||
|
||||
# TODO(pas-ha) replace 'command: vbmc ...' tasks
|
||||
# with a custom Ansible module using vbmc Python API
|
||||
@ -104,7 +104,7 @@
|
||||
- name: delete vm from virtualbmc if it is there
|
||||
command: vbmc delete {{ vm_name }}
|
||||
environment: "{{ bifrost_venv_env if enable_venv else {} }}"
|
||||
when: vbmc_list.stdout.find("{{ vm_name }} ") != -1
|
||||
when: vbmc_list.stdout.find(vm_name) != -1
|
||||
|
||||
- set_fact:
|
||||
virtual_ipmi_port: "{{ (test_vm_ipmi_port_start|default(623) | int ) + (testvm_json_data | length) }}"
|
||||
|
@ -70,7 +70,7 @@
|
||||
- name: "Adjust ansible_pkg_mgr if dnf exists"
|
||||
set_fact:
|
||||
ansible_pkg_mgr: "dnf"
|
||||
when: ansible_distribution == 'Fedora' and "{{ test_dnf.stat.exists|bool }}"
|
||||
when: ansible_distribution == 'Fedora' and test_dnf.stat.exists|bool
|
||||
|
||||
- name: "Install required packages"
|
||||
action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
|
||||
@ -86,12 +86,12 @@
|
||||
set_fact:
|
||||
generated_test_vm_node_names: "{{ generated_test_vm_node_names|default([]) + [item] }}"
|
||||
with_sequence: count={{ test_vm_num_nodes | int }} format={{ test_vm_node_name_base }}%i
|
||||
when: "{{ test_vm_node_names | length == 0 }}"
|
||||
when: test_vm_node_names | length == 0
|
||||
|
||||
- name: set test vm names
|
||||
set_fact:
|
||||
test_vm_node_names: "{{ generated_test_vm_node_names }}"
|
||||
when: "{{ test_vm_node_names | length == 0 }}"
|
||||
when: test_vm_node_names | length == 0
|
||||
|
||||
- name: create placeholder var for vm entries in JSON format
|
||||
set_fact:
|
||||
|
@ -213,7 +213,7 @@
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: 0755
|
||||
when: "{{ inventory_dhcp | bool == true }}"
|
||||
when: inventory_dhcp | bool == true
|
||||
- name: "Setup Inventory DHCP Hosts Directory"
|
||||
file:
|
||||
path: "/etc/dnsmasq.d/bifrost.dhcp-hosts.d"
|
||||
@ -221,16 +221,16 @@
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: 0755
|
||||
when: "{{ inventory_dhcp | bool == true }}"
|
||||
when: inventory_dhcp | bool == true
|
||||
- name: "Deploy dnsmasq configuration file"
|
||||
template: src=dnsmasq.conf.j2 dest=/etc/dnsmasq.conf
|
||||
when: "{{ include_dhcp_server | bool == true }}"
|
||||
when: include_dhcp_server | bool == true
|
||||
# NOTE(Shrews) When testing, we want to use our custom dnsmasq.conf file,
|
||||
# not the one supplied by libvirt.
|
||||
- name: "Look for libvirt dnsmasq config"
|
||||
stat: path=/etc/dnsmasq.d/libvirt-bin
|
||||
register: test_libvirt_dnsmasq
|
||||
when: "{{ include_dhcp_server | bool == true }}"
|
||||
when: include_dhcp_server | bool == true
|
||||
- name: "Disable libvirt dnsmasq config"
|
||||
command: mv /etc/dnsmasq.d/libvirt-bin /etc/dnsmasq.d/libvirt-bin~
|
||||
when: >
|
||||
@ -246,7 +246,7 @@
|
||||
get_url:
|
||||
url: "{{ cirros_deploy_image_upstream_url }}"
|
||||
dest: "{{ deploy_image }}"
|
||||
when: "{{ use_cirros | bool == true }}"
|
||||
when: use_cirros | bool == true
|
||||
- name: >
|
||||
"Explicitly permit nginx port (TCP) for
|
||||
file downloads from nodes to be provisioned"
|
||||
|
@ -18,13 +18,13 @@
|
||||
msg: >
|
||||
The configured network interface {{ network_interface }} does
|
||||
not exist
|
||||
when: "{{ 'ansible_' ~ ans_network_interface not in hostvars[inventory_hostname] }}"
|
||||
when: ('ansible_' ~ network_interface) not in hostvars[inventory_hostname]
|
||||
- name: "Fail if the network interface has no IP address assigned"
|
||||
fail:
|
||||
msg: >
|
||||
The configured network interface {{ network_interface }} does
|
||||
not have an IP address assigned
|
||||
when: "{{ not hostvars[inventory_hostname]['ansible_' ~ ans_network_interface].get('ipv4', {}).get('address') }}"
|
||||
when: not hostvars[inventory_hostname]['ansible_' ~ network_interface].get('ipv4', {}).get('address')
|
||||
- name: "Update driver list if PXE drivers are enabled"
|
||||
set_fact:
|
||||
enabled_drivers: "{{ enabled_drivers }},{{ pxe_drivers }}"
|
||||
|
@ -48,7 +48,7 @@
|
||||
# are not controlled by upstart, so we need to manually kill those.
|
||||
- name: "Stop existing libvirt dnsmasq processes"
|
||||
command: killall -w dnsmasq
|
||||
when: "{{ testing | bool == true and include_dhcp_server | bool == true }}"
|
||||
when: testing | bool == true and include_dhcp_server | bool == true
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Ensure services are running with current config"
|
||||
@ -61,7 +61,7 @@
|
||||
service: name={{ item }} state=restarted enabled=yes
|
||||
with_items:
|
||||
- dnsmasq
|
||||
when: "{{ include_dhcp_server | bool == true }}"
|
||||
when: include_dhcp_server | bool == true
|
||||
|
||||
- name: "Send services a reload signal"
|
||||
service: name={{ item }} state=reloaded
|
||||
@ -71,4 +71,4 @@
|
||||
|
||||
- name: "Send services a force-reload signal"
|
||||
service: name=dnsmasq state=restarted
|
||||
when: "{{ include_dhcp_server | bool == true }}"
|
||||
when: include_dhcp_server | bool == true
|
||||
|
Loading…
Reference in New Issue
Block a user