gpt4 book ai didi

ansible - 在 Ansible 中显示横幅消息

转载 作者:行者123 更新时间:2023-12-02 02:49:23 25 4
gpt4 key购买 nike

我想在完成运行 playbook 后在 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

是否有更好的方法来显示运行后消息?

最佳答案

我在我的剧本中做了类似的事情。像这样重组一下怎么样:

  vars:
post_install_message: |
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_message.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"
]
}

关于ansible - 在 Ansible 中显示横幅消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42877391/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com