Ansible使用介绍

72课时
1.9K学过
8分

课程评价 (0)

请对课程作出评价:
0/300

学员评价

暂无精选评价
2分钟

13 Shell模块

功能:和command相似,用shell执行命令

​ ansible srv -m shell -a ‘echo magedu |passwd –stdin wang’

注意:

(1)调用bash执行命令 类似 cat /tmp/stanley.md | awk -F‘|’ ‘{print $1,$2}’ &>

/tmp/example.txt 这些复杂命令,即使使用shell也可能会失败。

解决办法:写到脚本,copy到远程,执行,再把需要的结果拉回执行命令的机器

(2)可将默认模块替换为shell:

​ vim ansible.conf

​ module_name = shell

ansible srvs -m command -a ‘echo magedu |passwd –stdin wang’ 成功