我想在完成运行一本剧本后在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
Run Code Online (Sandbox Code Playgroud)
但这会产生如下丑陋的输出:
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
Run Code Online (Sandbox Code Playgroud)
有没有更好的方式来显示运行后的消息?
hel*_*loV 18
我在我的剧本中做了类似的事情.如何重组它有点像这样:
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') }
Run Code Online (Sandbox Code Playgroud)
产量
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",
""
]
}
Run Code Online (Sandbox Code Playgroud)
另一种选择是将横幅作为列表传递:
- 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'
Run Code Online (Sandbox Code Playgroud)
产量
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"
]
}
Run Code Online (Sandbox Code Playgroud)