diff --git a/lib/ansible/runner/action_plugins/assert.py b/lib/ansible/runner/action_plugins/assert.py index 210dbc0af11..fbd0b3888ae 100644 --- a/lib/ansible/runner/action_plugins/assert.py +++ b/lib/ansible/runner/action_plugins/assert.py @@ -50,7 +50,7 @@ class ActionModule(object): args['that'] = [ args['that'] ] for that in args['that']: - result = utils.check_conditional(args['that'], self.runner.basedir, inject, fail_on_undefined=True) + result = utils.check_conditional(that, self.runner.basedir, inject, fail_on_undefined=True) if not result: return ReturnData(conn=conn, result=dict(failed=True, assertion=that, evaluated_to=result)) diff --git a/tests_new/integration/roles/test_copy/files/subdir/bar.txt b/tests_new/integration/roles/test_copy/files/subdir/bar.txt new file mode 100644 index 00000000000..76018072e09 --- /dev/null +++ b/tests_new/integration/roles/test_copy/files/subdir/bar.txt @@ -0,0 +1 @@ +baz diff --git a/tests_new/integration/roles/test_copy/files/subdir/subdir2/baz.txt b/tests_new/integration/roles/test_copy/files/subdir/subdir2/baz.txt new file mode 100644 index 00000000000..76018072e09 --- /dev/null +++ b/tests_new/integration/roles/test_copy/files/subdir/subdir2/baz.txt @@ -0,0 +1 @@ +baz diff --git a/tests_new/integration/roles/test_copy/tasks/main.yml b/tests_new/integration/roles/test_copy/tasks/main.yml index 5aa40f036da..81f04ca9e42 100644 --- a/tests_new/integration/roles/test_copy/tasks/main.yml +++ b/tests_new/integration/roles/test_copy/tasks/main.yml @@ -91,9 +91,51 @@ that: - "not copy_result4|changed" -# TODO: test recursive copy -# TODO: test copy where destination is a directory like {{output_dir}}/ +# test recursive copy + +- name: set the output subdirectory + set_fact: output_subdir={{output_dir}}/sub + +- name: make an output subdirectory + file: name={{output_subdir}} state=directory + +- name: test recursive copy to directory + copy: src=subdir dest={{output_subdir}} + register: recursive_copy_result + +- debug: var=recursive_copy_result + +- name: check that a file in a directory was transferred + stat: path={{output_dir}}/sub/subdir/bar.txt + register: stat_bar + +- name: check that a file in a deeper directory was transferred + stat: path={{output_dir}}/sub/subdir/subdir2/bar2.txt + register: stat_bar2 + + +- debug: var=stat_bar + +- fail: msg="boom!" + when: not stat_bar.stat.exists + +- assert: { that: "stat_bar.stat.exists" } + +- name: assert recursive copy things + assert: + that: + - "stat_bar.stat.exists" + - "stat_bar2.stat.exists" + # TODO: test that copy fails if the path does not exist + +- name: assert invalid copy location fails + copy: src=invalid_file_location_does_not_exist dest={{output_dir}}/file.txt + ignore_errors: True + register: failed_copy + +- debug: var=failed_copy + # TODO: ... diff --git a/tests_new/integration/test.sh b/tests_new/integration/test.sh index dae0cdeae21..74e23a258b3 100644 --- a/tests_new/integration/test.sh +++ b/tests_new/integration/test.sh @@ -1 +1 @@ -ansible-playbook non_destructive.yml -i inventory -e output_dir=~/ansible_testing -v +ansible-playbook non_destructive.yml -i inventory -e output_dir=~/ansible_testing -v $*