我想在运行攻略完成后在Ansible中显示一条横幅消息,为下一步提供说明。这就是我所做的:
- name: display post install message
debug:
msg: |
Things left to do:
- enable dash to dock gnome plugin in gnome tweal tool
- install SpaceVim plugins: vim "+call dein#install()" +qa
- git clone the dotfiles repo但这给出了一个丑陋的输出,如下所示:
TASK [display post install message] ********************************************
ok: [localhost] => {
"msg": "Things left to do:\n- enable dash to dock gnome plugin in gnome tweal tool\n- install SpaceVim plugins: vim \"+call dein#install()\" +qa\n- git clone the dotfiles repo\n"
}
PLAY RECAP *********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0 有没有更好的方式来显示post run消息?
发布于 2017-03-19 10:30:10
我在我的行动手册中做了类似的事情。不如像这样重新构建一下:
vars:
post_install: |
Things left to do:
- enable dash to dock gnome plugin in gnome tweal tool
- install SpaceVim plugins: vim "+call dein#install()" +qa
- git clone the dotfiles repo
tasks:
- name: display post install message
debug: msg={{ post_install.split('\n') }输出
TASK [display post install message] ********************************************
ok: [localhost] => {
"msg": [
"Things left to do:",
" - enable dash to dock gnome plugin in gnome tweal tool",
" - install SpaceVim plugins: vim \"+call dein#install()\" +qa",
" - git clone the dotfiles repo",
""
]
}另一种选择是将横幅作为列表传递:
- name: display post install message
debug:
msg:
- 'Things left to do:'
- '- enable dash to dock gnome plugin in gnome tweal tool'
- '- install SpaceVim plugins: vim "+call dein#install()" +qa'
- '- git clone the dotfiles repo'输出
TASK [display post install message] ********************************************
ok: [localhost] => {
"msg": [
"Things left to do:",
"- enable dash to dock gnome plugin in gnome tweal tool",
"- install SpaceVim plugins: vim \"+call dein#install()\" +qa",
"- git clone the dotfiles repo"
]
}发布于 2019-05-09 22:58:08
也许不完全是你(和我)想要的,但如果你想通知重要的事情,又不想让它埋没在你的行动手册中,那就运行吧。有一个Slack模块:https://docs.ansible.com/ansible/latest/modules/slack_module.html
发布于 2021-08-26 16:19:44
这里的其他答案对我不起作用,因为所有行都被连接在一起(无论我怎么尝试),这是不可读的。
解决方案是使用Pause模块,如an answer to another question中所述。
https://stackoverflow.com/questions/42877391
复制相似问题