私はYAMLには新人です。私は何者かがキーとなり、どちらがリストなのか混乱しています。例えば以下のプレイブックでは、 " - "はリスト項目を表しているようです。YAML構文のリストやキーに混乱が起きる可能性のある遊び方
---
- hosts: all
gather_facts: no
sudo: yes
tasks:
- name: Ensure NTP is installed.
yum: name=ntp state=present
- name: ensure ntp is running
service: name=ntpd state=started enabled=yes
のでhost
は、リストのキーとall
であるが、その値が、リストの辞書は- hosts
としてキーでもgather_facts: no
、sudo: yes
とtask: ...
のですか?
yamllint.comに上記の脚本を実行しているとき、私は次のような出力が得られます。
---
-
gather_facts: false
hosts: all
sudo: true
tasks:
-
name: "Ensure NTP is installed."
yum: "name=ntp state=present"
-
name: "ensure ntp is running"
service: "name=ntpd state=started enabled=yes"
"hosts:、gather_facts:、sudo:and tasks:"はリスト(キー)項目です(リストのキー項目がアイテムの前に " - "例えば " - " gather_facts:no 、 - sudo:yes ")。サブタスクが のキー "tasks:"と同様に、「NTPがインストールされていることを確認してください。 yum: "name = ntp state = present" - 一部のキー値の前に " - "を付けないでください。 –