2 Star 3 Fork 3

as4k/ysansible

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main1.yml 885 Bytes
一键复制 编辑 原始数据 按行查看 历史
kyle30 提交于 2021-01-19 23:36 +08:00 . 8789
---
- hosts: all
tasks:
- name: test1
debug:
msg: "test1"
- name: test2
shell: cat /etc/redhat-release
# .rc 在这里是固定用法表示 return code
- name: Report 'changed' when the return code is not equal to 0
shell: cat /etc/redhat-release
register: my_result
changed_when: "my_result.rc != 0"
- name: add ok.txt
copy:
content: 'service ok'
dest: /tmp/ok.txt
- name: add error.txt
copy:
content: 'service error'
dest: /tmp/error.txt
- name: test3
shell: cat /tmp/error.txt
- name: test4
shell: cat /tmp/error.txt
register: my_result
failed_when: "'error' in my_result.stdout"
- name: test5
shell: cat /tmp/ok.txt
register: my_result
failed_when: "'error' in my_result.stdout"
# ansible-playbook main1.yml
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
其他
1
https://gitee.com/as4k/ysansible.git
git@gitee.com:as4k/ysansible.git
as4k
ysansible
ysansible
master

搜索帮助