2
私はbashシェルで動作するスクリプトを持っています。私はそれをAnsibleに入れて、プレイブックに例外を与えます。エラー!いずれかのアンバランスJinja2のブロックまたは引用符、分割引数に失敗しました:
- name: add mnt to ignore_filesystems
shell: |
grep ignore_filesystem {{ cdm_path }} | awk -F'=' '{print $2}' | egrep '\^\\/mnt\*'
if [ $? -eq 0 ]; then
echo 'do nothing';
else
echo 'no';
items=$(grep ignore_filesystem {{ cdm_path }} | awk -F'=' '{print $2}')
if [ ${#items} -gt 1 ]; then
echo 'making the change'
sed -ie '/ignore_filesystem/ s~$~|^\\/mnt*~' {{ cdm_path }}
else
echo 'making the change'
sed -ie '/ignore_filesystem/ s~ignore_filesystem = *~ignore_filesystem = ^\\/mnt*~' {{ cdm_path }}
fi
fi
register: ignore_filesystems
changed_when: '"making the change" in ignore_filesystems.stdout'
脚本実行しようとしたとき、私は、次のメッセージを取得しています:これは失敗する可能性がある理由について
ERROR! failed at splitting arguments, either an unbalanced jinja2 block or quotes: grep ignore_filesystem {{ cdm_path }} | awk -F'=' '{print $2}' | egrep '\^\\/mnt\*'
if [ $? -eq 0 ]; then
echo 'do nothing';
else
echo 'no';
items=$(grep ignore_filesystem {{ cdm_path }} | awk -F'=' '{print $2}')
if [ ${#items} -gt 1 ]; then
echo 'making the change'
sed -ie '/ignore_filesystem/ s~$~|^\\/mnt*~' {{ cdm_path }}
else
echo 'making the change'
sed -ie '/ignore_filesystem/ s~ignore_filesystem = *~ignore_filesystem = ^\\/mnt*~' {{ cdm_path }}
fi
fi
The error appears to have been in '/home/username/provisioning/provisioning/edit_nimbus.yml':
line 179, column 5, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: add mnt to ignore_filesystems
^here
任意の考えを?
============================================== ===========================
UPDATE:
しようとしました>など|すべての行を同じインデントレベルにしました。それでも同じエラー
- name: add mnt to ignore_filesystems
shell: |
grep 'ignore_filesystem' {{ cdm_path }}| awk -F'=' '{print $2}' | egrep '\^\\/mnt\*';
if [ $? -eq 0 ]; then
echo 'do nothing';
else
echo 'no';
items=$(grep ignore_filesystem {{ cdm_path }} | awk -F'=' '{print $2}');
if [ ${#items} -gt 1 ]; then
echo 'making the change';
sed -ie '/ignore_filesystem/ s~$~|^\\/mnt*~' {{ cdm_path }};
else
echo 'making the change';
sed -ie '/ignore_filesystem/ s~ignore_filesystem = *~ignore_filesystem = ^\\/mnt*~' {{ cdm_path }};
fi;
fi
register: ignore_filesystems
changed_when: '"making the change" in ignore_filesystems.stdout'