21
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ansible | シェルの標準出力を ansible-playbook コマンドで出力させる

Last updated at Posted at 2018-06-30

いちどシェルの実行結果をいちどansibleの変数 ( return_from_shell ) に入れてから、 デバッグモジュールで表示させる例。

playbook の例

echo_shell_stdout.yml
---
- hosts: example
  tasks:
    - name: execute shell
      shell: echo some message
      register: return_from_shell # 実行結果をansible変数に入れる
      changed_when: no
    - name: show previous shell stdout
      debug:
        msg: "{{ return_from_shell.stdout }}" # .stdout に標準出力の結果が入っている

結果例

image.png

参考

環境

  • ansible 2.4

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

21
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?