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