deploy.yml
2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
- hosts: mvn-host
remote_user: root
tasks:
- name: "清理打包环境: /Data/project/{{ project }}"
command: rm -rf "/Data/project/{{ project }}"
- name: "拉取最新工程代码 {{ project_git }}"
command: git clone "{{ project_git }}" "/Data/project/{{ project }}"
- name: "编译/打包..."
shell: sh /Data/project/{{ project }}/deploy/build.sh
args:
chdir: "/Data/project/{{ project }}"
- name: "查找压缩文件"
find:
paths: "/Data/project/{{ project }}"
patterns: "*with-dependencies.jar"
recurse: yes
register: file_to_copy
- name: "准备压缩"
copy:
remote_src: yes
src: "{{ item.path }}"
dest: /Data/project/{{ project }}/
with_items: "{{ file_to_copy.files }}"
- name: "压缩可执行文件包"
archive:
path:
- /Data/project/{{ project }}/*with-dependencies.jar
- /Data/project/{{ project }}/deploy
format: tar
dest: /Data/{{ project }}.tar
- name: "拉取可执行文件包"
fetch:
src: /Data/{{ project }}.tar
dest: /tmp/project/{{ project }}.tar
flat: yes
- hosts: "{{ emr }}"
remote_user: root
sudo: yes
sudo_user: hadoop
tasks:
- name: "source bashrc file"
shell: "{{ item }}"
with_items:
- source /etc/profile
- name: "清理emr提交机执行环境"
command: rm -rf /home/hadoop/run/{{ project }}.tar /home/hadoop/run/{{ project }}
- name: "创建emr提交机执行环境"
command: mkdir -p /home/hadoop/run/{{ project }}
- name: "上传可执行文件包"
copy:
src: /tmp/project/{{ project }}.tar
dest: /home/hadoop/run/
- name: "解压可执行文件包"
unarchive:
src: /home/hadoop/run/{{ project }}.tar
dest: /home/hadoop/run/{{ project }}
remote_src: yes
- name: "停止emr正在执行的App {{ app }}"
shell: sh /home/hadoop/run/{{ project }}/deploy/kill.sh {{ app }}
- name: "启动App"
shell: sh /home/hadoop/run/{{ project }}/deploy/start.sh {{ app | default('-') }} {{ app_config | default('-') }} {{ main_class }} {{ main_args | default('-') }} /home/hadoop/run/{{ project }}/{{ main_jar }}