我也遇到类似问题,看官方文档都找不到答案,不过google了半天总算解决了。拷贝一点东西供你参考。
Want to run a shell command do something with the output?
Registered variables have useful attributes like :
changed – set to boolean true if something happened (useful to tell when a task has done something on a remote machine).
stderr – contains stringy output from stderr
stdout – contains stringy output from stdout
stdout_lines – contains a list of lines (i.e. stdout split on \n).
(see above)
- name: Do something
shell: /usr/bin/something | grep -c foo || true
register: shell_output
So – we could :
- name: Catch some fish (there are at least 5)
shell: /usr/bin/somethingelse
when: shell_output.stdout > "5"
本帖最后由 expert1 于 2015-07-16 17:23 编辑
闲得无聊写了个。---
- hosts: localhost
gather_facts: no
tasks:
- name:"echo pid"
shell: ls >/dev/null 2>&1 && echo $!
register: stat_result
- debug: var=stat_result.stdout
- name: do someting else
action: shell ls -l
when: stat_result.stdout >1
register: pr
- debug:var=pr.stdout
您好,看到你的发的ansible tower如何写callbakc plugin的帖子,我现在也遇到这个问题,自定义的callback_plugin无法使用,能麻烦解决一下吗? 回复 1# bun
您好,看到你的发的ansible tower如何写callbakc plugin的帖子,我现在也遇到这个问题,自定义的callback_plugin无法使用,能麻烦解决一下吗? 3F不行么?
http://blog.chinaunix.net/uid-20778583-id-5124957.html 回复 7# expert1
感谢你的回答,我的需求是用自定义的插件对执行playbook后的facts进行写日志。callback_plugin.py已经写好,放入指定目录。使用ansible-playbook的命令,可调用此插件,但使用ansible tower执行playbook,就不能调用此插件,麻烦能帮忙解决一下这个问题吗? ansible tower没用过呀,抱歉了。
页:
[1]