标签:errors use pat lse man install log command 剧本
在剧本中设置循环信息
vim test04.yml
vim test05.yml
实践配置:
[root@m01 ansible_playbook]# cat test_循环功能.yaml
扩展说明:单独加载指定主机清单文件
ansible-playbook nfs_auto.yaml -i ./nfs_hosts
-i 指定加载主机清单
在剧本中设置忽略错误
默认playbook会检查命令和模块的返回状态,如遇到错误就中断playbook的执行
可以加入ignore_errors: yes忽略错误
vim test06.yml
- hosts: all
remote_user: root
tasks:
- name: Ignore False
command: /bin/false
ignore_errors: yes
- name: touch new file
file: path=/tmp/oldboy_ignore state=touch
实践配置:
[root@m01 ansible_playbook]# cat test_忽略错误.yaml
- hosts: 172.16.1.7
tasks:
- name: create user
shell: useradd oldboy01 -s /sbin/nologin -M
ignore_errors: yes
- name: create dir
shell: mkdir /oldboy
ignore_errors: yes
- name: create file
shell: touch /etc/oldboy.txt
标签:errors use pat lse man install log command 剧本
原文地址:https://www.cnblogs.com/yangtao416/p/14595934.html