Skip to content

Instantly share code, notes, and snippets.

@dmsimard dmsimard/playbook.yml
Last active May 30, 2019

Embed
What would you like to do?
Fix disk layout
---
- hosts: all
gather_facts: yes
vars_files:
- devstack_gate_vars.yaml
pre_tasks:
# Note (dmsimard)
# If some swap is already set up, the amount is not 100% accurate
# (ex: 8191MB swap for a 8192MB file)
- name: Configure swap
include_role:
name: "configure_swap"
when: ansible_memory_mb['swap']['total'] | int + 10 <= SWAP_SIZE
roles:
- gather_host_info
- fix_etc_hosts
- create_base_folder
- start_fresh_logging
- setup_stack_user
- setup_tempest_user
- copy_mirror_config
- network_sanity_check
- name: Set ephemeral device if /dev/xvde exists
set_fact:
ephemeral_device: "/dev/xvde"
when: "/dev/xvde" in ansible_devices
- block:
when: ephemeral_device is undefined
# TODO: Add the filesystem label to ansible_mounts fact
# i.e, https://github.com/ansible/ansible/blob/7b73ee0818a4fa3b3155b45deb8f60e8b7a72cdf/lib/ansible/module_utils/facts/hardware/linux.py#L332
- name: Look if ephemeral0 device exists
command: blkid
register: blkid
- name: Set ephemeral device if ephemeral0 exists
set_fact:
ephemeral_device: "{{ lookup('pipe', 'blkid -L ephemeral0') }}"
when: "ephemeral0" in blkd.stdout
- block:
when: ephemeral device is defined
vars:
swap_partition: "{{ ephemeral_device }}1"
lvm_partition: "{{ ephemeral_device }}2"
opt_partition: "{{ ephemeral_device }}3"
- name: Ensure the ephemeral device is unmounted
mount:
name: "{{ ephemeral_device }}"
state: unmounted
# [...]
@manishshukla4u

This comment has been minimized.

Copy link

manishshukla4u commented May 30, 2019

I want to configure swap using disk where lvm module will create swap vm conditional. Lets say swap vol would be 2x memory when memory is <=4G, 1x memory from 4G-16G and 16G when memory is > 16G. What are your suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.