Reputation: 31
I do have a role foo
defined this way:
# roles/foo/tasks/main.yml
---
- name: restart Apache
systemd:
name: apache2
state: restarted
daemon_reload: yes
bute when I start the playbook which requests this role then I get this error:
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/root/roles/foo/tasks/main.yml': line 4, column 12, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: restart Apache
systemd:
^ here
I do not understand what is wrong here because I found such samples in the documentation...
(I left out the other parts which are defined in this role and are working well)
Upvotes: 2
Views: 5681
Reputation: 68479
Fix indentation:
---
- name: restart Apache
systemd:
name: apache2
state: restarted
daemon_reload: yes
I do not understand what is wrong here because I found such samples in the documentation...
Indentation in YAML is significant for interpretation. Certain elements must be defined at the same level.
Notice that systemd:
line ends with a colon and is followed by an indented block (where the whole block becomes its value), while name:
has value restart Apache
defined in the same line.
Upvotes: 1