mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
added lookup paths testing
This commit is contained in:
parent
3d9875773b
commit
60803a1d3c
4 changed files with 84 additions and 0 deletions
|
@ -184,3 +184,6 @@ test_galaxy_yaml:
|
|||
RC=$$? ; \
|
||||
rm -rf $$mytmpdir ; \
|
||||
exit $$RC
|
||||
|
||||
test_lookup_paths:
|
||||
ansible-playbook lookup_paths/play.yml -i $(INVENTORY) -v $(TEST_FLAGS)
|
||||
|
|
60
test/integration/lookup_paths/play.yml
Normal file
60
test/integration/lookup_paths/play.yml
Normal file
|
@ -0,0 +1,60 @@
|
|||
- name: setup state
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- copy: dest={{playbook_dir}}/roles/showfile/files/testfile content='in role files'
|
||||
- copy: dest={{playbook_dir}}/roles/showfile/tasks/testfile content='in role tasks'
|
||||
- copy: dest={{playbook_dir}}/roles/showfile/testfile content='in role'
|
||||
- copy: dest={{playbook_dir}}/files/testfile content='in files'
|
||||
- copy: dest={{playbook_dir}}/testfile content='in local'
|
||||
- set_fact: role_out="in role files" play_out="in files"
|
||||
|
||||
- include: testplay.yml
|
||||
|
||||
- name: remove from role/files
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- file: path={{playbook_dir}}/roles/showfile/files/testfile state=absent
|
||||
- set_fact: role_out="in role tasks" play_out="in files"
|
||||
|
||||
- include: testplay.yml
|
||||
|
||||
- name: remove from role/tasks
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- file: path={{playbook_dir}}/roles/showfile/tasks/testfile state=absent
|
||||
- set_fact: role_out="in files" play_out="in files"
|
||||
|
||||
- include: testplay.yml
|
||||
|
||||
- name: remove from role dir
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- file: path={{playbook_dir}}/roles/showfile/testfile state=absent
|
||||
- set_fact: role_out="in files" play_out="in files"
|
||||
|
||||
- include: testplay.yml
|
||||
|
||||
- name: remove from play/files
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- file: path={{playbook_dir}}/files/testfile state=absent
|
||||
- set_fact: role_out="in local" play_out="in local"
|
||||
|
||||
- include: testplay.yml
|
||||
|
||||
- name: cleanup
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- file: path={{playbook_dir}}/testfile state=absent
|
|
@ -0,0 +1,2 @@
|
|||
- name: relative to role
|
||||
set_fact: role_result="{{lookup('file', 'testfile')}}"
|
19
test/integration/lookup_paths/testplay.yml
Normal file
19
test/integration/lookup_paths/testplay.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
- name: test initial state
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
roles:
|
||||
- showfile
|
||||
tasks:
|
||||
- name: from play
|
||||
set_fact: play_result="{{lookup('file', 'testfile')}}"
|
||||
|
||||
- name: output output
|
||||
debug: msg="play> {{play_out}}, role> {{role_out}}"
|
||||
|
||||
- name: verify that result match expected
|
||||
assert:
|
||||
that:
|
||||
- 'play_result == play_out'
|
||||
- 'role_result == role_out'
|
||||
|
Loading…
Reference in a new issue