Replace with_first_found with lookup first_found

The with_ directives are discouraged now in place of use of loop: and/or
lookup filters. In the case of with_first_found, it confuses people
because with_ directives are usually a loop, but in this case it's
the task is always executed once. Using the first_found filter makes it
clearer that this is occuring.

While we're in there, remove uses of 'static: no'. Since 2.0 includes
are dynamic by default, so these are not necessary.

Change-Id: Ie429d7614b2f3322a646f46a8117d4b6ae29f737
This commit is contained in:
Monty Taylor 2018-08-03 08:14:11 -05:00
parent 41989b59cf
commit 57ee42601a
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
2 changed files with 18 additions and 17 deletions

View File

@ -5,8 +5,9 @@
loop: '{{ base_packages }}'
- name: Include OS-specific variables
include_vars: "{{ item }}"
with_first_found:
include_vars: "{{ lookup('first_found', file_list) }}"
vars:
file_list:
- "{{ ansible_facts.distribution }}.{{ ansible_facts.architecture }}.yaml"
- "{{ ansible_facts.distribution }}.yaml"
- "{{ ansible_facts.os_family }}.yaml"
@ -54,7 +55,6 @@
- name: Include OS-specific tasks
include_tasks: "{{ lookup('first_found', file_list) }}"
static: no
vars:
file_list:
- "{{ ansible_facts.distribution }}.{{ ansible_facts.lsb.codename }}.{{ ansible_facts.architecture }}.yaml"

View File

@ -1,16 +1,17 @@
- name: Include OS-specific variables
include_vars: "{{ item }}"
with_first_found:
include_vars: "{{ lookup('first_found', file_list) }}"
vars:
file_list:
- "{{ ansible_facts.distribution }}.{{ ansible_facts.architecture }}.yaml"
- "{{ ansible_facts.distribution }}.yaml"
- "{{ ansible_facts.os_family }}.yaml"
- "default.yaml"
- name: Include OS-specific tasks
include_tasks: "{{ item }}"
static: no
with_first_found:
- files:
include_tasks: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- "{{ ansible_facts.distribution }}.{{ ansible_facts.lsb.codename }}.{{ ansible_facts.architecture }}.yaml"
- "{{ ansible_facts.distribution }}.{{ ansible_facts.architecture }}.yaml"
- "{{ ansible_facts.distribution }}.yaml"