在Ansible中显示横幅消息

在Ansible中显示横幅消息,ansible,Ansible,我想在运行完剧本后,在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

我想在运行完剧本后,在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: |
      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:\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: |
      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",
        ""
    ]
}
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",
        ""
    ]
}
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"
    ]
}

也许不完全是你(和我)在寻找什么,但如果你想通知重要的事情,不想让它埋在你的剧本运行。有一个松弛模块:

谢谢,我喜欢列表选项。当我在我的
roles/myrole/vars/main中添加
post\u install
时,我在我的playbook中开发了角色。yaml
它在运行我的playbook后不会显示消息。当我在
roles/myrole/tasks/main.yaml
中放置与
vars
相同的块时,它给出了错误。我应该在哪里添加此
post\u install
块?我试着用谷歌,但还没有成功。