90 lines
3.3 KiB
YAML
90 lines
3.3 KiB
YAML
- block:
|
|
- name: Check the Zookeeper status
|
|
shell: netstat -anlp | egrep "2181" | grep LISTEN | wc -l
|
|
register: port_out
|
|
delegate_to: "{{ groups.zookeeper[0] }}"
|
|
|
|
- name: To terminate execution
|
|
fail:
|
|
msg: "Port 2181 of the zookeeper node is not monitored. The status may be abnormal"
|
|
run_once: true
|
|
delegate_to: 127.0.0.1
|
|
when: port_out.stdout != '1'
|
|
|
|
- name: Getting readonly key sha256
|
|
shell: echo -n "{{ clickhouse_query_pin }}"|sha256sum | tr -d '-' | sed -e 's/^[ ]*//g' | sed -e 's/[ ]*$//g'
|
|
register: readonly_key_out
|
|
|
|
- name: Setting readonly_key_sha variable
|
|
set_fact: readonly_key_sha="{{readonly_key_out.stdout}}"
|
|
|
|
- name: Getting root key sha256
|
|
shell: echo -n "{{ clickhouse_default_pin }}"|sha256sum| tr -d '-' | sed -e 's/^[ ]*//g' | sed -e 's/[ ]*$//g'
|
|
register: root_key_out
|
|
|
|
- name: Setting root_key_sha variable
|
|
set_fact: root_key_sha="{{root_key_out.stdout}}"
|
|
|
|
- name: Modify clickhouse process limits
|
|
shell: if [ `cat /etc/security/limits.d/20-nproc.conf | grep clickhouse | wc -l` -eq "0" ];then echo "clickhouse soft nproc 65535" >> /etc/security/limits.d/20-nproc.conf ;fi
|
|
|
|
- name: Creating ClickHouse install path
|
|
file:
|
|
state: directory
|
|
path: '{{ deploy_dir }}/{{ container_name }}/{{ item.path }}'
|
|
with_items:
|
|
- { path: 'clickhouse-server' }
|
|
- { path: 'logs' }
|
|
- { path: 'monitor' }
|
|
|
|
- name: Copying image to {{ deploy_dir }}/{{ container_name }}/
|
|
copy:
|
|
src: 'files/{{ image_name }}-{{ image_tag }}.tar'
|
|
dest: '{{ deploy_dir }}/{{ container_name }}/'
|
|
force: true
|
|
notify:
|
|
- Loading Image
|
|
|
|
- name: Copying ClickHouse configuration files
|
|
template:
|
|
src: '{{ item.src }}'
|
|
dest: '{{ item.dest }}'
|
|
force: true
|
|
with_items:
|
|
- { src: 'standalone/config.xml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/clickhouse-server/config.xml' }
|
|
- { src: 'users.xml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/clickhouse-server/users.xml' }
|
|
- { src: 'standalone/metrika_standalone.xml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/clickhouse-server/metrika.xml' }
|
|
- { src: 'standalone/docker-compose.yml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/docker-compose.yml' }
|
|
- { src: 'docker-compose_exporter.yml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/monitor/docker-compose.yml' }
|
|
notify:
|
|
- Start Container
|
|
|
|
- name: Copying clickhouse_exporter-2.0.tar
|
|
copy:
|
|
src: 'files/clickhouse_exporter-2.0.tar'
|
|
dest: '{{ deploy_dir }}/clickhouse/monitor/'
|
|
force: true
|
|
notify:
|
|
- Loading Exporter Image
|
|
|
|
- name: Copying ClickHouse monitor files
|
|
template:
|
|
src: '{{ item.src }}'
|
|
dest: '{{ item.dest }}'
|
|
mode: '{{ item.mode }}'
|
|
force: true
|
|
with_items:
|
|
- { src: 'standalone/ck_monitor.sh.j2', dest: '{{ deploy_dir }}/clickhouse/monitor/ck_monitor.sh', mode: '0755' }
|
|
- { src: 'docker-compose_exporter.yml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/monitor/docker-compose.yml', mode: '0644' }
|
|
notify:
|
|
- Start Exporter Container
|
|
|
|
- name: Adding a cron -> Check Clickhouse up to node_exporter
|
|
cron:
|
|
name: 'Check Clickhouse up to node_exporter'
|
|
minute: "*/5"
|
|
job: '{{ deploy_dir }}/clickhouse/monitor/ck_monitor.sh'
|
|
user: root
|
|
|
|
- meta: flush_handlers
|