#169 Avocado Test Role: use synchronize module to pull out logs
Closed 5 years ago by astepano. Opened 5 years ago by cleber.
cleber/standard-test-roles avocado_synchronize  into  master

@@ -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("") != ""

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 crosa@redhat.com

Hi!
Thank you for PR
Just merged a fix for this from #168
Close this as duplicate of #168.
Thank you!

Pull-Request has been closed by astepano

5 years ago