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