Skip to content

Instantly share code, notes, and snippets.

@webgyo
Created May 31, 2021 08:20
Show Gist options
  • Select an option

  • Save webgyo/4a5a680fae14e1f27e04b298cc1180bf to your computer and use it in GitHub Desktop.

Select an option

Save webgyo/4a5a680fae14e1f27e04b298cc1180bf to your computer and use it in GitHub Desktop.
ansibleでThe error was: template error while templating string: no filter named 'success'が出る時 #ansible #infra

Registered variableで実行コマンドの内容を出力。ls_resultに実行結果の内容を登録して最後にターミナルに表示している

- name: Run CakePHP container
  register: ls_result

- debug: var=ls_result.stdout_lines
  when: ls_result | success

- debug: var=ls_result.stderr_lines
  when: ls_result | failed

ansibleで最後に以下のエラーが出た

The error was: template error while templating string: no filter named 'success'

when:の記述方法が2.9で変更になったためと思われる。以下の書き方で直した

- debug: var=ls_result.stdout_lines
  when: ls_result is success

- debug: var=ls_result.stderr_lines
  when: ls_result is failed

[Ansible] Registered variable について調べてみた https://qiita.com/szk3/items/29e827f90a543c764a5e

Why it does not work for me? #1 swapnil-linux/ansible#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment