提交各组件部署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,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