Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: wildcard excludes in unarchive with tar archives #40935

Merged
merged 5 commits into from Jun 22, 2018

Conversation

sijis
Copy link
Contributor

@sijis sijis commented May 31, 2018

SUMMARY

Fixes an issue where the exclude option is used and one of the entries contains a wildcard, the unarchive module does not exclude files matching those wildcards as expected.

Fixes #37842, #22947
Related #40120

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

unarchive

ANSIBLE VERSION
ansible 2.7.0.dev0 (fix/unarchive/exclude_tar d8ef19b0c3) last updated 2018/05/31 02:04:19 (GMT -500)
  config file = None
  configured module search path = ['/home/saviles/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/saviles/data/git/github/ansible/lib/ansible
  executable location = /home/saviles/data/git/github/ansible/bin/ansible
  python version = 3.6.5 (default, Mar 29 2018, 18:20:46) [GCC 8.0.1 20180317 (Red Hat 8.0.1-0.19)]
ADDITIONAL INFORMATION

Playbook used to test

- hosts: localhost
  vars:
    issue: 37842
    src_dir: "files/{{ issue }}"
    dst_dir: "/tmp/{{ issue }}"
  tasks:
    - name: Create directory
      file:
        state: directory
        path: "{{item}}"
      with_items:
        - "{{src_dir}}"
        - "{{dst_dir}}"

    - name: Create files
      shell: "touch {{src_dir}}/{include,exclude}-{0..9}.txt"

    - name: Create archive file
      archive:
        format: "tar"
        path: "{{src_dir}}/*"
        dest: "{{src_dir}}.tar"

    - name: Unpack zip file
      unarchive:
        src: "{{src_dir}}.tar"
        dest: "{{dst_dir}}"
        # remote_src: yes
        exclude:
          - "exclude-*.txt"
      register: unzipped

    - name: Debug unzipped
      debug:
        msg: "{{unzipped}}"
        # verbosity: 2

Before fix

$ ls /tmp/37842/
exclude-0.txt  exclude-2.txt  exclude-4.txt  exclude-6.txt  exclude-8.txt  include-0.txt  include-2.txt  include-4.txt  include-6.txt  include-8.txt
exclude-1.txt  exclude-3.txt  exclude-5.txt  exclude-7.txt  exclude-9.txt  include-1.txt  include-3.txt  include-5.txt  include-7.txt  include-9.txt

After fix

$ ls /tmp/37842/
include-0.txt  include-1.txt  include-2.txt  include-3.txt  include-4.txt  include-5.txt  include-6.txt  include-7.txt  include-8.txt  include-9.txt

I still need to include integration tests.

@sijis sijis force-pushed the fix/unarchive/exclude_tar branch from d8ef19b to e8539a1 Compare May 31, 2018 07:15
@ansibot
Copy link
Contributor

ansibot commented May 31, 2018

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. m:unarchive This issue/PR relates to the unarchive module. labels May 31, 2018
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Jun 1, 2018
@sijis sijis force-pushed the fix/unarchive/exclude_tar branch from e8539a1 to 8b304aa Compare June 5, 2018 04:43
@ansibot ansibot added test This PR relates to tests. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jun 11, 2018
@mattclay
Copy link
Member

CI failure in integration tests: https://app.shippable.com/github/ansible/ansible/runs/69413/38/tests

@mattclay mattclay added the ci_verified Changes made in this PR are causing tests to fail. label Jun 11, 2018
@sijis sijis force-pushed the fix/unarchive/exclude_tar branch from 0af13a8 to b6be9c3 Compare June 12, 2018 05:38
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jun 12, 2018
@sijis sijis force-pushed the fix/unarchive/exclude_tar branch 4 times, most recently from 116ae28 to c908778 Compare June 12, 2018 12:36
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jun 12, 2018
@sijis sijis force-pushed the fix/unarchive/exclude_tar branch from c908778 to 5893fdd Compare June 13, 2018 05:17
@ansibot
Copy link
Contributor

ansibot commented Jun 13, 2018

The test ansible-test sanity --test no-tests-as-filters [explain] failed with 1 error:

test/integration/targets/unarchive/tasks/main.yml:247:16: use `item.stdout is search` instead of `item.stdout | search`

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jun 13, 2018
@sijis sijis force-pushed the fix/unarchive/exclude_tar branch from 5893fdd to e38576a Compare June 13, 2018 12:31
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jun 13, 2018
@sijis sijis force-pushed the fix/unarchive/exclude_tar branch from e38576a to 3d92aa3 Compare June 13, 2018 12:38
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Jun 13, 2018
@sijis sijis force-pushed the fix/unarchive/exclude_tar branch from 3d92aa3 to 4d88d26 Compare June 13, 2018 14:17
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jun 13, 2018
@sijis sijis force-pushed the fix/unarchive/exclude_tar branch from 4d88d26 to b6aa73c Compare June 20, 2018 05:50
@sijis
Copy link
Contributor Author

sijis commented Jun 20, 2018

Rebased.

@abadger abadger merged commit ba3db90 into ansible:devel Jun 22, 2018
@sijis sijis deleted the fix/unarchive/exclude_tar branch June 22, 2018 16:26
jacum pushed a commit to jacum/ansible that referenced this pull request Jun 26, 2018
* fix: exclude using wildcards for tar archives

Fixes ansible#37842, ansible#22947

* fix: Remove quote() as it munges the exclude format

* test: Refactor to use single archive structure

A common structure archived by different methods should simplify some of
the feature tests.

* test: Use common archive layout to validate exclude feature

* test: Use the same exclude checks for zip/tar archives
@ansible ansible locked and limited conversation to collaborators Jun 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. m:unarchive This issue/PR relates to the unarchive module. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unarchive module with exclude in wildcard doesn't seem to work
5 participants