mirror of https://github.com/ansible/ansible.git
Correct usage for shutil.rmtree (#31541)
* Correct usage for shutil.rmtree Fix adds correct usage of shutil.rmtree in git module Fixes: #31225 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com> * Include archive tests so they get run * Use new include syntax * Cleanup syntax on git tests - use multi-line YAML - remove unneeded {{ }} around vars in conditionals - remove unneeded quotes - add task file name to task names for easier troubleshooting when things fail * Make archive tests work for RHEL/CentOS 6 The older versions of Jinja2 in RHEL/CentOS 6 required assertion tasks using the map filter to be skipped. The older version of git required gzip compression to be skipped on RHEL/CentOS 6. * Account for ansible_distribution_major_version missingpull/31708/head
parent
42deaf2c71
commit
a047fe0e4c
@ -1,31 +1,37 @@
|
|||||||
---
|
|
||||||
|
|
||||||
# test for https://github.com/ansible/ansible-modules-core/pull/3386
|
# test for https://github.com/ansible/ansible-modules-core/pull/3386
|
||||||
|
|
||||||
- name: clone repo
|
- name: AMBIGUOUS-REF | clone repo
|
||||||
git:
|
git:
|
||||||
repo: '{{ repo_format1 }}'
|
repo: '{{ repo_format1 }}'
|
||||||
dest: '{{ checkout_dir }}'
|
dest: '{{ checkout_dir }}'
|
||||||
|
|
||||||
- name: rename remote to be ambiguous
|
- name: AMBIGUOUS-REF | rename remote to be ambiguous
|
||||||
command: git remote rename origin v0.1 chdir="{{ checkout_dir }}"
|
command: git remote rename origin v0.1
|
||||||
|
args:
|
||||||
|
chdir: "{{ checkout_dir }}"
|
||||||
|
|
||||||
- name: switch to HEAD
|
- name: AMBIGUOUS-REF | switch to HEAD
|
||||||
git:
|
git:
|
||||||
repo: '{{ repo_format1 }}'
|
repo: '{{ repo_format1 }}'
|
||||||
dest: '{{ checkout_dir }}'
|
dest: '{{ checkout_dir }}'
|
||||||
remote: v0.1
|
remote: v0.1
|
||||||
|
|
||||||
- name: rev-parse remote HEAD
|
- name: AMBIGUOUS-REF | rev-parse remote HEAD
|
||||||
command: git rev-parse v0.1/HEAD chdir="{{ checkout_dir }}"
|
command: git rev-parse v0.1/HEAD
|
||||||
|
args:
|
||||||
|
chdir: "{{ checkout_dir }}"
|
||||||
register: git_remote_head
|
register: git_remote_head
|
||||||
|
|
||||||
- name: rev-parse local HEAD
|
- name: AMBIGUOUS-REF | rev-parse local HEAD
|
||||||
command: git rev-parse HEAD chdir="{{ checkout_dir }}"
|
command: git rev-parse HEAD
|
||||||
|
args:
|
||||||
|
chdir: "{{ checkout_dir }}"
|
||||||
register: git_local_head
|
register: git_local_head
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that: git_remote_head.stdout == git_local_head.stdout
|
that: git_remote_head.stdout == git_local_head.stdout
|
||||||
|
|
||||||
- name: clear checkout_dir
|
- name: AMBIGUOUS-REF | clear checkout_dir
|
||||||
file: state=absent path={{ checkout_dir }}
|
file:
|
||||||
|
state: absent
|
||||||
|
path: "{{ checkout_dir }}"
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
- name: ARCHIVE | Clear checkout_dir
|
||||||
|
file:
|
||||||
|
state: absent
|
||||||
|
path: "{{ checkout_dir }}"
|
||||||
|
|
||||||
|
- name: ARCHIVE | Archive repo using various archival format
|
||||||
|
git:
|
||||||
|
repo: '{{ repo_format1 }}'
|
||||||
|
dest: '{{ checkout_dir }}'
|
||||||
|
archive: '{{ checkout_dir }}/test_role.{{ item }}'
|
||||||
|
register: git_archive
|
||||||
|
with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}"
|
||||||
|
|
||||||
|
# The map filter was added in Jinja2 2.7, which is newer than the version on RHEL/CentOS 6,
|
||||||
|
# so we skip this validation on those hosts
|
||||||
|
- name: ARCHIVE | Assert that archives were downloaded
|
||||||
|
assert:
|
||||||
|
that: (git_archive.results | map(attribute='changed') | unique | list)[0]
|
||||||
|
when:
|
||||||
|
- "ansible_os_family == 'RedHat'"
|
||||||
|
- ansible_distribution_major_version | version_compare('7', '>=')
|
||||||
|
|
||||||
|
- name: ARCHIVE | Check if archive file is created or not
|
||||||
|
stat:
|
||||||
|
path: '{{ checkout_dir }}/test_role.{{ item }}'
|
||||||
|
register: archive_check
|
||||||
|
with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}"
|
||||||
|
|
||||||
|
- name: ARCHIVE | Assert that archive files exist
|
||||||
|
assert:
|
||||||
|
that: (archive_check.results | map(attribute='stat.exists') | unique | list)[0]
|
||||||
|
when:
|
||||||
|
- "ansible_os_family == 'RedHat'"
|
||||||
|
- ansible_distribution_major_version | version_compare('7', '>=')
|
@ -1,31 +1,31 @@
|
|||||||
---
|
- name: SETUP | clean out the output_dir
|
||||||
|
|
||||||
- name: clean out the output_dir
|
|
||||||
file:
|
file:
|
||||||
path: "{{ output_dir }}"
|
path: "{{ output_dir }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: create clean output_dir
|
- name: SETUP | create clean output_dir
|
||||||
file:
|
file:
|
||||||
path: "{{ output_dir }}"
|
path: "{{ output_dir }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: verify that git is installed so this test can continue
|
- name: SETUP | verify that git is installed so this test can continue
|
||||||
shell: which git
|
shell: which git
|
||||||
|
|
||||||
- name: get git version, only newer than {{git_version_supporting_depth}} has fixed git depth
|
- name: SETUP | get git version, only newer than {{git_version_supporting_depth}} has fixed git depth
|
||||||
shell: git --version | grep 'git version' | sed 's/git version //'
|
shell: git --version | grep 'git version' | sed 's/git version //'
|
||||||
register: git_version
|
register: git_version
|
||||||
|
|
||||||
- name: get gpg version
|
- name: SETUP | get gpg version
|
||||||
shell: gpg --version 2>1 | head -1 | sed -e 's/gpg (GnuPG) //'
|
shell: gpg --version 2>1 | head -1 | sed -e 's/gpg (GnuPG) //'
|
||||||
register: gpg_version
|
register: gpg_version
|
||||||
|
|
||||||
- name: set git global user.email if not already set
|
- name: SETUP | set git global user.email if not already set
|
||||||
shell: git config --global user.email || git config --global user.email "noreply@example.com"
|
shell: git config --global user.email || git config --global user.email "noreply@example.com"
|
||||||
|
|
||||||
- name: set git global user.name if not already set
|
- name: SETUP | set git global user.name if not already set
|
||||||
shell: git config --global user.name || git config --global user.name "Ansible Test Runner"
|
shell: git config --global user.name || git config --global user.name "Ansible Test Runner"
|
||||||
|
|
||||||
- name: create repo_dir
|
- name: SETUP | create repo_dir
|
||||||
file: path={{repo_dir}} state=directory
|
file:
|
||||||
|
path: "{{ repo_dir }}"
|
||||||
|
state: directory
|
||||||
|
Loading…
Reference in New Issue