Compare commits

...

16 commits

Author SHA1 Message Date
Mandar Kulkarni
0411d0eac9
Merge 99585a9696 into 2f699307c7 2023-11-17 23:19:16 +00:00
softwarefactory-project-zuul[bot]
2f699307c7
Merge pull request #508 from saito-hideki/pr/refactoring_ci_remote
[CI] Refactoring CI tests for both remote and container tests

SUMMARY
Refactored CI tests:

Remove tests for Ansible Core 2.10 and 2.11 that already reached EOL.
Remote test target of ansible.posix will be the latest version of RHEL8,9 only.
The target OS of container tests has been modified, and a few OS have been removed
Add Ansible Core 2.16 and new devel branch to container and remote test target.
#506

For CI testing, other platforms can be added as needed.
ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2023-11-16 04:34:53 +00:00
Hideki Saito
7dd5087e7b Refactoring remote and docker CI tests.
* Removed tests for Ansible Core 2.10 and 2.11 fromn remote and container targets
* Modoifed remote and container test target OS
* Fixed #506

Signed-off-by: Hideki Saito <saito@fgrep.org>
2023-11-16 11:56:08 +09:00
Mandar Kulkarni
99585a9696
Update at.py 2021-08-04 23:46:54 -07:00
Mandar Kulkarni
c7d610b662 Skipping tests for CentOS 6 2021-07-06 11:53:09 -07:00
Mandar Kulkarni
8788d4d103 Updating condition for a test 2021-07-05 15:49:49 -07:00
Mandar Kulkarni
12d3db3414 Update main.yml 2021-07-02 15:54:30 -07:00
Mandar Kulkarni
a18fce2f3a Update main.yml 2021-07-02 15:11:08 -07:00
Mandar Kulkarni
b8fcfdd247 Update main.yml 2021-07-02 08:58:21 -07:00
Mandar Kulkarni
faf1ea4132 Fix assertion 2021-07-01 17:43:16 -07:00
Mandar Kulkarni
3206c5c1b7
Merge branch 'ansible-collections:main' into module-at-add-chdir 2021-07-01 19:57:25 -04:00
Baptiste Mille-Mathias
17f8c02361 Update changelogs/fragments/102_module_at_add_chdir_option.yml
Co-authored-by: quidame <quidame@poivron.org>
2021-06-16 16:09:39 +05:30
Baptiste Mille-Mathias
ceaee68c85 Update plugins/modules/at.py
Co-authored-by: quidame <quidame@poivron.org>
2021-06-16 16:00:57 +05:30
Baptiste Mille-Mathias
09299f1b9a Update version_added
Co-authored-by: quidame <quidame@poivron.org>
2021-06-16 16:00:57 +05:30
Baptiste Mille-Mathias
a699771c87 add chdir option to define a directory from where to run the at command 2021-06-16 16:00:57 +05:30
Baptiste Mille-Mathias
269c66fbdb Add a test for removal of at command 2021-06-16 16:00:57 +05:30
6 changed files with 146 additions and 137 deletions

View file

@ -51,16 +51,29 @@ stages:
parameters: parameters:
testFormat: devel/linux/{0}/1 testFormat: devel/linux/{0}/1
targets: targets:
- name: CentOS 7
test: centos7
- name: Fedora 38 - name: Fedora 38
test: fedora38 test: fedora38
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 20.04 - name: Ubuntu 20.04
test: ubuntu2004 test: ubuntu2004
- name: Ubuntu 22.04 - name: Ubuntu 22.04
test: ubuntu2204 test: ubuntu2204
- stage: Docker_2_16
displayName: Docker 2.16
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.16/linux/{0}/1
targets:
- name: CentOS 7
test: centos7
- name: Fedora 38
test: fedora38
- name: Ubuntu 20.04
test: ubuntu2004
- name: Ubuntu 22.04
test: ubuntu2204
- stage: Docker_2_15 - stage: Docker_2_15
displayName: Docker 2.15 displayName: Docker 2.15
dependsOn: [] dependsOn: []
@ -141,44 +154,6 @@ stages:
test: ubuntu1804 test: ubuntu1804
- name: Ubuntu 20.04 - name: Ubuntu 20.04
test: ubuntu2004 test: ubuntu2004
- stage: Docker_2_11
displayName: Docker 2.11
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.11/linux/{0}/1
targets:
- name: CentOS 6
test: centos6
- name: CentOS 7
test: centos7
- name: openSUSE 15 py2
test: opensuse15py2
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 18.04
test: ubuntu1804
- stage: Docker_2_10
displayName: Docker 2.10
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.10/linux/{0}/1
targets:
- name: CentOS 6
test: centos6
- name: CentOS 7
test: centos7
- name: openSUSE 15 py2
test: opensuse15py2
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 16.04
test: ubuntu1604
- name: Ubuntu 18.04
test: ubuntu1804
- stage: Docker_2_9 - stage: Docker_2_9
displayName: Docker 2.9 displayName: Docker 2.9
dependsOn: [] dependsOn: []
@ -209,16 +184,21 @@ stages:
parameters: parameters:
testFormat: devel/{0}/1 testFormat: devel/{0}/1
targets: targets:
- name: MacOS 13.2 - name: RHEL 9.3
test: macos/13.2 test: rhel/9.3
- name: RHEL 7.9 - stage: Remote_2_16
test: rhel/7.9 displayName: Remote 2.16
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.16/{0}/1
targets:
- name: RHEL 8.8 - name: RHEL 8.8
test: rhel/8.8 test: rhel/8.8
- name: RHEL 9.2 - name: RHEL 9.2
test: rhel/9.2 test: rhel/9.2
- name: FreeBSD 13.2
test: freebsd/13.2
- stage: Remote_2_15 - stage: Remote_2_15
displayName: Remote 2.15 displayName: Remote 2.15
dependsOn: [] dependsOn: []
@ -227,18 +207,12 @@ stages:
parameters: parameters:
testFormat: 2.15/{0}/1 testFormat: 2.15/{0}/1
targets: targets:
- name: MacOS 13.2
test: macos/13.2
- name: RHEL 7.9 - name: RHEL 7.9
test: rhel/7.9 test: rhel/7.9
- name: RHEL 8.7 - name: RHEL 8.7
test: rhel/8.7 test: rhel/8.7
- name: RHEL 9.1 - name: RHEL 9.1
test: rhel/9.1 test: rhel/9.1
- name: FreeBSD 12.4
test: freebsd/12.4
- name: FreeBSD 13.1
test: freebsd/13.1
- stage: Remote_2_14 - stage: Remote_2_14
displayName: Remote 2.14 displayName: Remote 2.14
dependsOn: [] dependsOn: []
@ -247,18 +221,10 @@ stages:
parameters: parameters:
testFormat: 2.14/{0}/1 testFormat: 2.14/{0}/1
targets: targets:
- name: MacOS 12.0
test: macos/12.0
- name: RHEL 7.9 - name: RHEL 7.9
test: rhel/7.9 test: rhel/7.9
- name: RHEL 8.6 - name: RHEL 8.6
test: rhel/8.6 test: rhel/8.6
- name: RHEL 9.0
test: rhel/9.0
- name: FreeBSD 12.3
test: freebsd/12.3
- name: FreeBSD 13.1
test: freebsd/13.1
- stage: Remote_2_13 - stage: Remote_2_13
displayName: Remote 2.13 displayName: Remote 2.13
dependsOn: [] dependsOn: []
@ -267,16 +233,10 @@ stages:
parameters: parameters:
testFormat: 2.13/{0}/1 testFormat: 2.13/{0}/1
targets: targets:
- name: MacOS 12.0
test: macos/12.0
- name: RHEL 7.9 - name: RHEL 7.9
test: rhel/7.9 test: rhel/7.9
- name: RHEL 8.5 - name: RHEL 8.5
test: rhel/8.5 test: rhel/8.5
- name: FreeBSD 12.3
test: freebsd/12.3
- name: FreeBSD 13.0
test: freebsd/13.0
- stage: Remote_2_12 - stage: Remote_2_12
displayName: Remote 2.12 displayName: Remote 2.12
dependsOn: [] dependsOn: []
@ -285,40 +245,10 @@ stages:
parameters: parameters:
testFormat: 2.12/{0}/1 testFormat: 2.12/{0}/1
targets: targets:
- name: MacOS 11.1
test: macos/11.1
- name: RHEL 7.9 - name: RHEL 7.9
test: rhel/7.9 test: rhel/7.9
- name: RHEL 8.4 - name: RHEL 8.4
test: rhel/8.4 test: rhel/8.4
- name: FreeBSD 13.0
test: freebsd/13.0
- stage: Remote_2_11
displayName: Remote 2.11
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.11/{0}/1
targets:
- name: MacOS 11.1
test: macos/11.1
- name: RHEL 7.9
test: rhel/7.9
- name: RHEL 8.3
test: rhel/8.3
- stage: Remote_2_10
displayName: Remote 2.10
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.10/{0}/1
targets:
- name: RHEL 7.9
test: rhel/7.9
- name: RHEL 8.2
test: rhel/8.2
- stage: Remote_2_9 - stage: Remote_2_9
displayName: Remote 2.9 displayName: Remote 2.9
dependsOn: [] dependsOn: []
@ -339,10 +269,6 @@ stages:
dependsOn: dependsOn:
- Remote_2_9 - Remote_2_9
- Docker_2_9 - Docker_2_9
- Remote_2_10
- Docker_2_10
- Remote_2_11
- Docker_2_11
- Remote_2_12 - Remote_2_12
- Docker_2_12 - Docker_2_12
- Remote_2_13 - Remote_2_13
@ -351,6 +277,8 @@ stages:
- Docker_2_14 - Docker_2_14
- Remote_2_15 - Remote_2_15
- Docker_2_15 - Docker_2_15
- Remote_2_16
- Docker_2_16
- Remote_devel - Remote_devel
- Docker_devel - Docker_devel
jobs: jobs:

View file

@ -0,0 +1,2 @@
minor_changes:
- at - add option ``chdir`` to permit to launch the ``at`` command from a specific directory (https://github.com/ansible-collections/ansible.posix/issues/13).

View file

@ -0,0 +1,3 @@
---
trivial:
- "Refactoring remote CI targets."

View file

@ -17,6 +17,12 @@ description:
- All jobs are executed in the 'a' queue. - All jobs are executed in the 'a' queue.
version_added: "1.0.0" version_added: "1.0.0"
options: options:
chdir:
description:
- An optional location from where to run the command C(at).
- Useful for instance when running a playbook using ansible-pull with C(purge) option.
type: path
version_added: 1.3.0
command: command:
description: description:
- A command to be executed in the future. - A command to be executed in the future.
@ -78,32 +84,32 @@ import tempfile
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
def add_job(module, result, at_cmd, count, units, command, script_file): def add_job(module, result, at_cmd, count, units, command, script_file, chdir=None):
at_command = "%s -f %s now + %s %s" % (at_cmd, script_file, count, units) at_command = "%s -f %s now + %s %s" % (at_cmd, script_file, count, units)
rc, out, err = module.run_command(at_command, check_rc=True) rc, out, err = module.run_command(at_command, cwd=chdir, check_rc=True)
if command: if command:
os.unlink(script_file) os.unlink(script_file)
result['changed'] = True result['changed'] = True
def delete_job(module, result, at_cmd, command, script_file): def delete_job(module, result, at_cmd, command, script_file, chdir=None):
for matching_job in get_matching_jobs(module, at_cmd, script_file): for matching_job in get_matching_jobs(module, at_cmd, script_file):
at_command = "%s -r %s" % (at_cmd, matching_job) at_command = "%s -r %s" % (at_cmd, matching_job)
rc, out, err = module.run_command(at_command, check_rc=True) rc, out, err = module.run_command(at_command, cwd=chdir, check_rc=True)
result['changed'] = True result['changed'] = True
if command: if command:
os.unlink(script_file) os.unlink(script_file)
module.exit_json(**result) module.exit_json(**result)
def get_matching_jobs(module, at_cmd, script_file): def get_matching_jobs(module, at_cmd, script_file, chdir=None):
matching_jobs = [] matching_jobs = []
atq_cmd = module.get_bin_path('atq', True) atq_cmd = module.get_bin_path('atq', True)
# Get list of job numbers for the user. # Get list of job numbers for the user.
atq_command = "%s" % atq_cmd atq_command = "%s" % atq_cmd
rc, out, err = module.run_command(atq_command, check_rc=True) rc, out, err = module.run_command(atq_command, cwd=chdir, check_rc=True)
current_jobs = out.splitlines() current_jobs = out.splitlines()
if len(current_jobs) == 0: if len(current_jobs) == 0:
return matching_jobs return matching_jobs
@ -118,7 +124,7 @@ def get_matching_jobs(module, at_cmd, script_file):
split_current_job = current_job.split() split_current_job = current_job.split()
at_opt = '-c' if platform.system() != 'AIX' else '-lv' at_opt = '-c' if platform.system() != 'AIX' else '-lv'
at_command = "%s %s %s" % (at_cmd, at_opt, split_current_job[0]) at_command = "%s %s %s" % (at_cmd, at_opt, split_current_job[0])
rc, out, err = module.run_command(at_command, check_rc=True) rc, out, err = module.run_command(at_command, cwd=chdir, check_rc=True)
if script_file_string in out: if script_file_string in out:
matching_jobs.append(split_current_job[0]) matching_jobs.append(split_current_job[0])
@ -139,6 +145,7 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
command=dict(type='str'), command=dict(type='str'),
chdir=dict(type='path'),
script_file=dict(type='str'), script_file=dict(type='str'),
count=dict(type='int'), count=dict(type='int'),
units=dict(type='str', choices=['minutes', 'hours', 'days', 'weeks']), units=dict(type='str', choices=['minutes', 'hours', 'days', 'weeks']),
@ -152,6 +159,7 @@ def main():
at_cmd = module.get_bin_path('at', True) at_cmd = module.get_bin_path('at', True)
chdir = module.params['chdir']
command = module.params['command'] command = module.params['command']
script_file = module.params['script_file'] script_file = module.params['script_file']
count = module.params['count'] count = module.params['count']
@ -173,7 +181,7 @@ def main():
# if absent remove existing and return # if absent remove existing and return
if state == 'absent': if state == 'absent':
delete_job(module, result, at_cmd, command, script_file) delete_job(module, result, at_cmd, command, script_file, chdir=chdir)
# if unique if existing return unchanged # if unique if existing return unchanged
if unique: if unique:
@ -186,7 +194,7 @@ def main():
result['count'] = count result['count'] = count
result['units'] = units result['units'] = units
add_job(module, result, at_cmd, count, units, command, script_file) add_job(module, result, at_cmd, count, units, command, script_file, chdir=chdir)
module.exit_json(**result) module.exit_json(**result)

View file

@ -1,3 +1,2 @@
shippable/posix/group1 shippable/posix/group1
destructive destructive
disabled # fixme package

View file

@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- set_fact: output_dir_test={{output_dir}}/at - set_fact: output_dir_test={{output_dir}}/at
- name: make sure our testing sub-directory does not exist - name: make sure our testing sub-directory does not exist
@ -28,35 +29,103 @@
## at ## at
## ##
- name: define distros to attempt installing at on - name: Run At tests
set_fact: block:
package_distros: - name: define distros to attempt installing at on
- RedHat set_fact:
- CentOS package_distros:
- ScientificLinux - RedHat
- Fedora - CentOS
- Ubuntu - ScientificLinux
- Debian - Fedora
- openSUSE Leap - Ubuntu
- Debian
- openSUSE Leap
- name: ensure at is installed - name: ensure at is installed
package: package:
name: at name: at
state: present state: present
when: ansible_distribution in package_distros when: ansible_distribution in package_distros
- name: run the first example - name: run the first example
at: at:
command: "ls -d / > /dev/null" command: "ls -d / > /dev/null"
count: 20 count: 20
units: minutes units: minutes
register: at_test0 register: at_test0
- debug: var=at_test0
- name: validate results - debug: var=at_test0
assert:
that: - name: validate results
assert:
that:
- 'at_test0.changed is defined' - 'at_test0.changed is defined'
- 'at_test0.count is defined' - 'at_test0.count is defined'
- 'at_test0.script_file is defined' - 'at_test0.script_file is defined'
- 'at_test0.state is defined' - 'at_test0.state is defined'
- 'at_test0.units is defined' - 'at_test0.units is defined'
- name: Add a useless command using at
at:
command: /bin/logger 'AT task ran from Ansible'
count: 1
units: minutes
unique: yes
register: at_add
- debug: var=at_add
- name: Wait for at to run the previous command
pause:
minutes: 1
- name: Add a useless command
at:
command: /bin/logger 'AT task ran from Ansible'
count: 1
units: minutes
unique: true
state: absent
register: at_removal
- debug: var=at_removal
- name: Wait for at to run the previous command
pause:
minutes: 1
- name: Validate results
assert:
that:
- at_add is changed
- at_removal is changed
- name: Create an at command with chdir with valid value
at:
command: /bin/logger 'AT task ran from Ansible with chdir'
count: 1
units: minutes
chdir: /tmp
register: at_chdir_valid
- debug: var=at_chdir_valid
- name: Create an at command with chdir with invalid value
at:
command: /bin/logger 'AT task ran from Ansible with chdir'
count: 1
units: minutes
chdir: /invalid
register: at_chdir_invalid
ignore_errors: true
- debug: var=at_chdir_invalid
- name: Validate results
assert:
that:
- at_chdir_valid is changed
- at_chdir_invalid is changed
when:
- not (ansible_facts['distribution'] in ('Ubuntu','FreeBSD'))
- not (ansible_distribution == "CentOS" and ansible_distribution_version is version('6', '=='))