Display banner message in Ansible

I want to display a banner message in Ansible after finishing the launch of the playbook, giving instructions for the next steps. This is what I did:

- 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

But this leads to an ugly conclusion:

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   

Is there a better way to display a message after startup?

+10
source share
2 answers

I do something similar in my books. How about restructuring it like this:

  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') }

Exit

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",
        ""
    ]
}

Another option is to pass the banner to the list:

  - 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'

Exit

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"
    ]
}
+17
source

maybe not exactly what you (and I) were looking for, but if you want to notify you of important things and don’t want it to be hidden in your plays. There is a Slack module: https://docs.ansible.com/ansible/latest/modules/slack_module.html.

0

Source: https://habr.com/ru/post/1015863/


All Articles