-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create LVM on loop device to deploy Openshift Storage
The Openshift Storage that uses topolvm was raising an error, because the Microshift host does not have any LVM device. In previous role stage, we just remove the openshift-storage namespace and storageclass, because the CI tests mostly were using local storage for PV.
- Loading branch information
Showing
5 changed files
with
91 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,69 @@ | ||
--- | ||
# NOTE: The Openshift storage uses topolvm, that requires additional volume, | ||
# which is not necessary for us, due we mostly use that playbook for CI. | ||
- name: Check if openshift-storage namespace exists | ||
ansible.builtin.command: oc get namespace openshift-storage | ||
register: _openshift_storage_ns | ||
failed_when: _openshift_storage_ns.rc not in [0, 1] | ||
|
||
- name: Delete openshift storage namespace | ||
ansible.builtin.command: oc delete namespace openshift-storage | ||
when: _openshift_storage_ns.rc == 0 | ||
|
||
- name: Delete topolvm-provisioner storageclass | ||
ansible.builtin.command: oc delete storageclass topolvm-provisioner | ||
when: _openshift_storage_ns.rc == 0 | ||
- name: Delete openshift-storage if needed | ||
when: delete_openshift_storage | ||
block: | ||
# NOTE: The Openshift storage uses topolvm, that requires additional volume, | ||
# which is not necessary for us, due we mostly use that playbook for CI. | ||
- name: Check if openshift-storage namespace exists | ||
ansible.builtin.command: oc get namespace openshift-storage | ||
register: _openshift_storage_ns | ||
failed_when: _openshift_storage_ns.rc not in [0, 1] | ||
|
||
- name: Delete openshift storage namespace | ||
ansible.builtin.command: oc delete namespace openshift-storage | ||
when: _openshift_storage_ns.rc == 0 | ||
|
||
- name: Delete topolvm-provisioner storageclass | ||
ansible.builtin.command: oc delete storageclass topolvm-provisioner | ||
when: _openshift_storage_ns.rc == 0 | ||
|
||
- name: Create LVM on loop device to deploy openshift storage with topolvm | ||
when: not delete_openshift_storage | ||
block: | ||
- name: Check if file already exists | ||
become: true | ||
stat: | ||
path: "{{ disk_file_path }}" | ||
register: _disk_file | ||
|
||
- name: Create loop disk | ||
when: not _disk_file.stat.exists | ||
block: | ||
- name: Create empty file | ||
become: true | ||
community.general.filesize: | ||
path: "{{ disk_file_path }}" | ||
size: "{{ disk_file_size }}" | ||
|
||
- name: Make partition on empty file | ||
become: true | ||
community.general.parted: | ||
device: "{{ disk_file_path }}" | ||
number: 1 | ||
state: present | ||
flags: ["lvm"] | ||
|
||
- name: Get first available loop device | ||
become: true | ||
ansible.builtin.command: losetup -f | ||
register: loop_device | ||
|
||
- name: Create loop device service | ||
become: true | ||
ansible.builtin.template: | ||
src: microshift-loop-device.service.j2 | ||
dest: /usr/lib/systemd/system/microshift-loop-device.service | ||
|
||
- name: Enable loop device service | ||
become: true | ||
ansible.builtin.systemd: | ||
name: microshift-loop-device | ||
state: started | ||
enabled: true | ||
daemon_reload: true | ||
|
||
- name: Create volume group | ||
become: true | ||
community.general.lvg: | ||
vg: "{{ vg_name }}" | ||
pvs: "{{ loop_device.stdout }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
- git | ||
- golang | ||
- python3-cryptography | ||
- lvm2 | ||
state: present | ||
|
||
- name: Add host to the hosts file | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Unit] | ||
Description=Setup loopback device | ||
DefaultDependencies=no | ||
Conflicts=umount.target | ||
Before=local-fs.target umount.target microshift.service | ||
|
||
[Service] | ||
ExecStart=/sbin/losetup {{ loop_device.stdout }} {{ disk_file_path }} | ||
ExecStop=/sbin/losetup -d {{ loop_device.stdout }} | ||
Type=oneshot | ||
TimeoutSec=60 | ||
RemainAfterExit=yes | ||
|
||
[Install] | ||
WantedBy=local-fs-pre.target | ||
Also=systemd-udevd.service |