b6fef79fd0bd8be5c4a4ba107b5ac9a807a83cd8
[apex-tripleo-heat-templates.git] / extraconfig / all_nodes / swap-partition.j2.yaml
1 heat_template_version: ocata
2
3 description: Template file to add a swap partition to a node.
4
5 parameters:
6   servers:
7     type: json
8   swap_partition_label:
9     type: string
10     description: Swap partition label
11     default: 'swap1'
12
13 resources:
14   SwapConfig:
15     type: OS::Heat::SoftwareConfig
16     properties:
17       group: script
18       config: |
19         #!/bin/bash
20         set -eux
21         swap_partition=$(realpath /dev/disk/by-label/$swap_partition_label)
22         if [ -f "$swap_partition" ]; then
23           swapon $swap_partition
24           echo "$swap_partition swap swap defaults 0 0" >> /etc/fstab
25         else
26           echo "$swap_partition needs to be a valid path"
27           echo "Check that $swap_partition_label is a valid partition label"
28         fi
29       inputs:
30         - name: swap_partition_label
31           description: Swap partition label
32           default: 'swap1'
33
34 {% for role in roles %}
35   {{role.name}}SwapDeployment:
36     type: OS::Heat::SoftwareDeploymentGroup
37     properties:
38       config: {get_resource: SwapConfig}
39       servers: {get_param: [servers, {{role.name}}]}
40       input_values:
41         swap_partition_label: {get_param: swap_partition_label}
42       actions: ["CREATE"]
43 {% endfor %}