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