提交各组件部署Ansible剧本初版

This commit is contained in:
qidaijie
2024-01-18 15:35:33 +08:00
parent f0bd05d565
commit 0cc392df5c
262 changed files with 15927 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
[pushgateway]
192.168.45.102

View File

@@ -0,0 +1,7 @@
- hosts: pushgateway
remote_user: root
roles:
- role
vars_files:
- role/vars/main.yml

View 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

View File

@@ -0,0 +1,25 @@
- 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

View File

@@ -0,0 +1,22 @@
- name: Creating directory
file:
state: directory
path: '{{ deploy_dir }}/{{ container_name }}'
- 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 Kafka config files
template:
src: 'docker-compose.yml.j2'
dest: '{{ deploy_dir }}/{{ container_name }}/docker-compose.yml'
mode: 0644
notify:
- Start Container
- meta: flush_handlers

View 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) == "uninstall"

View File

@@ -0,0 +1,17 @@
- name: Waitting for Pushgateway running,30s
shell: sleep 30
- name: Check if the Pushgateway already exists
shell: ps -ef | grep pushgateway |grep -v grep | wc -l
register: process_out
- name: Check if the Pushgateway already exists
shell: netstat -anlp | egrep "9091" | grep LISTEN | wc -l
register: port_out
- name: To terminate execution
fail:
msg: "Kafka 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'

View File

@@ -0,0 +1,27 @@
- 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: Stopping and removing exporter container
docker_container:
name: 'kafka_exporter'
state: absent
- name: Removing old exporter image
docker_image:
name: 'kafka_exporter'
tag: 'v2.0'
state: absent
- name: Ansible delete old {{ deploy_dir }}/{{ container_name }}
file:
path: '{{ deploy_dir }}/{{ container_name }}'
state: absent

View File

@@ -0,0 +1,15 @@
version: '3'
services:
pushgateway:
image: {{ image_name }}:{{ image_tag }}
container_name: {{ container_name }}
ports:
- 9091:9091
networks:
olap:
ipv4_address: 172.20.88.12
networks:
olap:
external: true

Binary file not shown.

View File

@@ -0,0 +1,11 @@
#镜像名称
image_name: pushgateway
#镜像版本号
image_tag: 1.4.2
#容器名称
container_name: pushgateway
#组件版本
component_version: pushgateway-1.4.2