Browse Source

Merge pull request #1 from lachie83/feature-add-swap-partition

add swap partition support
tags/2016.12
Jakub Pavlik 9 years ago
parent
commit
950b745cd1
2 changed files with 35 additions and 1 deletions
  1. +13
    -0
      README.rst
  2. +22
    -1
      linux/storage/swap.sls

+ 13
- 0
README.rst View File

@@ -493,6 +493,19 @@ Linux with file swap
device: /swapfile
size: 1024

Linux with partition swap

.. code-block:: yaml

linux:
storage:
enabled: true
swap:
partition:
enabled: true
engine: partition
device: /dev/vg0/swap

LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`

.. code-block:: yaml

+ 22
- 1
linux/storage/swap.sls View File

@@ -5,7 +5,28 @@

{%- if swap.enabled %}

{%- if swap.engine == 'file' %}
{%- if swap.engine == 'partition' %}

linux_create_swap_partition_{{ swap.device }}:
cmd.run:
- name: 'mkswap {{ swap.device }}'
- onlyif: "test `file -L -s {{ swap.device }} | grep 'swap file' >/dev/null;echo $?` -ne 0"
- creates: {{ swap.device }}

linux_set_swap_partition_{{ swap.device }}:
cmd.run:
- name: 'swapon {{ swap.device }}'
- unless: grep $(readlink -f {{ swap.device }}) /proc/swaps
- require:
- cmd: linux_create_swap_partition_{{ swap.device }}

{{ swap.device }}:
mount.swap:
- persist: True
- require:
- cmd: linux_set_swap_partition_{{ swap.device }}

{%- elif swap.engine == 'file' %}

linux_create_swap_file_{{ swap.device }}:
cmd.run:

Loading…
Cancel
Save