Skip to content

Commit 3578dd4

Browse files
authored
Merge pull request #79 from stackhpc/ansible-facts
Use ansible_facts to reference facts
2 parents 9612557 + b6018f7 commit 3578dd4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

tasks/autodetect.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- name: Set a fact containing the virtualisation engine
1616
set_fact:
1717
libvirt_vm_engine: >-
18-
{%- if ansible_architecture != libvirt_vm_arch -%}
18+
{%- if ansible_facts.architecture != libvirt_vm_arch -%}
1919
{# Virtualisation instructions are generally available only for the host
2020
architecture. Ideally we would test for virtualisation instructions, eg. vt-d
2121
as it is possible that another architecture could support these even
@@ -59,8 +59,8 @@
5959
when: kvm_emulator_result.stat.exists
6060
when:
6161
- libvirt_vm_engine == 'qemu'
62-
- ansible_os_family == 'RedHat'
63-
- ansible_distribution_major_version | int >= 8
62+
- ansible_facts.os_family == 'RedHat'
63+
- ansible_facts.distribution_major_version | int >= 8
6464

6565
- block:
6666
- name: Detect the QEMU emulator binary path
@@ -74,7 +74,7 @@
7474

7575
when:
7676
- libvirt_vm_engine == 'qemu'
77-
- ansible_os_family != 'RedHat' or ansible_distribution_major_version | int == 7
77+
- ansible_facts.os_family != 'RedHat' or ansible_facts.distribution_major_version | int == 7
7878

7979
- name: Fail if unable to detect the emulator
8080
fail:

tasks/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
include_vars: "{{ item }}"
44
with_first_found:
55
- files:
6-
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
7-
- "{{ ansible_distribution }}.yml"
8-
- "{{ ansible_os_family }}.yml"
6+
- "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
7+
- "{{ ansible_facts.distribution }}.yml"
8+
- "{{ ansible_facts.os_family }}.yml"
99
tags: vars
1010

1111
- include_tasks: autodetect.yml
@@ -18,8 +18,8 @@
1818
# Libvirt requires qemu-img to create qcow2 files.
1919
- name: Ensure qemu-img is installed
2020
package:
21-
name: "{{ 'qemu-img' if ansible_os_family == 'RedHat' else 'qemu-utils' }}"
22-
update_cache: "{{ True if ansible_pkg_mgr == 'apt' else omit }}"
21+
name: "{{ 'qemu-img' if ansible_facts.os_family == 'RedHat' else 'qemu-utils' }}"
22+
update_cache: "{{ True if ansible_facts.pkg_mgr == 'apt' else omit }}"
2323
become: true
2424

2525
- include_tasks: volumes.yml

0 commit comments

Comments
 (0)