Merge "Adds network/cidr mapping into a new service property"
[apex-tripleo-heat-templates.git] / docker / services / pacemaker / rabbitmq.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Rabbitmq service
5
6 parameters:
7   DockerNamespace:
8     description: namespace
9     default: 'tripleoupstream'
10     type: string
11   DockerRabbitmqImage:
12     description: image
13     default: 'centos-binary-rabbitmq:latest'
14     type: string
15   DockerRabbitmqConfigImage:
16     description: The container image to use for the rabbitmq config_volume
17     default: 'centos-binary-rabbitmq:latest'
18     type: string
19   EndpointMap:
20     default: {}
21     description: Mapping of service endpoint -> protocol. Typically set
22                  via parameter_defaults in the resource registry.
23     type: json
24   ServiceData:
25     default: {}
26     description: Dictionary packing service data
27     type: json
28   ServiceNetMap:
29     default: {}
30     description: Mapping of service_name -> network name. Typically set
31                  via parameter_defaults in the resource registry.  This
32                  mapping overrides those in ServiceNetMapDefaults.
33     type: json
34   DefaultPasswords:
35     default: {}
36     type: json
37   RabbitCookie:
38     type: string
39     default: ''
40     hidden: true
41   RoleName:
42     default: ''
43     description: Role name on which the service is applied
44     type: string
45   RoleParameters:
46     default: {}
47     description: Parameters specific to the role
48     type: json
49
50 resources:
51
52   RabbitmqBase:
53     type: ../../../puppet/services/rabbitmq.yaml
54     properties:
55       EndpointMap: {get_param: EndpointMap}
56       ServiceData: {get_param: ServiceData}
57       ServiceNetMap: {get_param: ServiceNetMap}
58       DefaultPasswords: {get_param: DefaultPasswords}
59       RoleName: {get_param: RoleName}
60       RoleParameters: {get_param: RoleParameters}
61
62 outputs:
63   role_data:
64     description: Role data for the Rabbitmq API role.
65     value:
66       service_name: {get_attr: [RabbitmqBase, role_data, service_name]}
67       config_settings:
68         map_merge:
69           - {get_attr: [RabbitmqBase, role_data, config_settings]}
70           - rabbitmq::service_manage: false
71             tripleo::profile::pacemaker::rabbitmq_bundle::rabbitmq_docker_image: &rabbitmq_image
72               list_join:
73                 - '/'
74                 - - {get_param: DockerNamespace}
75                   - {get_param: DockerRabbitmqImage}
76       step_config: &step_config
77         get_attr: [RabbitmqBase, role_data, step_config]
78       service_config_settings: {get_attr: [RabbitmqBase, role_data, service_config_settings]}
79       # BEGIN DOCKER SETTINGS
80       puppet_config:
81         config_volume: rabbitmq
82         puppet_tags: file
83         step_config: *step_config
84         config_image:
85           list_join:
86             - '/'
87             - [ {get_param: DockerNamespace}, {get_param: DockerRabbitmqConfigImage} ]
88       kolla_config:
89         /var/lib/kolla/config_files/rabbitmq.json:
90           command: /usr/sbin/pacemaker_remoted
91           config_files:
92           - dest: /etc/libqb/force-filesystem-sockets
93             source: /dev/null
94             owner: root
95             perm: '0644'
96           - source: "/var/lib/kolla/config_files/src/*"
97             dest: "/"
98             merge: true
99             preserve_properties: true
100           permissions:
101            - path: /var/lib/rabbitmq
102              owner: rabbitmq:rabbitmq
103              recurse: true
104            - path: /var/log/rabbitmq
105              owner: rabbitmq:rabbitmq
106              recurse: true
107       # When using pacemaker we don't launch the container, instead that is done by pacemaker
108       # itself.
109       docker_config:
110         step_1:
111           rabbitmq_bootstrap:
112             start_order: 0
113             image: *rabbitmq_image
114             net: host
115             privileged: false
116             volumes:
117               - /var/lib/kolla/config_files/rabbitmq.json:/var/lib/kolla/config_files/config.json:ro
118               - /var/lib/config-data/puppet-generated/rabbitmq/:/var/lib/kolla/config_files/src:ro
119               - /etc/hosts:/etc/hosts:ro
120               - /etc/localtime:/etc/localtime:ro
121               - /var/lib/rabbitmq:/var/lib/rabbitmq
122             environment:
123               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
124               - KOLLA_BOOTSTRAP=True
125               -
126                 list_join:
127                   - '='
128                   - - 'RABBITMQ_CLUSTER_COOKIE'
129                     -
130                       yaql:
131                         expression: $.data.passwords.where($ != '').first()
132                         data:
133                           passwords:
134                             - {get_param: RabbitCookie}
135                             - {get_param: [DefaultPasswords, rabbit_cookie]}
136         step_2:
137           rabbitmq_init_bundle:
138             start_order: 0
139             detach: false
140             net: host
141             user: root
142             command:
143               - '/bin/bash'
144               - '-c'
145               - str_replace:
146                   template:
147                     list_join:
148                       - '; '
149                       - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 2}' > /etc/puppet/hieradata/docker.json"
150                         - "FACTER_uuid=docker puppet apply --tags file,file_line,concat,augeas,TAGS -v -e 'CONFIG'"
151                   params:
152                     TAGS: 'pacemaker::resource::bundle,pacemaker::property,pacemaker::resource::ocf,pacemaker::constraint::order,pacemaker::constraint::colocation'
153                     CONFIG: 'include ::tripleo::profile::base::pacemaker;include ::tripleo::profile::pacemaker::rabbitmq_bundle'
154             image: *rabbitmq_image
155             volumes:
156               - /etc/hosts:/etc/hosts:ro
157               - /etc/localtime:/etc/localtime:ro
158               - /etc/puppet:/tmp/puppet-etc:ro
159               - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
160               - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
161               - /dev/shm:/dev/shm:rw
162       host_prep_tasks:
163         - name: create /var/lib/rabbitmq
164           file:
165             path: /var/lib/rabbitmq
166             state: directory
167         - name: stop the Erlang port mapper on the host and make sure it cannot bind to the port used by container
168           shell: |
169             echo 'export ERL_EPMD_ADDRESS=127.0.0.1' > /etc/rabbitmq/rabbitmq-env.conf
170             echo 'export ERL_EPMD_PORT=4370' >> /etc/rabbitmq/rabbitmq-env.conf
171             for pid in $(pgrep epmd); do if [ "$(lsns -o NS -p $pid)" == "$(lsns -o NS -p 1)" ]; then kill $pid; break; fi; done
172       upgrade_tasks:
173         - name: Stop and disable rabbitmq service
174           tags: step2
175           service: name=rabbitmq-server state=stopped enabled=no