Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/iso_customize/tasks/iso_customize.yml

raw
1 # Copyright (c) 2022, Ansible Project
2 # Copyright (c) 2022, VMware, Inc. All Rights Reserved.
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Add a line to the file test02.cfg and make sure it succeed
7 ansible.builtin.lineinfile:
8 path: "{{ test_dir }}/test02.cfg"
9 regexp: "^test"
10 line: "test"
11
12 - name: "Customize ISO file: add file, delete file and change file"
13 community.general.iso_customize:
14 src_iso: "{{ test_dir }}/test.iso"
15 dest_iso: "{{ test_dir }}/{{ dest_iso_name }}"
16 delete_files:
17 - "/test01.cfg"
18 add_files:
19 - src_file: "{{ test_dir }}/test01.cfg"
20 dest_file: "/preseed/ubuntu.seed"
21 - src_file: "{{ test_dir }}/test02.cfg"
22 dest_file: "/test02.cfg"
23
24 - include_tasks: iso_mount.yml
25 vars:
26 iso_name: "{{ dest_iso_name }}"
27
28 - debug: var=mount_root_dir
29
30 - name: Check the file test01.cfg is deleted
31 stat:
32 path: "{{ mount_root_dir }}/test01.cfg"
33 register: check_file
34
35 - assert:
36 that:
37 - check_file.stat.exists == False
38
39 - name: Check the file /preseed/ubuntu.seed is added
40 stat:
41 path: "{{ mount_root_dir }}/preseed/ubuntu.seed"
42 register: check_file
43
44 - assert:
45 that:
46 - check_file.stat.exists == True
47
48 - block:
49 - name: Get the content of file test02.cfg
50 command: "cat {{ mount_root_dir }}/test02.cfg"
51 register: get_file_content
52
53 - set_fact:
54 file_contents: "{{ get_file_content.stdout }}"
55 when: ansible_facts.distribution == 'RedHat' and ansible_facts.distribution_version is version('7.9', '==')
56
57 - name: Get the content of file test02.cfg
58 set_fact:
59 file_contents: "{{ lookup('file', mount_root_dir + '/test02.cfg') }}"
60 when: not (ansible_facts.distribution == 'RedHat' and ansible_facts.distribution_version is version('7.9', '=='))
61
62 - fail: msg="Failed to replace the file test02.cfg"
63 when: file_contents != "test"
64
65 - name: Umount ISO
66 mount:
67 path: "{{ mount_root_dir }}"
68 fstab: "{{ test_dir }}/temp.fstab"
69 state: unmounted
70
71 - name: Delete line of file test02.cfg
72 ansible.builtin.lineinfile:
73 path: "{{ test_dir }}/test02.cfg"
74 regexp: "test"
75 state: absent