04ansible shell script模块使用案例
标签(空格分隔): ansible后
内容说明
shell模块
说明
演示
模块2
演示
创建成功
模块3
演示
chdir 创建多个文件时 不用重复写绝对路径
ansible-doc shell
模块4
演示
ansible test -m shell -a “ssh-keygen -f ~/.ssh/id_rsa -N ‘’ creates=~/.ssh/id_rsa”
test 无密钥文件
创建成功
再次执行,跳过,提示文件已存在
ansible node1,node2 -m shell -a ‘unzip /root/test.zip removes=/bin/unzip’
一个装unzip并且有文件,有个没装unzip当有文件
有unzip 执行成功, 无unzip跳过不执行
这是判断模块
帮助文档
scipt模块
演示
受控主机的yum要可以使用
脚本放在受控主机的临时目录下,执行完成后自动删除