使用ansible 分发jar到各机器节点

- 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

Ansible之Playbook使用_ansible playbook_草莓甜甜圈的博客-CSDN博客

自动化运维工具-----Ansible playbook详解_EoinXu的博客-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值