Merge "TLS everywhere/haproxy: Remove empty postsave command"
[apex-tripleo-heat-templates.git] / docker / services / pacemaker / database / redis.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Redis services
5
6 parameters:
7   DockerRedisImage:
8     description: image
9     type: string
10   DockerRedisConfigImage:
11     description: The container image to use for the redis config_volume
12     type: string
13   EndpointMap:
14     default: {}
15     description: Mapping of service endpoint -> protocol. Typically set
16                  via parameter_defaults in the resource registry.
17     type: json
18   ServiceData:
19     default: {}
20     description: Dictionary packing service data
21     type: json
22   ServiceNetMap:
23     default: {}
24     description: Mapping of service_name -> network name. Typically set
25                  via parameter_defaults in the resource registry.  This
26                  mapping overrides those in ServiceNetMapDefaults.
27     type: json
28   DefaultPasswords:
29     default: {}
30     type: json
31   RoleName:
32     default: ''
33     description: Role name on which the service is applied
34     type: string
35   RoleParameters:
36     default: {}
37     description: Parameters specific to the role
38     type: json
39
40 resources:
41
42   RedisBase:
43     type: ../../../../puppet/services/database/redis.yaml
44     properties:
45       EndpointMap: {get_param: EndpointMap}
46       ServiceData: {get_param: ServiceData}
47       ServiceNetMap: {get_param: ServiceNetMap}
48       DefaultPasswords: {get_param: DefaultPasswords}
49       RoleName: {get_param: RoleName}
50       RoleParameters: {get_param: RoleParameters}
51
52 outputs:
53   role_data:
54     description: Role data for the Redis API role.
55     value:
56       service_name: {get_attr: [RedisBase, role_data, service_name]}
57       config_settings:
58         map_merge:
59           - {get_attr: [RedisBase, role_data, config_settings]}
60           - redis::service_manage: false
61             redis::notify_service: false
62             redis::managed_by_cluster_manager: true
63             tripleo::profile::pacemaker::database::redis_bundle::redis_docker_image: &redis_image_pcmklatest
64               list_join:
65                 - ':'
66                 - - yaql:
67                       data: {get_param: DockerRedisImage}
68                       expression: $.data.rightSplit(separator => ":", maxSplits => 1)[0]
69                   - 'pcmklatest'
70             tripleo::profile::pacemaker::database::redis_bundle::control_port: 3124
71             tripleo.redis.firewall_rules:
72               '108 redis-bundle':
73                 dport:
74                   - 3124
75                   - 6379
76                   - 26379
77       step_config: ""
78       service_config_settings: {get_attr: [RedisBase, role_data, service_config_settings]}
79       # BEGIN DOCKER SETTINGS
80       puppet_config:
81         config_volume: 'redis'
82         # NOTE: we need the exec tag to copy /etc/redis.conf.puppet to
83         # /etc/redis.conf
84         # https://github.com/arioch/puppet-redis/commit/1c004143223e660cbd433422ff8194508aab9763
85         puppet_tags: 'exec'
86         step_config:
87           get_attr: [RedisBase, role_data, step_config]
88         config_image: &redis_config_image {get_param: DockerRedisConfigImage}
89       kolla_config:
90         /var/lib/kolla/config_files/redis.json:
91           command: /usr/sbin/pacemaker_remoted
92           config_files:
93             - dest: /etc/libqb/force-filesystem-sockets
94               source: /dev/null
95               owner: root
96               perm: '0644'
97             - source: "/var/lib/kolla/config_files/src/*"
98               dest: "/"
99               merge: true
100               preserve_properties: true
101               optional: true
102           permissions:
103             - path: /var/run/redis
104               owner: redis:redis
105               recurse: true
106             - path: /var/lib/redis
107               owner: redis:redis
108               recurse: true
109             - path: /var/log/redis
110               owner: redis:redis
111               recurse: true
112       docker_config:
113         step_1:
114           redis_image_tag:
115             start_order: 1
116             detach: false
117             net: host
118             user: root
119             command:
120               - '/bin/bash'
121               - '-c'
122               - str_replace:
123                   template:
124                     "/usr/bin/docker tag 'REDIS_IMAGE' 'REDIS_IMAGE_PCMKLATEST'"
125                   params:
126                     REDIS_IMAGE: {get_param: DockerRedisImage}
127                     REDIS_IMAGE_PCMKLATEST: *redis_image_pcmklatest
128             image: {get_param: DockerRedisImage}
129             volumes:
130               - /etc/hosts:/etc/hosts:ro
131               - /etc/localtime:/etc/localtime:ro
132               - /dev/shm:/dev/shm:rw
133               - /etc/sysconfig/docker:/etc/sysconfig/docker:ro
134               - /usr/bin:/usr/bin:ro
135               - /var/run/docker.sock:/var/run/docker.sock:rw
136         step_2:
137           redis_init_bundle:
138             start_order: 2
139             detach: false
140             net: host
141             user: root
142             config_volume: 'redis_init_bundle'
143             command:
144               - '/bin/bash'
145               - '-c'
146               - str_replace:
147                   template:
148                     list_join:
149                       - '; '
150                       - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 2}' > /etc/puppet/hieradata/docker.json"
151                         - "FACTER_uuid=docker puppet apply --tags file,file_line,concat,augeas,TAGS -v -e 'CONFIG'"
152                   params:
153                     TAGS: 'pacemaker::resource::bundle,pacemaker::property,pacemaker::resource::ocf,pacemaker::constraint::order,pacemaker::constraint::colocation'
154                     CONFIG: 'include ::tripleo::profile::base::pacemaker;include ::tripleo::profile::pacemaker::database::redis_bundle'
155             image: *redis_config_image
156             volumes:
157               - /etc/hosts:/etc/hosts:ro
158               - /etc/localtime:/etc/localtime:ro
159               - /etc/puppet:/tmp/puppet-etc:ro
160               - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
161               - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
162               - /dev/shm:/dev/shm:rw
163       host_prep_tasks:
164         - name: create /var/run/redis
165           file:
166             path: /var/run/redis
167             state: directory
168         - name: create /var/log/redis
169           file:
170             path: /var/log/redis
171             state: directory
172         - name: create /var/lib/redis
173           file:
174             path: /var/lib/redis
175             state: directory
176       upgrade_tasks:
177         - name: get bootstrap nodeid
178           tags: common
179           command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
180           register: bootstrap_node
181         - name: set is_bootstrap_node fact
182           tags: common
183           set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
184         - name: Disable the redis cluster resource
185           tags: step2
186           pacemaker_resource:
187             resource: {get_attr: [RedisBase, role_data, service_name]}
188             state: disable
189             wait_for_resource: true
190           when: is_bootstrap_node
191         - name: Delete the stopped redis cluster resource.
192           tags: step2
193           pacemaker_resource:
194             resource: {get_attr: [RedisBase, role_data, service_name]}
195             state: delete
196             wait_for_resource: true
197           when: is_bootstrap_node
198         - name: Disable redis service
199           tags: step2
200           service: name=redis enabled=no