ansible 使用
1. hosts文件
[test-hosts]
192.168.32.128
192.168.32.129
192.168.32.130
[all:vars]
ansible_ssh_user=test
ansible_sudo_pass='123456'
2. ping 模块
ansible -i conf/hosts test-hosts -b --become-user=root -m ping
3. shell 模块
ansible -i conf/hosts test-hosts -b --become-user=root -m shell -a 'sh /tmp/1.sh'
4. copy 模块
ansible -i conf/hosts test-hosts -b --become-user=root -m copy -a 'src=https://www.it610.com/article/package/1.txt dest=/tmp owner=test group=test mode=0755'
【ansible 使用】5. playbook 编辑
- name: copy file
hosts: test-hosts
gather_facts: no
vars:
remote_user: test
become: yes
become_user: root
become_method: sudo
become_pass: 123456
tasks:
-name: copy script file
copy:
src: "/tmp/1.sh"
dest: "/tmp"
owner: root
group: root
mode: 0644
-name: run shell script
shell: |
sh /tmp/1.sh > /tmp/1.log
推荐阅读
- 由浅入深理解AOP
- 【译】20个更有效地使用谷歌搜索的技巧
- mybatisplus如何在xml的连表查询中使用queryWrapper
- MybatisPlus|MybatisPlus LambdaQueryWrapper使用int默认值的坑及解决
- MybatisPlus使用queryWrapper如何实现复杂查询
- iOS中的Block
- Linux下面如何查看tomcat已经使用多少线程
- 使用composer自动加载类文件
- android|android studio中ndk的使用
- 使用协程爬取网页,计算网页数据大小