Authored by Your Name

add bigdata deploy.yml

---
- 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 }}
... ...