我希望在完成运行剧本后在Ansible中显示横幅消息,并提供后续步骤的说明。这就是我所做的:
StaticResource
但这给出了一个丑陋的输出:
- 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
有没有更好的方法来显示发布后的消息?
答案 0 :(得分:17)
我在剧本中做了类似的事情。如何重组它有点像这样:
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"
]
}
答案 1 :(得分:0)
可能并不完全是您(和我)所寻找的内容,但是如果您想通知重要的事情并且不想将其埋入您的剧本中。有一个Slack模块:https://docs.ansible.com/ansible/latest/modules/slack_module.html