67 lines
1.7 KiB
YAML
67 lines
1.7 KiB
YAML
---
|
|
# 校验 Rocketmq Exporter 是否安装
|
|
- name: '<{{ cmd | upper }}> | 校验 Rocketmq Exporter 是否安装'
|
|
stat:
|
|
path: '{{ flag }}'
|
|
register: ret
|
|
|
|
# 安装 Rocketmq Exporter
|
|
- block:
|
|
- name: '<{{ cmd | upper }}> | 创建 Rocketmq Exporter 相关目录'
|
|
file:
|
|
path: '{{ rocketmq_exporter.dir }}'
|
|
state: directory
|
|
|
|
- name: '<{{ cmd | upper }}> | 准备 Rocketmq Exporter Jar 包'
|
|
copy:
|
|
src: files/{{ rocketmq_exporter.jar }}
|
|
dest: '{{ rocketmq_exporter.dir }}/{{ rocketmq_exporter.jar }}'
|
|
|
|
- name: '<{{ cmd | upper }}> | 安装 Rocketmq Exporter'
|
|
template:
|
|
src: '{{ item.src }}'
|
|
dest: '{{ item.dest }}'
|
|
loop:
|
|
- src: docker-compose.yml.j2
|
|
dest: '{{ rocketmq_exporter.dir }}/docker-compose.yml'
|
|
|
|
- name: '<{{ cmd | upper }}> | 启动 Rocketmq Exporter 容器'
|
|
shell: |
|
|
. /etc/profile
|
|
cd {{ rocketmq_exporter.dir }}
|
|
docker-compose down
|
|
docker-compose up -d
|
|
|
|
# - name: '<{{ cmd | upper }}> | 等待 Rocketmq Exporter 服务启动'
|
|
# wait_for:
|
|
# port: '{{ rocketmq_exporter.port }}'
|
|
|
|
- name: '<{{ cmd | upper }}> | 创建 Rocketmq Exporter 安装标记'
|
|
shell: |
|
|
set -ex
|
|
mkdir -p ~/.flag
|
|
touch {{ flag }}
|
|
|
|
when:
|
|
- cmd == "install"
|
|
- not ret.stat.exists
|
|
- ansible_architecture == "x86_64"
|
|
|
|
# 卸载 Rocketmq Exporter
|
|
- block:
|
|
- name: '<{{ cmd | upper }}> | 卸载 Rocketmq Exporter'
|
|
shell: |
|
|
. /etc/profile
|
|
cd {{ rocketmq_exporter.dir }}
|
|
docker-compose down
|
|
|
|
- name: '<{{ cmd | upper }}> | 清除 Rocketmq Exporter 相关文件'
|
|
shell: |
|
|
rm -rf {{ rocketmq_exporter.dir }}
|
|
rm -rf {{ flag }}
|
|
|
|
when:
|
|
- cmd == "remove"
|
|
- ret.stat.exists
|
|
- ansible_architecture == "x86_64"
|