- name: Distribute counect load test jars to flume lib
hosts: flume
vars:
dir:
source_lib: /application/lib/spark2
dest_lib: /flume-ng/lib
jars:
- "coucontext-api-1.0.4.RELEASE.jar"
- "coumetrics-core-1.3.4.RELEASE.jar"
- "micrometer-core-1.5.4.jar"
tasks:
- name: Download jar from hdfs
command: hadoop fs -get {{ dir.source_lib }}/{{ item }} {{dir.dest_lib}}
become: true
with_items:
- "{{ jars }}"
tags:
- download_jar
- name: Chmod for jar
become: true
file:
owner: root
group: root
mode: 0755
state: file
path: "{{ dir.dest_lib }}/{{ item }}"
with_items:
- "{{ jars }}"
tags:
- chmod_jar
playbook 做了两件事:
1) 从HDFS把jar文件下载到机器上;
2)使用file module 修改文件权限;
Creating a playbook — Ansible Documentation
Index of all Modules — Ansible Documentation
Understanding privilege escalation: become — Ansible Documentation
ansible.builtin.file module – Manage files and file properties — Ansible Documentation