From 57ee42601a5cfdcb7cc3c7b3f0d52630ef22f7df Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 3 Aug 2018 08:14:11 -0500 Subject: [PATCH] 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 --- playbooks/roles/base-server/tasks/main.yaml | 14 +++++++------- playbooks/roles/exim/tasks/main.yaml | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/playbooks/roles/base-server/tasks/main.yaml b/playbooks/roles/base-server/tasks/main.yaml index 4d7f669245..d305d4f9d9 100644 --- a/playbooks/roles/base-server/tasks/main.yaml +++ b/playbooks/roles/base-server/tasks/main.yaml @@ -5,12 +5,13 @@ loop: '{{ base_packages }}' - name: Include OS-specific variables - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_facts.distribution }}.{{ ansible_facts.architecture }}.yaml" - - "{{ ansible_facts.distribution }}.yaml" - - "{{ ansible_facts.os_family }}.yaml" - - "default.yaml" + 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: Install distro specific packages package: @@ -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" diff --git a/playbooks/roles/exim/tasks/main.yaml b/playbooks/roles/exim/tasks/main.yaml index a91cfb55e6..c3d6a43935 100644 --- a/playbooks/roles/exim/tasks/main.yaml +++ b/playbooks/roles/exim/tasks/main.yaml @@ -1,16 +1,17 @@ - name: Include OS-specific variables - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_facts.distribution }}.{{ ansible_facts.architecture }}.yaml" - - "{{ ansible_facts.distribution }}.yaml" - - "{{ ansible_facts.os_family }}.yaml" - - "default.yaml" + 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"