036cf2733c
This, alongside the "df -h" output, may provide some useful information about the /opt content (not as precise as a `du -shxc /opt', but at least it's already something). It can then be compared with the existing `df -h' information located in the zuul-info/ directory. The goal here is to understand the actual impact of this task. Change-Id: I201eba6ec6db9f0caaaabb0a3d15b0894125c7d6
132 lines
3.2 KiB
YAML
132 lines
3.2 KiB
YAML
---
|
|
|
|
# Configure attached ephemeral devices for storage and swap
|
|
|
|
- name: Assert that ephemeral_device is defined
|
|
assert:
|
|
that:
|
|
- "ephemeral_device is defined"
|
|
|
|
- name: Set partition names
|
|
set_fact:
|
|
swap_partition: "{{ ephemeral_device }}1"
|
|
opt_partition: "{{ ephemeral_device }}2"
|
|
|
|
- name: Ensure ephemeral device is unmounted
|
|
become: yes
|
|
mount:
|
|
name: "{{ ephemeral_device }}"
|
|
state: "{{ item }}"
|
|
with_items:
|
|
- unmounted
|
|
- absent
|
|
# ^ https://github.com/ansible/ansible/issues/48313
|
|
|
|
- name: Get existing partitions
|
|
become: yes
|
|
parted:
|
|
device: "{{ ephemeral_device }}"
|
|
unit: MiB
|
|
register: ephemeral_partitions
|
|
|
|
- name: Remove any existing partitions
|
|
become: yes
|
|
parted:
|
|
device: "{{ ephemeral_device }}"
|
|
number: "{{ item.num }}"
|
|
state: absent
|
|
with_items:
|
|
- "{{ ephemeral_partitions.partitions }}"
|
|
|
|
- name: Create new disk label
|
|
become: yes
|
|
parted:
|
|
label: msdos
|
|
device: "{{ ephemeral_device }}"
|
|
|
|
- name: Create swap partition
|
|
become: yes
|
|
parted:
|
|
device: "{{ ephemeral_device }}"
|
|
number: 1
|
|
state: present
|
|
part_start: '0%'
|
|
part_end: "{{ configure_swap_size }}MiB"
|
|
|
|
- name: Create opt partition
|
|
become: yes
|
|
parted:
|
|
device: "{{ ephemeral_device }}"
|
|
number: 2
|
|
state: present
|
|
part_start: "{{ configure_swap_size }}MiB"
|
|
part_end: "100%"
|
|
|
|
- name: Make swap on partition
|
|
become: yes
|
|
command: "mkswap {{ swap_partition }}"
|
|
|
|
- name: Write swap to fstab
|
|
become: yes
|
|
mount:
|
|
path: none
|
|
src: "{{ swap_partition }}"
|
|
fstype: swap
|
|
opts: sw
|
|
passno: 0
|
|
dump: 0
|
|
state: present
|
|
|
|
# XXX: does "parted" plugin ensure the partition is available
|
|
# before moving on? No udev settles here ...
|
|
|
|
- name: Add all swap
|
|
become: yes
|
|
command: swapon -a
|
|
|
|
- name: Create /opt filesystem
|
|
become: yes
|
|
filesystem:
|
|
fstype: ext4
|
|
# The default ratio is 16384 bytes per inode or so. Reduce that to 8192
|
|
# bytes per inode so that we get roughly twice the number of inodes as
|
|
# by default. This should still be well above the block size of 4096.
|
|
# We do this because we have found in at least a couple locations that
|
|
# more inodes is useful and is painful to fix after the fact.
|
|
opts: -i 8192
|
|
dev: "{{ opt_partition }}"
|
|
|
|
# Rackspace at least does not have enough room for two devstack
|
|
# installs on the primary partition. We copy in the existing /opt to
|
|
# the new partition on the ephemeral device, and then overmount /opt
|
|
# to there for the test runs.
|
|
#
|
|
# NOTE(ianw): the existing "mount" touches fstab. There is currently (Sep2017)
|
|
# work in [1] to split mount & fstab into separate parts, but for now we bundle
|
|
# it into an atomic shell command
|
|
# [1] https://github.com/ansible/ansible/pull/27174
|
|
- name: Copy old /opt
|
|
become: yes
|
|
register: moving_opt
|
|
shell: |
|
|
mount {{ opt_partition }} /mnt
|
|
find /opt/ -mindepth 1 -maxdepth 1 -print -exec mv {} /mnt/ \;
|
|
umount /mnt
|
|
df -h
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Output data from old /opt
|
|
debug:
|
|
var: moving_opt
|
|
|
|
# This overmounts any existing /opt
|
|
- name: Add opt to fstab and mount
|
|
become: yes
|
|
mount:
|
|
path: /opt
|
|
src: "{{ opt_partition }}"
|
|
fstype: ext4
|
|
opts: noatime
|
|
state: mounted
|