Add support for deploying ZooKeeper
This picks up the abandoned review: https://review.openstack.org/#/c/412423 Co-Authored-By: Sam Yaple <sam@yaple.net> Partially-Implements: blueprint monasca-roles Change-Id: Idc01afcb125271181ee5e15d327d0929f07b49e9
This commit is contained in:
parent
d32c708290
commit
f87b238db5
@ -303,6 +303,10 @@ trove_api_port: "8779"
|
|||||||
|
|
||||||
watcher_api_port: "9322"
|
watcher_api_port: "9322"
|
||||||
|
|
||||||
|
zookeeper_client_port: "2181"
|
||||||
|
zookeeper_peer_port: "2888"
|
||||||
|
zookeeper_quorum_port: "3888"
|
||||||
|
|
||||||
zun_api_port: "9517"
|
zun_api_port: "9517"
|
||||||
|
|
||||||
opendaylight_clustering_port: "2550"
|
opendaylight_clustering_port: "2550"
|
||||||
@ -477,6 +481,7 @@ enable_trove: "no"
|
|||||||
enable_vitrage: "no"
|
enable_vitrage: "no"
|
||||||
enable_vmtp: "no"
|
enable_vmtp: "no"
|
||||||
enable_watcher: "no"
|
enable_watcher: "no"
|
||||||
|
enable_zookeeper: "no"
|
||||||
enable_zun: "no"
|
enable_zun: "no"
|
||||||
|
|
||||||
ovs_datapath: "{{ 'netdev' if enable_ovs_dpdk | bool else 'system' }}"
|
ovs_datapath: "{{ 'netdev' if enable_ovs_dpdk | bool else 'system' }}"
|
||||||
|
@ -222,6 +222,9 @@ control
|
|||||||
[bifrost:children]
|
[bifrost:children]
|
||||||
deployment
|
deployment
|
||||||
|
|
||||||
|
[zookeeper:children]
|
||||||
|
control
|
||||||
|
|
||||||
[zun:children]
|
[zun:children]
|
||||||
control
|
control
|
||||||
|
|
||||||
|
@ -241,6 +241,9 @@ control
|
|||||||
[bifrost:children]
|
[bifrost:children]
|
||||||
deployment
|
deployment
|
||||||
|
|
||||||
|
[zookeeper:children]
|
||||||
|
control
|
||||||
|
|
||||||
[zun:children]
|
[zun:children]
|
||||||
control
|
control
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
- "03-rabbitmq"
|
- "03-rabbitmq"
|
||||||
- "04-openstack-wsgi"
|
- "04-openstack-wsgi"
|
||||||
- "05-libvirt"
|
- "05-libvirt"
|
||||||
|
- "06-zookeeper"
|
||||||
notify:
|
notify:
|
||||||
- Restart fluentd container
|
- Restart fluentd container
|
||||||
|
|
||||||
@ -217,6 +218,7 @@
|
|||||||
- { name: "trove", enabled: "{{ enable_trove }}" }
|
- { name: "trove", enabled: "{{ enable_trove }}" }
|
||||||
- { name: "vitrage", enabled: "{{ enable_vitrage }}" }
|
- { name: "vitrage", enabled: "{{ enable_vitrage }}" }
|
||||||
- { name: "watcher", enabled: "{{ enable_watcher }}" }
|
- { name: "watcher", enabled: "{{ enable_watcher }}" }
|
||||||
|
- { name: "zookeeper", enabled: "{{ enable_zookeeper }}" }
|
||||||
- { name: "zun", enabled: "{{ enable_zun }}" }
|
- { name: "zun", enabled: "{{ enable_zun }}" }
|
||||||
notify:
|
notify:
|
||||||
- Restart cron container
|
- Restart cron container
|
||||||
|
@ -7,6 +7,13 @@
|
|||||||
</record>
|
</record>
|
||||||
</filter>
|
</filter>
|
||||||
|
|
||||||
|
<filter infra.var.log.kolla.*.*.log>
|
||||||
|
@type record_transformer
|
||||||
|
<record>
|
||||||
|
Logger ${tag_parts[4]}
|
||||||
|
</record>
|
||||||
|
</filter>
|
||||||
|
|
||||||
<filter infra.*>
|
<filter infra.*>
|
||||||
@type record_transformer
|
@type record_transformer
|
||||||
<record>
|
<record>
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
{% set fluentd_dir = 'td-agent' if kolla_base_distro in ['ubuntu', 'debian'] else 'fluentd' %}
|
||||||
|
<source>
|
||||||
|
@type tail
|
||||||
|
path /var/log/kolla/zookeeper/zookeeper.log
|
||||||
|
pos_file /var/run/{{ fluentd_dir }}/zookeeper.pos
|
||||||
|
tag infra.*
|
||||||
|
format multiline
|
||||||
|
format_firstline /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} \S+ \S+ \S+ .*$/
|
||||||
|
format1 /^(?<Timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}) \[(?<server_id>\S+)\] \S+ (?<log_level>\S+) (?<Payload>.*)$/
|
||||||
|
time_key Timestamp
|
||||||
|
</source>
|
@ -0,0 +1,3 @@
|
|||||||
|
"/var/log/kolla/zookeeper/*.log"
|
||||||
|
{
|
||||||
|
}
|
@ -53,6 +53,7 @@
|
|||||||
( 'trove', enable_trove ),
|
( 'trove', enable_trove ),
|
||||||
( 'vitrage', enable_vitrage ),
|
( 'vitrage', enable_vitrage ),
|
||||||
( 'watcher', enable_watcher ),
|
( 'watcher', enable_watcher ),
|
||||||
|
( 'zookeeper', enable_zookeeper ),
|
||||||
( 'zun', enable_zun )
|
( 'zun', enable_zun )
|
||||||
] %}
|
] %}
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,12 @@
|
|||||||
"owner": "{{ fluentd_user }}",
|
"owner": "{{ fluentd_user }}",
|
||||||
"perm": "0600"
|
"perm": "0600"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"source": "{{ container_config_directory }}/input/06-zookeeper.conf",
|
||||||
|
"dest": "{{ fluentd_dir }}/input/06-zookeeper.conf",
|
||||||
|
"owner": "{{ fluentd_user }}",
|
||||||
|
"perm": "0600"
|
||||||
|
},
|
||||||
{# Copy all configuration files in filter/ directory to include #}
|
{# Copy all configuration files in filter/ directory to include #}
|
||||||
{# custom filter configs. #}
|
{# custom filter configs. #}
|
||||||
{
|
{
|
||||||
|
28
ansible/roles/zookeeper/defaults/main.yml
Normal file
28
ansible/roles/zookeeper/defaults/main.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
zookeeper_services:
|
||||||
|
zookeeper:
|
||||||
|
container_name: zookeeper
|
||||||
|
group: zookeeper
|
||||||
|
enabled: true
|
||||||
|
image: "{{ zookeeper_image_full }}"
|
||||||
|
environment:
|
||||||
|
ZOO_LOG_DIR: /var/log/kolla/zookeeper
|
||||||
|
ZOO_LOG4J_PROP: "{{ zookeeper_log_settings }}"
|
||||||
|
volumes:
|
||||||
|
- "{{ node_config_directory }}/zookeeper/:{{ container_config_directory }}/"
|
||||||
|
- "/etc/localtime:/etc/localtime:ro"
|
||||||
|
- "zookeeper:/var/lib/zookeeper/data"
|
||||||
|
- "kolla_logs:/var/log/kolla/"
|
||||||
|
|
||||||
|
####################
|
||||||
|
# Zookeeper
|
||||||
|
####################
|
||||||
|
zookeeper_log_settings: 'INFO,ROLLINGFILE'
|
||||||
|
|
||||||
|
####################
|
||||||
|
# Docker
|
||||||
|
####################
|
||||||
|
zookeeper_install_type: "{{ kolla_install_type }}"
|
||||||
|
zookeeper_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ zookeeper_install_type }}-zookeeper"
|
||||||
|
zookeeper_tag: "{{ openstack_release }}"
|
||||||
|
zookeeper_image_full: "{{ zookeeper_image }}:{{ zookeeper_tag }}"
|
24
ansible/roles/zookeeper/handlers/main.yml
Normal file
24
ansible/roles/zookeeper/handlers/main.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
- name: Restart zookeeper container
|
||||||
|
vars:
|
||||||
|
service_name: "zookeeper"
|
||||||
|
service: "{{ zookeeper_services[service_name] }}"
|
||||||
|
config_json: "{{ zookeeper_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
zookeeper_conf: "{{ zookeeper_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
zookeeper_instance_id: "{{ zookeeper_instance_id.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
zookeeper_container: "{{ check_zookeeper_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
kolla_docker:
|
||||||
|
action: "recreate_or_restart_container"
|
||||||
|
common_options: "{{ docker_common_options }}"
|
||||||
|
name: "{{ service.container_name }}"
|
||||||
|
image: "{{ service.image }}"
|
||||||
|
environment: "{{ service.environment }}"
|
||||||
|
volumes: "{{ service.volumes }}"
|
||||||
|
when:
|
||||||
|
- action != "config"
|
||||||
|
- inventory_hostname in groups[service.group]
|
||||||
|
- service.enabled | bool
|
||||||
|
- config_json.changed | bool
|
||||||
|
or zookeeper_conf.changed | bool
|
||||||
|
or zookeeper_instance_id.changed | bool
|
||||||
|
or zookeeper_container.changed | bool
|
3
ansible/roles/zookeeper/meta/main.yml
Normal file
3
ansible/roles/zookeeper/meta/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- { role: common }
|
1
ansible/roles/zookeeper/tasks/check.yml
Normal file
1
ansible/roles/zookeeper/tasks/check.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
---
|
76
ansible/roles/zookeeper/tasks/config.yml
Normal file
76
ansible/roles/zookeeper/tasks/config.yml
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
---
|
||||||
|
- name: Ensuring config directories exist
|
||||||
|
file:
|
||||||
|
path: "{{ node_config_directory }}/{{ item.key }}"
|
||||||
|
state: "directory"
|
||||||
|
owner: "{{ config_owner_user }}"
|
||||||
|
group: "{{ config_owner_group }}"
|
||||||
|
mode: "0770"
|
||||||
|
recurse: yes
|
||||||
|
become: true
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ zookeeper_services }}"
|
||||||
|
|
||||||
|
- name: Copying over config.json files for services
|
||||||
|
template:
|
||||||
|
src: "{{ item.key }}.json.j2"
|
||||||
|
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
|
||||||
|
mode: "0660"
|
||||||
|
become: true
|
||||||
|
register: zookeeper_config_jsons
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ zookeeper_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart zookeeper container
|
||||||
|
|
||||||
|
- name: Copying over zookeeper configuration
|
||||||
|
merge_configs:
|
||||||
|
sources:
|
||||||
|
- "{{ role_path }}/templates/{{ item.key }}.cfg.j2"
|
||||||
|
- "{{ node_custom_config }}/{{ item.key }}.cfg"
|
||||||
|
- "{{ node_custom_config }}/{{ item.key }}/{{ inventory_hostname }}/{{ item.key }}.cfg"
|
||||||
|
dest: "{{ node_config_directory }}/{{ item.key }}/{{ item.key }}.cfg"
|
||||||
|
mode: "0660"
|
||||||
|
become: true
|
||||||
|
register: zookeeper_confs
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ zookeeper_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart zookeeper container
|
||||||
|
|
||||||
|
- name: Copying over zookeeper instance id
|
||||||
|
template:
|
||||||
|
src: "myid.j2"
|
||||||
|
dest: "{{ node_config_directory }}/{{ item.key }}/myid"
|
||||||
|
mode: "0660"
|
||||||
|
become: true
|
||||||
|
register: zookeeper_instance_id
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ zookeeper_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart zookeeper container
|
||||||
|
|
||||||
|
- name: Check zookeeper containers
|
||||||
|
kolla_docker:
|
||||||
|
action: "compare_container"
|
||||||
|
common_options: "{{ docker_common_options }}"
|
||||||
|
name: "{{ item.value.container_name }}"
|
||||||
|
image: "{{ item.value.image }}"
|
||||||
|
volumes: "{{ item.value.volumes }}"
|
||||||
|
environment: "{{ item.value.environment }}"
|
||||||
|
register: check_zookeeper_containers
|
||||||
|
when:
|
||||||
|
- action != "config"
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ zookeeper_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart zookeeper container
|
5
ansible/roles/zookeeper/tasks/deploy.yml
Normal file
5
ansible/roles/zookeeper/tasks/deploy.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- include: config.yml
|
||||||
|
|
||||||
|
- name: Flush handlers
|
||||||
|
meta: flush_handlers
|
2
ansible/roles/zookeeper/tasks/main.yml
Normal file
2
ansible/roles/zookeeper/tasks/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
- include: "{{ action }}.yml"
|
21
ansible/roles/zookeeper/tasks/precheck.yml
Normal file
21
ansible/roles/zookeeper/tasks/precheck.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
- name: Get container facts
|
||||||
|
kolla_container_facts:
|
||||||
|
name:
|
||||||
|
- zookeeper
|
||||||
|
register: container_facts
|
||||||
|
|
||||||
|
- name: Checking zookeeper ports are available
|
||||||
|
wait_for:
|
||||||
|
host: "{{ api_interface_address }}"
|
||||||
|
port: "{{ item }}"
|
||||||
|
connect_timeout: 1
|
||||||
|
timeout: 1
|
||||||
|
state: stopped
|
||||||
|
with_items:
|
||||||
|
- "{{ zookeeper_client_port }}"
|
||||||
|
- "{{ zookeeper_peer_port }}"
|
||||||
|
- "{{ zookeeper_quorum_port }}"
|
||||||
|
when:
|
||||||
|
- container_facts['zookeeper'] is not defined
|
||||||
|
- inventory_hostname in groups['zookeeper']
|
10
ansible/roles/zookeeper/tasks/pull.yml
Normal file
10
ansible/roles/zookeeper/tasks/pull.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
- name: Pulling zookeeper images
|
||||||
|
kolla_docker:
|
||||||
|
action: "pull_image"
|
||||||
|
common_options: "{{ docker_common_options }}"
|
||||||
|
image: "{{ item.value.image }}"
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ zookeeper_services }}"
|
2
ansible/roles/zookeeper/tasks/reconfigure.yml
Normal file
2
ansible/roles/zookeeper/tasks/reconfigure.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
- include: deploy.yml
|
5
ansible/roles/zookeeper/tasks/upgrade.yml
Normal file
5
ansible/roles/zookeeper/tasks/upgrade.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- include: config.yml
|
||||||
|
|
||||||
|
- name: Flush handlers
|
||||||
|
meta: flush_handlers
|
5
ansible/roles/zookeeper/templates/myid.j2
Normal file
5
ansible/roles/zookeeper/templates/myid.j2
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{% for host in groups['zookeeper'] -%}
|
||||||
|
{% if hostvars[host]['ansible_hostname'] == ansible_hostname -%}
|
||||||
|
{{ loop.index }}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
8
ansible/roles/zookeeper/templates/zookeeper.cfg.j2
Normal file
8
ansible/roles/zookeeper/templates/zookeeper.cfg.j2
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
tickTime=2000
|
||||||
|
initLimit=10
|
||||||
|
syncLimit=5
|
||||||
|
dataDir=/var/lib/zookeeper/data
|
||||||
|
clientPort={{ zookeeper_client_port }}
|
||||||
|
{% for host in groups['zookeeper'] %}
|
||||||
|
server.{{ loop.index }}={{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ zookeeper_peer_port }}:{{ zookeeper_quorum_port }}
|
||||||
|
{% endfor %}
|
29
ansible/roles/zookeeper/templates/zookeeper.json.j2
Normal file
29
ansible/roles/zookeeper/templates/zookeeper.json.j2
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"command": "/opt/zookeeper/bin/zkServer.sh start-foreground /etc/zookeeper/conf/zoo.cfg",
|
||||||
|
"config_files": [
|
||||||
|
{
|
||||||
|
"source": "{{ container_config_directory }}/myid",
|
||||||
|
"dest": "/var/lib/zookeeper/data/myid",
|
||||||
|
"owner": "zookeeper",
|
||||||
|
"perm": "0600"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "{{ container_config_directory }}/zookeeper.cfg",
|
||||||
|
"dest": "/etc/zookeeper/conf/zoo.cfg",
|
||||||
|
"owner": "zookeeper",
|
||||||
|
"perm": "0600"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"path": "/var/lib/zookeeper",
|
||||||
|
"owner": "zookeeper:zookeeper",
|
||||||
|
"recurse": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/var/log/kolla/zookeeper",
|
||||||
|
"owner": "zookeeper:zookeeper",
|
||||||
|
"recurse": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -75,6 +75,15 @@
|
|||||||
tags: collectd,
|
tags: collectd,
|
||||||
when: enable_collectd | bool }
|
when: enable_collectd | bool }
|
||||||
|
|
||||||
|
- name: Apply role zookeeper
|
||||||
|
gather_facts: false
|
||||||
|
hosts: zookeeper
|
||||||
|
serial: '{{ serial|default("0") }}'
|
||||||
|
roles:
|
||||||
|
- { role: zookeeper,
|
||||||
|
tags: zookeeper,
|
||||||
|
when: enable_zookeeper | bool }
|
||||||
|
|
||||||
- name: Apply role elasticsearch
|
- name: Apply role elasticsearch
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
hosts: elasticsearch
|
hosts: elasticsearch
|
||||||
|
@ -234,6 +234,7 @@ kolla_internal_vip_address: "10.10.10.254"
|
|||||||
#enable_vitrage: "no"
|
#enable_vitrage: "no"
|
||||||
#enable_vmtp: "no"
|
#enable_vmtp: "no"
|
||||||
#enable_watcher: "no"
|
#enable_watcher: "no"
|
||||||
|
#enable_zookeeper: "no"
|
||||||
#enable_zun: "no"
|
#enable_zun: "no"
|
||||||
|
|
||||||
##############
|
##############
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Add a role for deploying Apache Zookeeper for the purpose of
|
||||||
|
supporting Apache Kafka. See https://zookeeper.apache.org/
|
||||||
|
for more details.
|
Loading…
Reference in New Issue
Block a user