2017-03-18 5 views
6

プレイブックの実行が完了した後、バナーメッセージを「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 

をポスト実行メッセージを表示するための良い方法はありますか?

答えて

7

私のプレイブックでは、これと同様のことをしています。どのようにビットのようにそれを再構築について:

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

別のオプションリストとしてバナーを渡すことです:

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

ありがとうございます。リストオプションが好きです。 – GMaster

+0

自分のプレイブックで、 'role/myrole/vars/main.yaml'に' post_install'を追加すると、自分のプレイブックにロールを作成しました。 'vars'と同じブロックを' roles/myrole/tasks/main.yaml'に置くとエラーになります。この 'post_install'ブロックをどこに追加する必要がありますか?私はgoogleをやろうとしましたが、運はまだありません。 – Nilesh

関連する問題