Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/filesystem/tasks/create_fs.yml

raw
1 ---
2 # Copyright (c) Ansible Project
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: "Create filesystem ({{ fstype }})"
7 community.general.filesystem:
8 dev: '{{ dev }}'
9 fstype: '{{ fstype }}'
10 register: fs_result
11
12 - name: "Assert that results are as expected"
13 ansible.builtin.assert:
14 that:
15 - 'fs_result is changed'
16 - 'fs_result is success'
17
18 - name: "Get UUID of created filesystem"
19 ansible.builtin.shell:
20 cmd: "{{ get_uuid_cmd }}"
21 changed_when: false
22 register: uuid
23
24 - name: "Check that filesystem isn't created if force isn't used"
25 community.general.filesystem:
26 dev: '{{ dev }}'
27 fstype: '{{ fstype }}'
28 register: fs2_result
29
30 - name: "Get UUID of the filesystem"
31 ansible.builtin.shell:
32 cmd: "{{ get_uuid_cmd }}"
33 changed_when: false
34 register: uuid2
35
36 - name: "Assert that filesystem UUID is not changed"
37 ansible.builtin.assert:
38 that:
39 - 'fs2_result is not changed'
40 - 'fs2_result is success'
41 - 'uuid.stdout == uuid2.stdout'
42
43 - name: "Check that filesystem is recreated if force is used"
44 community.general.filesystem:
45 dev: '{{ dev }}'
46 fstype: '{{ fstype }}'
47 force: true
48 register: fs3_result
49
50 - name: "Get UUID of the new filesystem"
51 ansible.builtin.shell:
52 cmd: "{{ get_uuid_cmd }}"
53 changed_when: false
54 register: uuid3
55
56 - name: "Assert that filesystem UUID is changed"
57 # libblkid gets no UUID at all for this fstype on FreeBSD
58 when: not (ansible_facts.system == 'FreeBSD' and fstype == 'reiserfs')
59 ansible.builtin.assert:
60 that:
61 - 'fs3_result is changed'
62 - 'fs3_result is success'
63 - 'uuid.stdout != uuid3.stdout'
64
65
66 - when: 'grow|bool and (fstype != "vfat" or resize_vfat)'
67 block:
68 - name: "Increase fake device"
69 community.general.filesize:
70 path: '{{ image_file }}'
71 size: '{{ fssize | int + 1 }}M'
72
73 - name: "Resize loop device for LVM"
74 ansible.builtin.command:
75 cmd: 'losetup -c {{ dev }}'
76 when: fstype == 'lvm'
77
78 - name: "Resize memory disk for UFS"
79 ansible.builtin.command:
80 cmd: 'mdconfig -r -u {{ dev }} -s {{ fssize | int + 1 }}M'
81 when: fstype == 'ufs'
82
83 - name: "Expand filesystem"
84 community.general.filesystem:
85 dev: '{{ dev }}'
86 fstype: '{{ fstype }}'
87 resizefs: true
88 register: fs4_result
89
90 - name: "Get UUID of the filesystem"
91 ansible.builtin.shell:
92 cmd: "{{ get_uuid_cmd }}"
93 changed_when: false
94 register: uuid4
95
96 - name: "Assert that filesystem UUID is not changed"
97 ansible.builtin.assert:
98 that:
99 - 'fs4_result is changed'
100 - 'fs4_result is success'
101 - 'uuid3.stdout == uuid4.stdout' # unchanged
102
103 - when:
104 - (grow | bool and (fstype != "vfat" or resize_vfat)) or
105 (fstype == "xfs" and ansible_facts.system == "Linux" and
106 ansible_facts.distribution not in ["CentOS", "Ubuntu"])
107 block:
108 - name: "Check that resizefs does nothing if device size is not changed"
109 community.general.filesystem:
110 dev: '{{ dev }}'
111 fstype: '{{ fstype }}'
112 resizefs: true
113 register: fs5_result
114
115 - name: "Assert that the state did not change"
116 ansible.builtin.assert:
117 that:
118 - 'fs5_result is not changed'
119 - 'fs5_result is succeeded'