提交各组件部署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,2 @@
[arangodb]
192.168.45.102

View File

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

View File

@@ -0,0 +1,32 @@
#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
#arangodb 管理用户名
arangodb_default_username: root
#arangodb 管理用户密码
arangodb_default_pin: galaxy_2019
#arangodb 管理用户密码(加密)
arangodb_default_pin_encrypt: PBdMaxfC3u+HMzjjij2tyuJWeooSuZNW
#arangodb 只读用户名
arangodb_query_username: query
#arangodb 只读用户密码
arangodb_query_pin: galaxy2018
#arangodb 只读用户密码(加密)
arangodb_query_pin_encrypt: qUA355VopKSx6kwwwXZwqWWEYSu76Slz
#arangodb 只写用户名
arangodb_upsert_username: upsert
#arangodb 只写用户密码
arangodb_upsert_pin: galaxy2019
#arangodb 只写用户密码(加密)
arangodb_upsert_pin_encrypt: LDEb2OekU7iZWiFw6pUYBSozVKP27r1y

Binary file not shown.

View 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

View File

@@ -0,0 +1,43 @@
- name: Validating ArangoDB server nodes
fail:
msg: "ArangoDB only supports single instance deployment,please checking configurations/hosts -> arangodb"
when: (groups.arangodb|length) != 1
- name: Creating directory
file:
state: directory
path: '{{ deploy_dir }}/{{ container_name }}'
- name: Copying ArangoDB docker image
copy:
src: 'files/{{image_name}}-{{image_tag}}.tar'
dest: '{{ deploy_dir }}/{{ container_name }}/'
force: true
- name: Loading {{ image_name }} 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
notify:
- Loading Image
- name: Copying docker-compose.yml
template:
src: docker-compose.yml.j2
dest: '{{ deploy_dir }}/{{ container_name }}/docker-compose.yml'
backup: false
force: true
- name: Initialize arangodb
unarchive:
src: 'files/init.zip'
dest: '{{ deploy_dir }}/{{ container_name }}/'
notify:
- Loading Image
- 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) == "unload"

View File

@@ -0,0 +1,17 @@
- name: Waitting for Arangodb running,10s
shell: sleep 10
- name: Check if the Arangodb process already exists
shell: ps -ef | grep -v grep | grep -w "arangod" | wc -l
register: process_out
- name: Check if the Arangodb port already exists
shell: netstat -anlp | grep "8529" | grep LISTEN | wc -l
register: port_out
- name: To terminate execution
fail:
msg: "Arangodb 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 <= '0'

View 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

View File

@@ -0,0 +1,17 @@
version: '2'
services:
arangodb:
image: {{ image_name }}:{{ image_tag }}
restart: always
container_name: {{ container_name }}
environment:
ARANGO_ROOT_PASSWORD: "{{ arangodb_default_pin }}"
ports:
- "8529:8529"
volumes:
- "{{ deploy_dir }}/{{ container_name }}/conf:/etc/arangodb3"
- "{{ deploy_dir }}/{{ container_name }}/data:/var/lib/arangodb3"
- "{{ deploy_dir }}/{{ container_name }}/log:/var/log/arangodb3"
restart: always
network_mode: "host"

View File

@@ -0,0 +1,8 @@
#镜像名称
image_name: arangodb
#镜像版本号
image_tag: 3.6.4
#容器名称
container_name: arangodb