質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ansible

Ansibleは、Python で書かれたサーバーの設定を管理するための 構成管理ツールです。

Q&A

解決済

1回答

4195閲覧

ansibleで下記playbookが動作しません。

ustst

総合スコア31

Ansible

Ansibleは、Python で書かれたサーバーの設定を管理するための 構成管理ツールです。

0グッド

0クリップ

投稿2018/07/02 10:21

playbook

- name: create log files shell: [ ! -e {{ item }} ] && touch {{ item }} && chmod 640 with_items: - "/var/log/snmplog" - "/var/log/ftp.log" changed_when: false

エラー内容

ERROR! Syntax Error while loading YAML. The error appears to have been in '/xxxx/xxxx/xxxx/xxx/tasks/main.yml': line 140, column 17, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: - name: create log files shell: [ ! -e {{ item }} ] && touch {{ item }} && chmod 640 ^ here We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value. For instance: with_items: - {{ foo }} Should be written as: with_items: - "{{ foo }}" exception type: <class 'yaml.parser.ParserError'> exception: while parsing a flow sequence in "<unicode string>", line 140, column 10 did not find expected ',' or ']' in "<unicode string>", line 140, column 17

なお140行目はshell:の部分です。

どこが問題なのでしょうか?
ダブルクォートでくくってみたりしましたが、うまく動作しませんでした。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

エラーの原因はわかりませんが、[test に置き換えると動作しました。

shell: test ! -e {{ item }} && touch {{ item }} && chmod 640 {{ item }}

投稿2018/07/04 12:50

TaichiYanagiya

総合スコア12141

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ustst

2018/07/05 03:12

ありがとうございます。 まだ試してませんが、エスケープとかすればいけたのかもですね。 ひとまずはtestコマンドでやろうと思います。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問