From 58be1b049e819774000e398e9d00b561913e8c87 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 9 Dec 2014 11:31:21 -0500 Subject: [PATCH] added tests for templating and with_items --- .../roles/test_lookups/tasks/main.yml | 30 +++++++++++++------ test/integration/vars_file.yml | 7 +++++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/test/integration/roles/test_lookups/tasks/main.yml b/test/integration/roles/test_lookups/tasks/main.yml index 6480b18b35..8440ff5772 100644 --- a/test/integration/roles/test_lookups/tasks/main.yml +++ b/test/integration/roles/test_lookups/tasks/main.yml @@ -81,7 +81,7 @@ - "wc_result.stdout == '9'" - "cat_result.stdout == newpass" -# ENV LOOKUP +# ENV LOOKUP - name: get first environment var name shell: env | head -n1 | cut -d\= -f1 @@ -92,16 +92,16 @@ register: known_var_value - name: use env lookup to get known var - set_fact: + set_fact: test_val: "{{ lookup('env', known_var_name.stdout) }}" - debug: var=known_var_name.stdout - debug: var=known_var_value.stdout -- debug: var=test_val +- debug: var=test_val - name: compare values assert: - that: + that: - "test_val == known_var_value.stdout" @@ -109,11 +109,23 @@ # https://github.com/ansible/ansible/issues/6550 - name: confirm pipe lookup works with a single positional arg - debug: msg="{{ lookup('pipe', 'ls') }}" - -# https://github.com/ansible/ansible/issues/6550 -- name: confirm pipe lookup works with multiple positional args - debug: msg="{{ lookup('pipe', 'ls -l /tmp') }}" + debug: msg="{{ lookup('pipe', 'ls') }}" +# LOOKUP TEMPLATING + +- name: use bare interpolation + debug: msg="got {{item}}" + with_items: things1 + register: bare_var + +- name: verify that list was interpolated + assert: + that: + - "bare_var.results[0].item == 1" + - "bare_var.results[1].item == 2" + +- name: use list with undefined var in it + debug: msg={{item}} + with_items: things2 diff --git a/test/integration/vars_file.yml b/test/integration/vars_file.yml index bd162327d2..c43bf81866 100644 --- a/test/integration/vars_file.yml +++ b/test/integration/vars_file.yml @@ -2,4 +2,11 @@ # in general define test data in the individual role: # roles/role_name/vars/main.yml +foo: "Hello" +things1: + - 1 + - 2 +things2: + - "{{ foo }}" + - "{{ foob }}" vars_file_var: 321