ansible远程执行命令

一、ansible简介

需要在一台机器上搭建ansible环境,且配置目的ip的密码,通道没有问题即可下发命令

使用的通道是ssh(端口:36000)

二、搭建细节

1、安装ansible

yum install -y ansible

2、把目的ip密码写到配置文件中

vim /etc/ansible/hosts

配置文件例如,

[outside_muji]
你的IP	ansible_ssh_user=root ansible_ssh_port=36000  ansible_ssh_pass=你的密码
你的IP	ansible_ssh_user=root ansible_ssh_port=36000  ansible_ssh_pass=你的密码

3、修改免密登录

vim /etc/ansible/ansible.cfg
在文件中进行搜索定位
:/host_key_checking

修改前:
# uncomment this to disable SSH key host checking
#host_key_checking = False
修改后:
# uncomment this to disable SSH key host checking
host_key_checking = False

4、执行你想批量执行的命令

ansible outside_muji -m shell -a "date"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值