mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 15:15:26 +01:00
Fix integration test error on ansible devel branch
- Remove centos6 platforms for integration tests on the ansible devel branch from the azure-pipelines. - Add delegate_to to each task of integration test for synchronized module on devel branch - Modify invalid parameter test to use key instead of name for sysctl module - Replace lookup plugin to slurp module in integration tests for selinux module - Add creating working directory task in integration tests for acl module Signed-off-by: Hideki Saito <saito@fgrep.org>
This commit is contained in:
parent
aaa96c2011
commit
8f58cbb41c
6 changed files with 94 additions and 20 deletions
|
|
@ -51,8 +51,6 @@ stages:
|
|||
parameters:
|
||||
testFormat: devel/linux/{0}/1
|
||||
targets:
|
||||
- name: CentOS 6
|
||||
test: centos6
|
||||
- name: CentOS 7
|
||||
test: centos7
|
||||
- name: CentOS 8
|
||||
|
|
@ -61,8 +59,6 @@ stages:
|
|||
test: fedora33
|
||||
- name: Fedora 34
|
||||
test: fedora34
|
||||
- name: openSUSE 15 py2
|
||||
test: opensuse15py2
|
||||
- name: openSUSE 15 py3
|
||||
test: opensuse15
|
||||
- name: Ubuntu 18.04
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
trivial:
|
||||
- Fix integration tests of synchronize and sysctl to address chaging behavior on devel branch (https://github.com/ansible-collections/overview/issues/45).
|
||||
|
|
@ -23,6 +23,16 @@
|
|||
group:
|
||||
name: "{{ test_group }}"
|
||||
|
||||
- name: Clean up working directory and files
|
||||
file:
|
||||
path: "{{ output_dir }}"
|
||||
state: absent
|
||||
|
||||
- name: Create working directory
|
||||
file:
|
||||
path: "{{ output_dir }}"
|
||||
state: directory
|
||||
|
||||
- name: Create ansible file
|
||||
file:
|
||||
path: "{{ test_file }}"
|
||||
|
|
|
|||
|
|
@ -26,10 +26,19 @@
|
|||
state: present
|
||||
|
||||
- name: TEST 1 | Get current SELinux config file contents
|
||||
slurp:
|
||||
src: /etc/sysconfig/selinux
|
||||
register: selinux_config_original_base64
|
||||
|
||||
- name: TEST 1 | Register SELinux config and SELinux status
|
||||
set_fact:
|
||||
selinux_config_original: "{{ lookup('file', '/etc/sysconfig/selinux').split('\n') }}"
|
||||
selinux_config_original_raw: "{{ selinux_config_original_base64.content | b64decode }}"
|
||||
before_test_sestatus: "{{ ansible_selinux }}"
|
||||
|
||||
- name: TEST 1 | Split by line and register original config
|
||||
set_fact:
|
||||
selinux_config_original: "{{ selinux_config_original_raw.split('\n') }}"
|
||||
|
||||
- debug:
|
||||
var: "{{ item }}"
|
||||
verbosity: 1
|
||||
|
|
@ -95,8 +104,17 @@
|
|||
- _disable_test2.reboot_required
|
||||
|
||||
- name: TEST 1 | Get modified config file
|
||||
slurp:
|
||||
src: /etc/sysconfig/selinux
|
||||
register: selinux_config_after_base64
|
||||
|
||||
- name: TEST 1 | Register modified config
|
||||
set_fact:
|
||||
selinux_config_after: "{{ lookup('file', '/etc/sysconfig/selinux').split('\n') }}"
|
||||
selinux_config_after_raw: "{{ selinux_config_after_base64.content | b64decode }}"
|
||||
|
||||
- name: TEST 1 | Split by line and register modified config
|
||||
set_fact:
|
||||
selinux_config_after: "{{ selinux_config_after_raw.split('\n') }}"
|
||||
|
||||
- debug:
|
||||
var: selinux_config_after
|
||||
|
|
@ -209,8 +227,17 @@
|
|||
- not _state_test2.reboot_required
|
||||
|
||||
- name: TEST 2 | Get modified config file
|
||||
slurp:
|
||||
src: /etc/sysconfig/selinux
|
||||
register: selinux_config_after_base64
|
||||
|
||||
- name: TEST 2 | Register modified config
|
||||
set_fact:
|
||||
selinux_config_after: "{{ lookup('file', '/etc/sysconfig/selinux').split('\n') }}"
|
||||
selinux_config_after_raw: "{{ selinux_config_after_base64.content | b64decode }}"
|
||||
|
||||
- name: TEST 2 | Split by line and register modified config
|
||||
set_fact:
|
||||
selinux_config_after: "{{ selinux_config_after_raw.split('\n') }}"
|
||||
|
||||
- debug:
|
||||
var: selinux_config_after
|
||||
|
|
|
|||
|
|
@ -2,16 +2,29 @@
|
|||
package:
|
||||
name: rsync
|
||||
when: ansible_distribution != "MacOSX"
|
||||
- name: cleanup old files
|
||||
shell: rm -rf {{output_dir}}/*
|
||||
- name: Clean up the working directory and files
|
||||
file:
|
||||
path: '{{ output_dir }}'
|
||||
state: absent
|
||||
- name: Create the working directory
|
||||
file:
|
||||
path: '{{ output_dir }}'
|
||||
state: directory
|
||||
- name: create test new files
|
||||
copy: dest={{output_dir}}/{{item}} mode=0644 content="hello world"
|
||||
copy:
|
||||
dest: '{{output_dir}}/{{item}}'
|
||||
mode: '0644'
|
||||
content: 'hello world'
|
||||
with_items:
|
||||
- foo.txt
|
||||
- bar.txt
|
||||
|
||||
- name: synchronize file to new filename
|
||||
synchronize: src={{output_dir}}/foo.txt dest={{output_dir}}/foo.result
|
||||
synchronize:
|
||||
src: '{{output_dir}}/foo.txt'
|
||||
dest: '{{output_dir}}/foo.result'
|
||||
register: sync_result
|
||||
delegate_to: '{{ inventory_hostname }}'
|
||||
- assert:
|
||||
that:
|
||||
- '''changed'' in sync_result'
|
||||
|
|
@ -31,9 +44,13 @@
|
|||
that:
|
||||
- stat_result.stat.exists == True
|
||||
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
||||
|
||||
- name: test that the file is not copied a second time
|
||||
synchronize: src={{output_dir}}/foo.txt dest={{output_dir}}/foo.result
|
||||
synchronize:
|
||||
src='{{output_dir}}/foo.txt'
|
||||
dest='{{output_dir}}/foo.result'
|
||||
register: sync_result
|
||||
delegate_to: '{{ inventory_hostname }}'
|
||||
- assert:
|
||||
that:
|
||||
- sync_result.changed == False
|
||||
|
|
@ -44,12 +61,14 @@
|
|||
with_items:
|
||||
- foo.result
|
||||
- bar.result
|
||||
|
||||
- name: Synchronize using the mode=push param
|
||||
synchronize:
|
||||
src: '{{output_dir}}/foo.txt'
|
||||
dest: '{{output_dir}}/foo.result'
|
||||
mode: push
|
||||
register: sync_result
|
||||
delegate_to: '{{ inventory_hostname }}'
|
||||
- assert:
|
||||
that:
|
||||
- '''changed'' in sync_result'
|
||||
|
|
@ -69,12 +88,14 @@
|
|||
that:
|
||||
- stat_result.stat.exists == True
|
||||
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
||||
|
||||
- name: test that the file is not copied a second time
|
||||
synchronize:
|
||||
src: '{{output_dir}}/foo.txt'
|
||||
dest: '{{output_dir}}/foo.result'
|
||||
mode: push
|
||||
register: sync_result
|
||||
delegate_to: '{{ inventory_hostname }}'
|
||||
- assert:
|
||||
that:
|
||||
- sync_result.changed == False
|
||||
|
|
@ -85,12 +106,14 @@
|
|||
with_items:
|
||||
- foo.result
|
||||
- bar.result
|
||||
|
||||
- name: Synchronize using the mode=pull param
|
||||
synchronize:
|
||||
src: '{{output_dir}}/foo.txt'
|
||||
dest: '{{output_dir}}/foo.result'
|
||||
mode: pull
|
||||
register: sync_result
|
||||
delegate_to: '{{ inventory_hostname }}'
|
||||
- assert:
|
||||
that:
|
||||
- '''changed'' in sync_result'
|
||||
|
|
@ -110,12 +133,14 @@
|
|||
that:
|
||||
- stat_result.stat.exists == True
|
||||
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
||||
|
||||
- name: test that the file is not copied a second time
|
||||
synchronize:
|
||||
src: '{{output_dir}}/foo.txt'
|
||||
dest: '{{output_dir}}/foo.result'
|
||||
mode: pull
|
||||
register: sync_result
|
||||
delegate_to: '{{ inventory_hostname }}'
|
||||
- assert:
|
||||
that:
|
||||
- sync_result.changed == False
|
||||
|
|
@ -126,12 +151,16 @@
|
|||
with_items:
|
||||
- foo.result
|
||||
- bar.result
|
||||
|
||||
- name: synchronize files using with_items (issue#5965)
|
||||
synchronize: src={{output_dir}}/{{item}} dest={{output_dir}}/{{item}}.result
|
||||
synchronize:
|
||||
src: '{{output_dir}}/{{item}}'
|
||||
dest: '{{output_dir}}/{{item}}.result'
|
||||
with_items:
|
||||
- foo.txt
|
||||
- bar.txt
|
||||
register: sync_result
|
||||
delegate_to: '{{ inventory_hostname }}'
|
||||
- assert:
|
||||
that:
|
||||
- sync_result.changed
|
||||
|
|
@ -151,9 +180,14 @@
|
|||
with_items:
|
||||
- foo.txt
|
||||
- bar.txt
|
||||
|
||||
- name: synchronize files using rsync_path (issue#7182)
|
||||
synchronize: src={{output_dir}}/foo.txt dest={{output_dir}}/foo.rsync_path rsync_path="sudo rsync"
|
||||
synchronize:
|
||||
src: '{{output_dir}}/foo.txt'
|
||||
dest: '{{output_dir}}/foo.rsync_path'
|
||||
rsync_path: 'sudo rsync'
|
||||
register: sync_result
|
||||
delegate_to: '{{ inventory_hostname }}'
|
||||
- assert:
|
||||
that:
|
||||
- '''changed'' in sync_result'
|
||||
|
|
@ -186,6 +220,7 @@
|
|||
dest: '{{output_dir}}/{{item}}/foo.txt'
|
||||
with_items:
|
||||
- directory_a
|
||||
delegate_to: '{{ inventory_hostname }}'
|
||||
- name: synchronize files using link_dest
|
||||
synchronize:
|
||||
src: '{{output_dir}}/directory_a/foo.txt'
|
||||
|
|
@ -193,6 +228,7 @@
|
|||
link_dest:
|
||||
- '{{output_dir}}/directory_a'
|
||||
register: sync_result
|
||||
delegate_to: '{{ inventory_hostname }}'
|
||||
- name: get stat information for directory_a
|
||||
stat:
|
||||
path: '{{ output_dir }}/directory_a/foo.txt'
|
||||
|
|
@ -214,6 +250,8 @@
|
|||
- '{{output_dir}}'
|
||||
register: sync_result
|
||||
ignore_errors: true
|
||||
delegate_to: '{{ inventory_hostname }}'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- sync_result is not changed
|
||||
|
|
|
|||
|
|
@ -123,10 +123,10 @@
|
|||
that:
|
||||
- sysctl_test2_change_test is not changed
|
||||
|
||||
- name: Try sysctl with an invalid value
|
||||
- name: Try sysctl with an invalid name
|
||||
sysctl:
|
||||
name: net.ipv4.ip_forward
|
||||
value: foo
|
||||
name: test.invalid
|
||||
value: 1
|
||||
register: sysctl_test3
|
||||
ignore_errors: yes
|
||||
|
||||
|
|
@ -196,10 +196,10 @@
|
|||
- sysctl_no_value is failed
|
||||
- "sysctl_no_value.msg == 'value cannot be None'"
|
||||
|
||||
- name: Try sysctl with an invalid value
|
||||
- name: Try sysctl with an invalid name
|
||||
sysctl:
|
||||
name: net.ipv4.ip_forward
|
||||
value: foo
|
||||
name: test.invalid
|
||||
value: 1
|
||||
sysctl_set: yes
|
||||
register: sysctl_test4
|
||||
ignore_errors: yes
|
||||
|
|
|
|||
Loading…
Reference in a new issue