首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Ansible中显示横幅消息

在Ansible中显示横幅消息
EN

Stack Overflow用户
提问于 2017-03-19 01:12:21
回答 3查看 15.7K关注 0票数 16

我想在运行攻略完成后在Ansible中显示一条横幅消息,为下一步提供说明。这就是我所做的:

代码语言:javascript
复制
- 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

但这给出了一个丑陋的输出,如下所示:

代码语言:javascript
复制
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消息?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-03-19 10:30:10

我在我的行动手册中做了类似的事情。不如像这样重新构建一下:

代码语言:javascript
复制
  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') }

输出

代码语言:javascript
复制
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",
        ""
    ]
}

另一种选择是将横幅作为列表传递:

代码语言:javascript
复制
  - 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'

输出

代码语言:javascript
复制
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"
    ]
}
票数 22
EN

Stack Overflow用户

发布于 2019-05-09 22:58:08

也许不完全是你(和我)想要的,但如果你想通知重要的事情,又不想让它埋没在你的行动手册中,那就运行吧。有一个Slack模块:https://docs.ansible.com/ansible/latest/modules/slack_module.html

票数 0
EN

Stack Overflow用户

发布于 2021-08-26 16:19:44

这里的其他答案对我不起作用,因为所有行都被连接在一起(无论我怎么尝试),这是不可读的。

解决方案是使用Pause模块,如an answer to another question中所述。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42877391

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档