標準出力ラインで「*」を拒否する必要があります。
"stdout_lines": [
"rchinnn01",
"rchinnn02",
"*"
]
- set_fact:
nfs_clients: "{{ nfs_clients_out.stdout_lines | reject('search','*') | list }}"
スクリプト出力:
TASK [set_fact] *****************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: error: nothing to repeat
fatal: [rchinnn03]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}
ベストアンサー1
正規表現「[*]」が有効です。次のドラマ
vars:
my_lines:
- "rchinnn01"
- "rchinnn02"
- "*"
tasks:
- debug:
msg: "{{ my_lines|reject('match', '[*]')|list }}"
(要約):
ok: [localhost] => {
"msg": [
"rchinnn01",
"rchinnn02"
]
}