提交各组件部署Ansible剧本初版
This commit is contained in:
48
Apache Ignite/2.15.0/ignite/role/tasks/deploy.yml
Normal file
48
Apache Ignite/2.15.0/ignite/role/tasks/deploy.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
- block:
|
||||
- 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: Creating directory
|
||||
file:
|
||||
state: directory
|
||||
path: '{{ deploy_dir }}/{{ container_name }}/{{ item.dir }}'
|
||||
with_items:
|
||||
- { dir: 'config' }
|
||||
|
||||
- name: unpack libs.zip
|
||||
unarchive:
|
||||
src: 'files/libs.zip'
|
||||
dest: '{{ 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 config files
|
||||
template:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
mode: 0644
|
||||
with_items:
|
||||
- { src: 'docker-compose.yml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/docker-compose.yml' }
|
||||
- { src: 'default-config.xml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/config/default-config.xml' }
|
||||
notify:
|
||||
- Start Container
|
||||
|
||||
- meta: flush_handlers
|
||||
|
||||
|
||||
10
Apache Ignite/2.15.0/ignite/role/tasks/main.yml
Normal file
10
Apache Ignite/2.15.0/ignite/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) == "uninstall"
|
||||
|
||||
17
Apache Ignite/2.15.0/ignite/role/tasks/status-check.yml
Normal file
17
Apache Ignite/2.15.0/ignite/role/tasks/status-check.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
- name: Waitting for Kafka running,60s
|
||||
shell: sleep 60
|
||||
|
||||
- name: Check if the Kafka already exists
|
||||
shell: ps -ef | grep -v grep | grep kafka.Kafka | wc -l
|
||||
register: process_out
|
||||
|
||||
- name: Check if the Kafka already exists
|
||||
shell: netstat -anlp | egrep "9092|9094|9095" | 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 != '3'
|
||||
28
Apache Ignite/2.15.0/ignite/role/tasks/uninstall.yml
Normal file
28
Apache Ignite/2.15.0/ignite/role/tasks/uninstall.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
- 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
|
||||
|
||||
- name: Checking ZooKeeper has Ignite nodes
|
||||
shell: "docker exec -it zookeeper zkCli.sh ls / | grep apacheIgnite | wc -l"
|
||||
run_once: true
|
||||
delegate_to: "{{ groups.zookeeper[0] }}"
|
||||
register: has_zknode
|
||||
|
||||
- name: Delete Ignite nodes in ZooKeeper
|
||||
shell: "docker exec -it zookeeper zkCli.sh rmr /apacheIgnite"
|
||||
run_once: true
|
||||
delegate_to: "{{ groups.zookeeper[0] }}"
|
||||
when: has_zknode.stdout >= '1'
|
||||
Reference in New Issue
Block a user