1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/iso_customize/tasks/iso_customize_exception.yml

82 lines
3.1 KiB
YAML
Raw Normal View History

New module: iso_customize (#5190) (#5346) * add ansible module iso_customize.py * rerun CI testing due to "Failed to send request to https://api.github.com/repos/ansible/ansible/issues/23642: HTTP Error 403: rate limit exceeded" * Rerun CI testing due to "Failed to send request to https://api.github....." * rerun CI testing due to failure "Unknown error when attempting to call Galaxy at 'https://galaxy.ansible.com/api/v2/collections/netbox/netbox/versions/3.1.0/': The read operation timed out" * change document part as felixfontein's careful review * modify test file as russoz's comments * modify comment part of module * add comment for the example * add more tests: check the files are deleted / added in customized ISO * fix it: failed to run ansible.posix.mount in ubuntu * fix it: ansible.posix.mount is not working well in some OS. * change DOCUMENTATION part * change files according to the comment from code review * fix issue: E231: missing whitespace after ':' * modify the description of Document * modify code for code review * delete extra blank line in yml file * Try to fix CI testing issue: "Caught \"'foo' is undefined. 'foo' is undefined\" while evaluating 'b' with item == {'a': 1}" * delete extra blank line in the end of file * change code as the comment from code review * change code from code review * change type: str to type: path * change type:str to type:path * delete unused variable * fix CI testing error: return-syntax-error: RETURN.dest_iso.type: not a valid value for dictionary value @ data['dest_iso']['type']. Got 'path' * add testcase: test add files / delete files separately * add more testcases: test if we can catch exception from error input of users * change code from code review * fix issue: E231: missing whitespace after ',' * change code from code review * add notes to document * modify notes in document part * /rebuild_failed /rebuild_failed * Try to support running testcases not only in MAC but also in other OS. * modify document * change mount to ansible.posix.mount * skip the test platform which report "Error mounting" * fix mount failed: Operation not permitted * change code from code review * change document from code review * fix CI testing issue in some platforms * Update plugins/modules/files/iso_customize.py * change code from code review 1) change testcase 2) try to fix "mount: not permitted" * modify aliases file * change document and rerun CI testing * add skip/docker as suggested * add debug task * fix issue in redhat 7.9: occurred while running the lookup plugin 'file'. ..could not locate file in lookup.. * change code from the code review * modify function "iso_rr_check_file_exist" to "iso_check_file_exists" to make it works in all types of ISO 1. modify function "iso_rr_check_file_exist" to "iso_check_file_exists" to make it works in all types of ISO 2. run main.yml with newer python 3.10.6 ansible [core 2.13.4] config file = None configured module search path = ['/Users/zouy/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/Cellar/ansible/6.4.0/libexec/lib/python3.10/site-packages/ansible ansible collection location = /Users/zouy/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible python version = 3.10.6 (main, Aug 30 2022, 05:12:36) [Clang 13.1.6 (clang-1316.0.21.2.5)] jinja version = 3.1.2 libyaml = True * delete blank * simply the code as suggested. * Two small docs updates. Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit d76392ed2a1b5b08097e1f5ae780d031f9d1adf3) Co-authored-by: Yuhua Zou <41054978+ZouYuhua@users.noreply.github.com>
2022-10-10 23:08:49 +02:00
# Copyright (c) 2022, Ansible Project
# Copyright (c) 2022, VMware, Inc. All Rights Reserved.
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: "Testcase: local resource ISO does not exists"
community.general.iso_customize:
src_iso: "{{ test_dir }}/test11.iso"
dest_iso: "{{ test_dir }}/{{ dest_iso_name }}"
register: customized_result
failed_when: customized_result.msg.find('does not exist') == -1
- name: "Testcase:: dest dir does not exists"
community.general.iso_customize:
src_iso: "{{ test_dir }}/test1.iso"
dest_iso: "/aaa/{{ dest_iso_name }}"
register: customized_result
failed_when: customized_result.msg.find('does not exist') == -1
# Test: Get MODULE FAILURE when no add files data and no delete files data
- name: "Testcase:: no add files data and no delete files data"
community.general.iso_customize:
src_iso: "{{ test_dir }}/test1.iso"
dest_iso: "{{ test_dir }}/iso_customize_nodata.iso"
delete_files:
add_files:
register: customized_result
failed_when: customized_result.msg.find("MODULE FAILURE") == -1
# Test: nothing is changed when no options "add files" and "delete files"
- block:
- name: "Testcase: no options 'add files' and 'delete files'"
community.general.iso_customize:
src_iso: "{{ test_dir }}/test1.iso"
dest_iso: "{{ test_dir }}/iso_customize_nochanged.iso"
- name: Get stats of a file test1.iso
ansible.builtin.stat:
path: "{{ test_dir }}/test1.iso"
register: iso_orginal
- name: Get stats of a file iso_customize_nochanged.iso
ansible.builtin.stat:
path: "{{ test_dir }}/iso_customize_nochanged.iso"
register: iso_customized
- name: compare size
fail: msg="Check we have nothing changed for customized ISO"
when: iso_orginal.stat.size != iso_customized.stat.size
- name: "Testcase: delete the non-existing file in ISO"
community.general.iso_customize:
src_iso: "{{ test_dir }}/test1.iso"
dest_iso: "{{ test_dir }}/{{ dest_iso_name }}"
delete_files:
- "/test03.cfg"
register: customized_result
failed_when: customized_result.msg.find("does not exist") == -1
# Test: failed when local src file does not exists
- name: "Testcase: local src file does not exists"
community.general.iso_customize:
src_iso: "{{ test_dir }}/test.iso"
dest_iso: "{{ test_dir }}/{{ dest_iso_name }}"
add_files:
- src_file: "{{ test_dir }}/test03.cfg"
dest_file: "/preseed/ubuntu.seed"
register: customized_result
failed_when: customized_result.msg.find("does not exist") == -1
# Test: filenames with whitespaces
# We report error: the user should be reponsible for the it
- name: "Testcase: filenames with whitespaces"
community.general.iso_customize:
src_iso: "{{ test_dir }}/test.iso"
dest_iso: "{{ test_dir }}/{{ dest_iso_name }}"
add_files:
- src_file: " {{ test_dir }}/test01.cfg "
dest_file: "/preseed/ubuntu.seed"
register: customized_result
failed_when: customized_result.msg.find("does not exist") == -1