From e21f2e99b7c868ce7c7b0ba709474ac884eac238 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Apr 09 2018 19:35:01 +0000 Subject: Avocado Test Role: use synchronize module to pull out logs The fetch module reports that it "cannot work on directories": TASK [standard-test-avocado : Pull out the logs] **************************************************************** fatal: [localhost]: FAILED! => {"changed": false, "file": "./artifacts/", "msg": "remote file is a directory, fetch cannot work on directories"} Let's use the synchronize method, as other roles are using, to fetch the complete directory structure. Signed-off-by: Cleber Rosa --- diff --git a/roles/standard-test-avocado/tasks/main.yml b/roles/standard-test-avocado/tasks/main.yml index 78c2b2c..635cbcb 100644 --- a/roles/standard-test-avocado/tasks/main.yml +++ b/roles/standard-test-avocado/tasks/main.yml @@ -2,18 +2,26 @@ - name: Install the avocado requirements package: name={{item}} state=latest with_items: + - rsync # need rsync for Ansible synchronize module - python2-avocado +- name: Define remote_artifacts if it is not already defined + set_fact: + remote_artifacts: /tmp/artifacts + when: remote_artifacts is not defined + - name: Make artifacts directory - file: path={{ artifacts }} state=directory owner=root mode=755 recurse=yes + file: path={{ remote_artifacts }} state=directory owner=root mode=755 recurse=yes - block: - name: Execute the avocado test - shell: exec 2>>{{artifacts}}/test.log 1>>{{artifacts}}/test.log; MODULE=rpm python -m avocado run --job-results-dir {{artifacts}}/ {{tests|join(' ') }} + shell: exec 2>>{{remote_artifacts}}/test.log 1>>{{remote_artifacts}}/test.log; MODULE=rpm python -m avocado run --job-results-dir {{remote_artifacts}}/ {{tests|join(' ') }} - always: - name: Pull out the logs - fetch: - dest: "{{artifacts}}/" - src: "{{artifacts}}/" - flat: yes + synchronize: + dest: "{{ artifacts }}/" + src: "{{ remote_artifacts }}/" + mode: pull + ssh_args: "-o UserKnownHostsFile=/dev/null" + when: artifacts|default("") != ""