提交各组件部署Ansible剧本初版
This commit is contained in:
5
Chproxy/21.06.30/chproxy/hosts
Normal file
5
Chproxy/21.06.30/chproxy/hosts
Normal file
@@ -0,0 +1,5 @@
|
||||
[clickhouse]
|
||||
192.168.45.102
|
||||
|
||||
[chproxy]
|
||||
192.168.45.102
|
||||
7
Chproxy/21.06.30/chproxy/install.yml
Normal file
7
Chproxy/21.06.30/chproxy/install.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
- hosts: chproxy
|
||||
remote_user: root
|
||||
roles:
|
||||
- role
|
||||
vars_files:
|
||||
- role/vars/main.yml
|
||||
|
||||
6
Chproxy/21.06.30/chproxy/role/defaults/main.yml
Normal file
6
Chproxy/21.06.30/chproxy/role/defaults/main.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
#The default installation location
|
||||
deploy_dir: /data/olap
|
||||
|
||||
#The default data storage location,use storing application data,logs and configuration files
|
||||
data_dir: /data/olap
|
||||
|
||||
24
Chproxy/21.06.30/chproxy/role/handlers/main.yml
Normal file
24
Chproxy/21.06.30/chproxy/role/handlers/main.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
- name: Loading Image
|
||||
docker_image:
|
||||
name: '{{ image_name }}'
|
||||
tag: '{{ image_tag }}'
|
||||
load_path: '{{ deploy_dir }}/{{ container_name }}/{{ image_name }}-{{ image_tag }}.tar'
|
||||
source: load
|
||||
force_tag: yes
|
||||
force_source: yes
|
||||
timeout: 300
|
||||
|
||||
- name: Stop Container
|
||||
docker_container:
|
||||
name: '{{ container_name }}'
|
||||
state: absent
|
||||
|
||||
- name: Start Container
|
||||
docker_compose:
|
||||
project_src: '{{ deploy_dir }}/{{ container_name }}/'
|
||||
|
||||
- name: Removing Image
|
||||
docker_image:
|
||||
name: '{{ image_name }}'
|
||||
tag: '{{ image_tag }}'
|
||||
state: absent
|
||||
31
Chproxy/21.06.30/chproxy/role/tasks/deploy.yml
Normal file
31
Chproxy/21.06.30/chproxy/role/tasks/deploy.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
- name: Creating directory
|
||||
file:
|
||||
state: directory
|
||||
path: '{{ deploy_dir }}/{{ container_name }}/config'
|
||||
|
||||
- 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 Chproxy config files
|
||||
template:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
mode: '{{ item.mode }}'
|
||||
with_items:
|
||||
- { src: 'config.yml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/config/config.yml', mode: "0644" }
|
||||
|
||||
- name: Copying Chproxy docker-compose.yml
|
||||
template:
|
||||
src: 'docker-compose.yml.j2'
|
||||
dest: '{{ deploy_dir }}/{{ container_name }}/docker-compose.yml'
|
||||
mode: 0644
|
||||
notify:
|
||||
- Loading Image
|
||||
- Start Container
|
||||
|
||||
- meta: flush_handlers
|
||||
10
Chproxy/21.06.30/chproxy/role/tasks/main.yml
Normal file
10
Chproxy/21.06.30/chproxy/role/tasks/main.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
- block:
|
||||
- include: uninstall.yml
|
||||
- include: deploy.yml
|
||||
- include: status-check.yml
|
||||
when: (operation) == "install"
|
||||
|
||||
- block:
|
||||
- include: uninstall.yml
|
||||
when: (operation) == "unload"
|
||||
|
||||
17
Chproxy/21.06.30/chproxy/role/tasks/status-check.yml
Normal file
17
Chproxy/21.06.30/chproxy/role/tasks/status-check.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
- name: Waitting for Chproxy running,10s
|
||||
shell: sleep 10
|
||||
|
||||
- name: Check if the Chproxy process already exists
|
||||
shell: docker ps -a | grep -w "galaxy-chproxy" | wc -l
|
||||
register: process_out
|
||||
|
||||
- name: Check if the Chproxy port already exists
|
||||
shell: netstat -anlp | grep "8124" | grep LISTEN | wc -l
|
||||
register: port_out
|
||||
|
||||
- name: To terminate execution
|
||||
fail:
|
||||
msg: "Chproxy on node {{ inventory_hostname }} is not started. Please check"
|
||||
run_once: true
|
||||
delegate_to: 127.0.0.1
|
||||
when: process_out.stdout != '1' or port_out.stdout != '1'
|
||||
16
Chproxy/21.06.30/chproxy/role/tasks/uninstall.yml
Normal file
16
Chproxy/21.06.30/chproxy/role/tasks/uninstall.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
- block:
|
||||
- name: Stopping and removing {{ container_name }} container
|
||||
docker_container:
|
||||
name: '{{ container_name }}'
|
||||
state: absent
|
||||
|
||||
- name: Removing old {{ image_name }} image
|
||||
docker_image:
|
||||
name: '{{ image_name }}'
|
||||
tag: '{{ image_tag }}'
|
||||
state: absent
|
||||
|
||||
- name: Ansible delete old {{ deploy_dir }}/{{ container_name }}
|
||||
file:
|
||||
path: '{{ deploy_dir }}/{{ container_name }}'
|
||||
state: absent
|
||||
58
Chproxy/21.06.30/chproxy/role/templates/config.yml.j2
Normal file
58
Chproxy/21.06.30/chproxy/role/templates/config.yml.j2
Normal file
@@ -0,0 +1,58 @@
|
||||
log_debug: false
|
||||
hack_me_please: true
|
||||
server:
|
||||
http:
|
||||
listen_addr: ":8124"
|
||||
read_timeout: 6h
|
||||
idle_timeout: 10m
|
||||
users:
|
||||
- name: "tsg_report"
|
||||
to_cluster: "report"
|
||||
to_user: "tsg_report"
|
||||
password: "{{ clickhouse_default_pin }}"
|
||||
max_queue_size: 100
|
||||
max_queue_time: 21700s
|
||||
|
||||
- name: "tsg_query"
|
||||
to_cluster: "query"
|
||||
to_user: "tsg_query"
|
||||
password: "{{ clickhouse_query_pin }}"
|
||||
max_queue_size: 100
|
||||
max_queue_time: 610s
|
||||
|
||||
- name: "default"
|
||||
to_cluster: "report"
|
||||
to_user: "default"
|
||||
password: "{{ clickhouse_default_pin }}"
|
||||
max_queue_size: 100
|
||||
max_queue_time: 3610s
|
||||
# by default each cluster has `default` user which can be overridden by section `users`
|
||||
clusters:
|
||||
- name: "report"
|
||||
{% if groups.clickhouse|length >= 3 %}
|
||||
nodes: [ "{{groups.clickhouse[0]}}:8123", "{{groups.clickhouse[1]}}:8123" ]
|
||||
masternode: 1
|
||||
{% elif groups.clickhouse|length == 1 %}
|
||||
nodes: [ "{{groups.clickhouse[0]}}:8123" ]
|
||||
{% endif %}
|
||||
kill_query_user:
|
||||
name: "default"
|
||||
password: "{{ clickhouse_default_pin }}"
|
||||
users:
|
||||
- name: "default"
|
||||
password: "{{ clickhouse_default_pin }}"
|
||||
- name: "tsg_report"
|
||||
password: "{{ clickhouse_default_pin }}"
|
||||
- name: "query"
|
||||
{% if groups.clickhouse|length >= 3 %}
|
||||
nodes: [ "{{groups.clickhouse[1]}}:8123", "{{groups.clickhouse[0]}}:8123" ]
|
||||
masternode: 1
|
||||
{% elif groups.clickhouse|length == 1 %}
|
||||
nodes: [ "{{groups.clickhouse[0]}}:8123" ]
|
||||
{% endif %}
|
||||
kill_query_user:
|
||||
name: "default"
|
||||
password: "galaxy2019"
|
||||
users:
|
||||
- name: "tsg_query"
|
||||
password: "{{ clickhouse_query_pin }}"
|
||||
@@ -0,0 +1,18 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
chproxy:
|
||||
image: {{ image_name }}:{{ image_tag }}
|
||||
container_name: {{ container_name }}
|
||||
ports:
|
||||
- "8124:8124"
|
||||
volumes:
|
||||
- "{{ deploy_dir }}/{{ container_name }}/config:/home/config"
|
||||
- "{{ deploy_dir }}/{{ container_name }}/log:/home/log"
|
||||
restart: always
|
||||
networks:
|
||||
olap:
|
||||
ipv4_address: 172.20.88.9
|
||||
networks:
|
||||
olap:
|
||||
external: true
|
||||
8
Chproxy/21.06.30/chproxy/role/vars/main.yml
Normal file
8
Chproxy/21.06.30/chproxy/role/vars/main.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
#镜像名称
|
||||
image_name: chproxy
|
||||
|
||||
#镜像版本号
|
||||
image_tag: 21.06.30
|
||||
|
||||
#容器名称
|
||||
container_name: galaxy-chproxy
|
||||
Reference in New Issue
Block a user