diff options
| author | Michal Nasiadka <mnasiadka@gmail.com> | 2023-10-27 12:28:01 +0200 |
|---|---|---|
| committer | Michal Nasiadka <mnasiadka@gmail.com> | 2023-11-08 09:57:32 +0000 |
| commit | 213e53e18a37fae0b5b71ba51ef6121a75dc5786 (patch) | |
| tree | deb55908d913073ae2fd7c8e140d3061e5ede33b /roles | |
| parent | 5e7e80fd8828b6614fedc46cc967fe786e780219 (diff) | |
| download | kolla-213e53e18a37fae0b5b71ba51ef6121a75dc5786.tar.gz kolla-213e53e18a37fae0b5b71ba51ef6121a75dc5786.zip | |
CI: Move ephemeral disk config to a role
Change-Id: Ieee71aa22f4ec45fe03f50fd697c85dda952b4d0
Diffstat (limited to 'roles')
| -rw-r--r-- | roles/configure-ephemeral/defaults/main.yml | 2 | ||||
| -rw-r--r-- | roles/configure-ephemeral/tasks/main.yml | 70 |
2 files changed, 72 insertions, 0 deletions
diff --git a/roles/configure-ephemeral/defaults/main.yml b/roles/configure-ephemeral/defaults/main.yml new file mode 100644 index 000000000..5879e49e1 --- /dev/null +++ b/roles/configure-ephemeral/defaults/main.yml @@ -0,0 +1,2 @@ +--- +configure_ephemeral_mountpoint: "/var/lib/docker" diff --git a/roles/configure-ephemeral/tasks/main.yml b/roles/configure-ephemeral/tasks/main.yml new file mode 100644 index 000000000..8fe7d6f63 --- /dev/null +++ b/roles/configure-ephemeral/tasks/main.yml @@ -0,0 +1,70 @@ +--- +# On RAX hosts, we have a small root partition and a large, +# unallocated ephemeral device attached at /dev/xvde +- name: Set ephemeral device if /dev/xvde exists + when: ansible_devices["xvde"] is defined + set_fact: + ephemeral_device: "/dev/xvde" + +# On other providers, we have a device called "ephemeral0". +- name: Set ephemeral device by label + when: ephemeral_device is undefined + block: + - name: Get ephemeral0 device node + command: /sbin/blkid -L ephemeral0 + register: ephemeral0 + # rc !=0 is expected + failed_when: False + changed_when: False + + - name: Set ephemeral device if LABEL exists + when: "ephemeral0.rc == 0" + set_fact: + ephemeral_device: "{{ ephemeral0.stdout }}" + +- name: Configure additional disk (if available) + become: true + when: ephemeral_device is defined + block: + - name: Ensure ephemeral device is unmounted + ansible.posix.mount: + name: "{{ ephemeral_device }}" + state: "{{ item }}" + loop: + - unmounted + - absent + + - name: Get existing partitions + community.general.parted: + device: "{{ ephemeral_device }}" + unit: MiB + state: info + register: ephemeral_partitions + + - name: Remove any existing partitions + community.general.parted: + device: "{{ ephemeral_device }}" + number: "{{ item.num }}" + state: absent + loop: "{{ ephemeral_partitions.partitions }}" + + - name: Create filesystem on additional disk + community.general.filesystem: + fstype: ext4 + dev: "{{ ephemeral_device }}" + opts: "-L kolla" + + - name: "Ensure {{ configure_ephemeral_mountpoint }} mountpoint is created" + ansible.builtin.file: + path: "{{ configure_ephemeral_mountpoint }}" + owner: root + group: root + state: directory + mode: 0755 + + - name: Mount additional filesystem + ansible.posix.mount: + path: "{{ configure_ephemeral_mountpoint }}" + src: "LABEL=kolla" + fstype: ext4 + state: mounted |
