2017-04-06 50 views
0

我正在尝试创建一个docker容器,该容器使用Ansible生成一个secretkey,但docker_container似乎没有返回容器输出。Ansible:在容器创建期间获取码头容器输出

如果我ssh到服务器并运行

[email protected]:~# docker run --rm sentry-onpremise config generate-secret-key 

我得到所需的输出。一个密钥,如本

q16w8(5s9_+%[email protected]%c%0uzb&agf0pn+6zfocraponasww&r)f 

但是,如果我尝试运行使用Ansible剧本相同的命令,泊坞窗容器被执行,但没有返回值:

... 
- name: Cria secret key para utilizacao em passos seguintes 
    docker_container: 
    name: sentry-key-generator 
    cleanup: True 
    image: sentry-onpremise 
    command: config generate-secret-key 
    register: saida 
    tags: 
    - debug 

- fail: 
    msg: "Valor de saida: {{ saida }}" 
    tags: 
    - debug 
... 

致命的: [45.56.93.133]:失败! => { “changed”:false, “failed”:true, “invocation”:{ “module_args”:{ “msg”:“Valor de saida:{u'changed':True,u'ansible_facts “:{}}” }, “MODULE_NAME”: “失败” }, “味精”: “华莱德赛达:{u'changed ':真,u'ansible_facts':{}}”

这是docker_container模块的限制吗?我是否必须在docker中设置任何其他配置或者能够获取容器输出?

回答

0

这是Ansible 2.2.x中引入的一个错误,它将ansible_docker_container从结果中剥离出来。

参见:
https://github.com/ansible/ansible/issues/22323
https://github.com/ansible/ansible/issues/20543

补丁:
https://github.com/ansible/ansible/pull/22324/files

修复的方法是用Ansible 2.3.x版本发布

+0

我会测试开发/ 2.3分支明天检查问题是否得到解决。谢谢! –

+0

我的ubuntu更新了Ansible到版本2.3,但仍然没有解决这个问题。我收到了很多有关容器(卷,网络,名称等)的数据,但没有收集到主机可以看到的标准输出数据。任何其他方式我可以实现这一目标? –

+1

你是否设置'detach:false'? –