bun 发表于 2014-09-17 18:34

expert1 发表于 2015-07-16 15:49

回复 1# bun


    我也遇到类似问题,看官方文档都找不到答案,不过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:16

本帖最后由 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

xiaoniuhong 发表于 2015-11-02 19:16

您好,看到你的发的ansible tower如何写callbakc plugin的帖子,我现在也遇到这个问题,自定义的callback_plugin无法使用,能麻烦解决一下吗?

xiaoniuhong 发表于 2015-11-02 19:16

回复 1# bun


    您好,看到你的发的ansible tower如何写callbakc plugin的帖子,我现在也遇到这个问题,自定义的callback_plugin无法使用,能麻烦解决一下吗?

expert1 发表于 2015-11-03 09:55

3F不行么?

expert1 发表于 2015-11-03 09:55

http://blog.chinaunix.net/uid-20778583-id-5124957.html

xiaoniuhong 发表于 2015-11-03 18:35

回复 7# expert1


    感谢你的回答,我的需求是用自定义的插件对执行playbook后的facts进行写日志。callback_plugin.py已经写好,放入指定目录。使用ansible-playbook的命令,可调用此插件,但使用ansible tower执行playbook,就不能调用此插件,麻烦能帮忙解决一下这个问题吗?

expert1 发表于 2015-11-04 11:06

ansible tower没用过呀,抱歉了。
页: [1]
查看完整版本: ansible tower如何写callback plugin?