mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 15:15:26 +01:00
* Enable at, patch and synchronize tests * Remove commented out tasks * Skip currently unsupported platforms * Skip AIX on at
116 lines
2.7 KiB
YAML
116 lines
2.7 KiB
YAML
- debug:
|
|
msg: >-
|
|
Skipping {{ ansible_distribution }} as ansible-base does not contain
|
|
the packaging module ({{ ansible_pkg_mgr }}) for this operating system
|
|
when: ansible_pkg_mgr not in ['apt', 'dnf', 'yum']
|
|
|
|
- name: stop executing on hosts that we don't have package manager modules for
|
|
meta: end_host
|
|
when: ansible_pkg_mgr not in ['apt', 'dnf', 'yum']
|
|
|
|
- name: ensure idempotency installed
|
|
package:
|
|
name: patch
|
|
when: ansible_pkg_mgr in ['apt', 'dnf', 'yum']
|
|
|
|
- name: create a directory for the result
|
|
file:
|
|
dest: '{{ output_dir }}/patch'
|
|
state: directory
|
|
register: result
|
|
|
|
- name: assert the directory was created
|
|
assert:
|
|
that:
|
|
- result.state == 'directory'
|
|
|
|
- name: copy the origin file
|
|
copy:
|
|
src: ./origin.txt
|
|
dest: '{{ output_dir }}/patch/workfile.txt'
|
|
register: result
|
|
|
|
- name: patch the origin file in check mode
|
|
check_mode: true
|
|
register: result
|
|
patch:
|
|
src: result.patch
|
|
dest: '{{ output_dir }}/patch/workfile.txt'
|
|
|
|
- name: verify patch the origin file in check mode
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: patch the origin file
|
|
register: result
|
|
patch:
|
|
src: result.patch
|
|
dest: '{{ output_dir }}/patch/workfile.txt'
|
|
|
|
- name: verify patch the origin file
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: test patch the origin file idempotency
|
|
register: result
|
|
patch:
|
|
src: result.patch
|
|
dest: '{{ output_dir }}/patch/workfile.txt'
|
|
|
|
- name: verify test patch the origin file idempotency
|
|
assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: verify the resulted file matches expectations
|
|
copy:
|
|
src: ./result.txt
|
|
dest: '{{ output_dir }}/patch/workfile.txt'
|
|
register: result
|
|
failed_when: result is changed
|
|
|
|
- name: patch the workfile file in check mode state absent
|
|
check_mode: true
|
|
register: result
|
|
patch:
|
|
src: result.patch
|
|
dest: '{{ output_dir }}/patch/workfile.txt'
|
|
state: absent
|
|
|
|
- name: verify patch the workfile file in check mode state absent
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: patch the workfile file state absent
|
|
register: result
|
|
patch:
|
|
src: result.patch
|
|
dest: '{{ output_dir }}/patch/workfile.txt'
|
|
state: absent
|
|
|
|
- name: verify patch the workfile file state absent
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: patch the workfile file state absent idempotency
|
|
register: result
|
|
patch:
|
|
src: result.patch
|
|
dest: '{{ output_dir }}/patch/workfile.txt'
|
|
state: absent
|
|
|
|
- name: verify patch the workfile file state absent idempotency
|
|
assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: verify the resulted file matches expectations
|
|
copy:
|
|
src: ./origin.txt
|
|
dest: '{{ output_dir }}/patch/workfile.txt'
|
|
register: result
|
|
failed_when: result is changed
|