Update the template_version alias for all the templates to pike.
[apex-tripleo-heat-templates.git] / extraconfig / all_nodes / swap.j2.yaml
1 heat_template_version: pike
2
3 description: Template file to add a swap file to a node.
4
5 parameters:
6   servers:
7     type: json
8   swap_size_megabytes:
9     type: string
10     description: Amount of swap space to allocate in megabytes
11     default: '4096'
12   swap_path:
13     type: string
14     description: Full path to location of swap file
15     default: '/swap'
16
17 resources:
18   SwapConfig:
19     type: OS::Heat::SoftwareConfig
20     properties:
21       group: script
22       config: |
23         #!/bin/bash
24         set -eux
25         if [ ! -f $swap_path ]; then
26           dd if=/dev/zero of=$swap_path count=$swap_size_megabytes bs=1M
27           chmod 0600 $swap_path
28           mkswap $swap_path
29           swapon $swap_path
30         else
31           echo "$swap_path already exists"
32         fi
33         echo "$swap_path swap swap defaults 0 0" >> /etc/fstab
34       inputs:
35         - name: swap_size_megabytes
36           description: Amount of swap space to allocate in megabytes
37           default: '4096'
38         - name: swap_path
39           description: Full path to location of swap file
40           default: '/swap'
41
42 {% for role in roles %}
43   {{role.name}}SwapDeployment:
44     type: OS::Heat::SoftwareDeploymentGroup
45     properties:
46       config: {get_resource: SwapConfig}
47       servers: {get_param: [servers, {{role.name}}]}
48       input_values:
49         swap_size_megabytes: {get_param: swap_size_megabytes}
50         swap_path: {get_param: swap_path}
51       actions: ["CREATE"]
52 {% endfor %}