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
|
||||
|
||||
- name: clone repo
|
||||
- name: AMBIGUOUS-REF | clone repo
|
||||
git:
|
||||
repo: '{{ repo_format1 }}'
|
||||
dest: '{{ checkout_dir }}'
|
||||
|
||||
- name: rename remote to be ambiguous
|
||||
command: git remote rename origin v0.1 chdir="{{ checkout_dir }}"
|
||||
- name: AMBIGUOUS-REF | rename remote to be ambiguous
|
||||
command: git remote rename origin v0.1
|
||||
args:
|
||||
chdir: "{{ checkout_dir }}"
|
||||
|
||||
- name: switch to HEAD
|
||||
- name: AMBIGUOUS-REF | switch to HEAD
|
||||
git:
|
||||
repo: '{{ repo_format1 }}'
|
||||
dest: '{{ checkout_dir }}'
|
||||
remote: v0.1
|
||||
|
||||
- name: rev-parse remote HEAD
|
||||
command: git rev-parse v0.1/HEAD chdir="{{ checkout_dir }}"
|
||||
- name: AMBIGUOUS-REF | rev-parse remote HEAD
|
||||
command: git rev-parse v0.1/HEAD
|
||||
args:
|
||||
chdir: "{{ checkout_dir }}"
|
||||
register: git_remote_head
|
||||
|
||||
- name: rev-parse local HEAD
|
||||
command: git rev-parse HEAD chdir="{{ checkout_dir }}"
|
||||
- name: AMBIGUOUS-REF | rev-parse local HEAD
|
||||
command: git rev-parse HEAD
|
||||
args:
|
||||
chdir: "{{ checkout_dir }}"
|
||||
register: git_local_head
|
||||
|
||||
- assert:
|
||||
that: git_remote_head.stdout == git_local_head.stdout
|
||||
|
||||
- name: clear checkout_dir
|
||||
file: state=absent path={{ checkout_dir }}
|
||||
- name: AMBIGUOUS-REF | clear 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,28 +1,26 @@
|
||||
---
|
||||
|
||||
- name: create dirs
|
||||
- name: SETUP-LOCAL-REPOS | create dirs
|
||||
file:
|
||||
name: "{{item}}"
|
||||
name: "{{ item }}"
|
||||
state: directory
|
||||
with_items:
|
||||
- "{{repo_dir}}/minimal"
|
||||
- "{{repo_dir}}/shallow"
|
||||
- "{{ repo_dir }}/minimal"
|
||||
- "{{ repo_dir }}/shallow"
|
||||
|
||||
- name: prepare minimal git repo
|
||||
- name: SETUP-LOCAL-REPOS | prepare minimal git repo
|
||||
shell: git init; echo "1" > a; git add a; git commit -m "1"
|
||||
args:
|
||||
chdir: "{{repo_dir}}/minimal"
|
||||
chdir: "{{ repo_dir }}/minimal"
|
||||
|
||||
- name: prepare git repo for shallow clone
|
||||
- name: SETUP-LOCAL-REPOS | prepare git repo for shallow clone
|
||||
shell: |
|
||||
git init;
|
||||
echo "1" > a; git add a; git commit -m "1"; git tag earlytag; git branch earlybranch;
|
||||
echo "2" > a; git add a; git commit -m "2";
|
||||
args:
|
||||
chdir: "{{repo_dir}}/shallow"
|
||||
chdir: "{{ repo_dir }}/shallow"
|
||||
|
||||
- name: set old hash var for shallow test
|
||||
- name: SETUP-LOCAL-REPOS | set old hash var for shallow test
|
||||
command: 'git rev-parse HEAD~1'
|
||||
register: git_shallow_head_1
|
||||
args:
|
||||
chdir: "{{repo_dir}}/shallow"
|
||||
chdir: "{{ repo_dir }}/shallow"
|
||||
|
@ -1,31 +1,31 @@
|
||||
---
|
||||
|
||||
- name: clean out the output_dir
|
||||
- name: SETUP | clean out the output_dir
|
||||
file:
|
||||
path: "{{ output_dir }}"
|
||||
state: absent
|
||||
|
||||
- name: create clean output_dir
|
||||
- name: SETUP | create clean output_dir
|
||||
file:
|
||||
path: "{{ output_dir }}"
|
||||
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
|
||||
|
||||
- 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 //'
|
||||
register: git_version
|
||||
|
||||
- name: get gpg version
|
||||
- name: SETUP | get gpg version
|
||||
shell: gpg --version 2>1 | head -1 | sed -e 's/gpg (GnuPG) //'
|
||||
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"
|
||||
|
||||
- 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"
|
||||
|
||||
- name: create repo_dir
|
||||
file: path={{repo_dir}} state=directory
|
||||
- name: SETUP | create repo_dir
|
||||
file:
|
||||
path: "{{ repo_dir }}"
|
||||
state: directory
|
||||
|
Loading…
Reference in New Issue