This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
galaxy-deployment-ansible-d…/Apache Druid/26.0.0/druid/role/tasks/deploy.yml

157 lines
5.3 KiB
YAML
Raw Normal View History

- block:
- name: To terminate execution
fail:
msg: "Druid Cluster mode at least 3 nodes,please checking configurations/hosts -> druid"
when: node_nums < (min_cluster_num)
- 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: Checking Hadoop DataNode status
shell: source /etc/profile && hadoop dfsadmin -report | grep "Live datanodes" | grep -E -o "[0-9]"
async: 10
register: datanode_out
run_once: true
delegate_to: "{{ groups.hdfs[0] }}"
- name: Checking Hadoop NameNode status
shell: source /etc/profile && hadoop dfsadmin -report |grep 50010 | wc -l
async: 10
register: namenode_out
run_once: true
delegate_to: "{{ groups.hdfs[0] }}"
- name: To terminate execution
fail:
msg: "If the dependency test fails, check whether the Hadoop cluster is normal"
when: datanode_out.stdout <= '1' and namenode_out.stdout <= '1'
- name: Creating directory
file:
state: directory
path: '{{ deploy_dir }}/{{ container_name }}/{{ item.dir }}'
with_items:
- { dir: 'var' }
- { dir: 'log' }
- { dir: 'monitor' }
- name: Copying config
unarchive:
src: 'files/conf.zip'
dest: '{{ deploy_dir }}/{{ container_name }}/'
- name: Copying image to {{ deploy_dir }}/{{ container_name }}/
copy:
src: '{{ role_path }}/../../../software-packages/{{ image_name }}-{{ image_tag }}.tar'
dest: '{{ deploy_dir }}/{{ container_name }}/'
force: true
notify:
- Loading Image
- name: copying druid config files
template:
src: '{{ item.src }}'
dest: '{{ deploy_dir }}/{{ container_name }}/conf/druid/cluster/{{ item.dest }}'
backup: false
with_items:
- { src: 'common.runtime.properties.j2', dest: '_common/common.runtime.properties' }
- { src: 'broker_runtime.j2', dest: 'query/broker/runtime.properties' }
- { src: 'broker_jvm.j2', dest: 'query/broker/jvm.config' }
- { src: 'historical_runtime.j2', dest: 'data/historical/runtime.properties' }
- { src: 'historical_jvm.j2', dest: 'data/historical/jvm.config' }
- { src: 'middleManager_jvm.j2', dest: 'data/middleManager/jvm.config' }
- { src: 'middleManager_runtime.properties.j2', dest: 'data/middleManager/runtime.properties' }
- { src: 'coordinator_jvm.j2', dest: 'master/coordinator-overlord/jvm.config' }
- { src: 'router_runtime.properties.j2', dest: 'query/router/runtime.properties' }
- name: Fetching Hadoop config files to /tmp
ansible.builtin.fetch:
src: "{{ deploy_dir }}/hadoop-2.7.1/etc/hadoop/{{ item.filename }}"
dest: "/tmp/"
flat: yes
loop: "{{ hadoop_config_files }}"
run_once: true
delegate_to: "{{ groups.hdfs[0] }}"
- name: Copying Hadoop config files to other nodes
ansible.builtin.copy:
src: "/tmp/{{ item.filename }}"
dest: "{{ deploy_dir }}/{{ container_name }}/conf/druid/cluster/_common/"
loop: "{{ hadoop_config_files }}"
- name: Create a new database with name {{ druid_database }}
shell: mysql -uroot -p{{ mariadb_default_pin }} -P3306 -h{{ groups.mariadb[0] }} -e "create database {{ druid_database }} default character set utf8mb4 collate utf8mb4_general_ci;"
run_once: true
delegate_to: "{{ groups.mariadb[0] }}"
- block:
- name: Setting startup_mode variable
set_fact: startup_mode="cluster-all-server"
- name: Copying Druid docker-compose
template:
src: 'docker-compose.yml.j2'
dest: '{{ deploy_dir }}/{{ container_name }}/docker-compose.yml'
mode: 0644
notify:
- Loading Image
- Start Container
when: node_nums <= (min_cluster_num)
- block:
- name: Setting startup_mode variable
set_fact: startup_mode="cluster-query-server"
- name: Copying Druid docker-compose
template:
src: 'docker-compose.yml.j2'
dest: '{{ deploy_dir }}/{{ container_name }}/docker-compose.yml'
mode: 0644
notify:
- Loading Image
- Start Container
when: node_nums > (min_cluster_num) and inventory_hostname in groups['druid'][:2]
- block:
- name: Setting startup_mode variable
set_fact: startup_mode="cluster-data-server"
- name: Copying Druid docker-compose
template:
src: 'docker-compose.yml.j2'
dest: '{{ deploy_dir }}/{{ container_name }}/docker-compose.yml'
mode: 0644
notify:
- Loading Image
- Start Container
when: node_nums > (min_cluster_num) and inventory_hostname not in groups['druid'][:2]
- name: Copying image to {{ deploy_dir }}/{{ container_name }}/monitor
copy:
src: '{{ role_path }}/../../../software-packages/druid_exporter-1.0.0.tar'
dest: '{{ deploy_dir }}/{{ container_name }}/monitor/'
force: true
notify:
- Loading Exporter Image
- name: Config exporter config files
template:
src: 'docker-compose_exporter.yml.j2'
dest: '{{ deploy_dir }}/{{ container_name }}/monitor/docker-compose.yml'
mode: 0644
notify:
- Start Exporter Container
- meta: flush_handlers