python ansible后台批处理

2 篇文章 0 订阅

官网
当前这个只能支持linux机器作为主机。
主页

安装

在centos中安装:

sudo yum install ansible -y
sudo pip install paramiko PyYAML Jinja2 httplib2 six

ubuntu安装:

sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible -y
sudo pip install paramiko PyYAML Jinja2 httplib2 six

配置自己的hosts文件

$ echo "127.0.0.1" > ~/ansible_hosts
$ export ANSIBLE_HOSTS=~/ansible_hosts
[cq]
gs1 ansible_ssh_user=cq ansible_ssh_host=39.106.154.40
gs2 ansible_ssh_user=cq ansible_ssh_host=47.93.13.164
gs3 ansible_ssh_user=cq ansible_ssh_host=101.200.55.213
[local]
sss2 ansible_ssh_user=zqj ansible_ssh_host=192.168.22.223
sss3 ansible_ssh_user=zqj ansible_ssh_host=192.168.22.225
sss4 ansible_ssh_user=zqj ansible_ssh_host=192.168.22.224

拷贝文件

ansible-doc -s copy
ansible [dst_name] -m copy -a 'src=httpd.conf dest=/tmp/ owner=root group=root mode=644 backup=yes'

参考文档

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值