ansible教程
目录
1 安装
pip3 install ansible
2 配置
配置一个名为hosts的文件中包含你要操作的主机
[spark]
cdhmaster
cdhslave1
cdhslave2
cdhslave3
cdhslave4
cdhslave5
cdhslave6
cdhslave7
cdhslave8
3 运行任务
创建任务文件 testcat.yml
- hosts: spark
user: nisl
tasks:
- name: cat securelog
become: yes
become_user: root
become_method: sudo
shell: cat /var/log/secure
运行任务
ansible-playbook -i hosts --ask-become-pass testcat.yml