Ansible 连接受控端sudo超时

最近在装Ansible,有一台受控端负载重,响应慢。当用Ansible连接它时,总是提示超时。

现象

主控端

  • 执行脚本
bash 复制代码
ansible 192.168.5.37 -m shell -a 'ip a| grep 192.168.'
bash 复制代码
192.168.5.37 | FAILED | rc=-1 >>
Timeout (12s) waiting for privilege escalation prompt: 

解决

受控端

  • 修改sudoers超时时间
bash 复制代码
vim /etc/sudoers

在行Defaults env_reset下增加

bash 复制代码
# 单位分钟 
Defaults    timestamp_timeout = 15

详见:Linux学习记录:sudo相关

主控端

  • 修改hosts文件
bash 复制代码
vim /etc/ansible/hosts
bash 复制代码
# 单位秒
192.168.5.37 ansible_ssh_timeout=30
  • 执行效果
bash 复制代码
ansible 192.168.5.37 -m shell -a 'ip a| grep 192.168.'
bash 复制代码
192.168.5.37 | CHANGED | rc=0 >>
    inet 192.168.5.37/24 brd 192.168.5.255 scope global noprefixroute ens192

详见:ansible.builtin.ssh connection -- connect via SSH client binary - timeout

相关推荐
遇见火星13 天前
如何使用Ansible一键部署MinIO集群?
ansible
粥周粥13 天前
ANSIBLE
ansible
码农101号13 天前
Linux中ansible模块补充和playbook讲解
linux·运维·ansible
码农101号13 天前
Linux的Ansible软件基础使用讲解和ssh远程连接
ansible
烟雨书信14 天前
ANSIBLE运维自动化管理端部署
运维·自动化·ansible
碎碎-li14 天前
ANSIBLE(运维自动化)
运维·自动化·ansible
@donshu@17 天前
Linux运维-ansible-python开发-获取inventroy信息
linux·运维·ansible
Kendra91920 天前
Ansible
ansible
꧁༺朝花夕逝༻꧂23 天前
Ansible小试牛刀
ansible
꧁༺朝花夕逝༻꧂23 天前
Ansible+Zabbix-agent2快速实现对多主机监控
运维·ansible