I'm trying to use Ansible to update Linux targets but an getting the below error:
Code:
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/home/ec2-user/Playbooks/Apply_OS_Updates/tasks/main.yml': line 7, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
name: "*"
state: latest
^ here
exception type: <class 'yaml.parser.ParserError'>
exception: while parsing a block mapping
in "<unicode string>", line 6, column 5
did not find expected key
in "<unicode string>", line 7, column 7
The playbook is:
Code:
---
- name: update packages
hosts: ansible-test-targets
become: true
yum:
name: "*"
state: latest
# check if we need a reboot
- name: check if reboot needed
stat: path=/var/run/reboot-required
register: file_reboot_required
# Stop here unless the node needs a reboot
- meta: end_play
when: not file_reboot_required.stat.exists
- name: reboot node
shell: sleep 2 && shutdown -r now "Reboot triggered by ansible"
async: 1
poll: 0
ignore_errors: true
What's going on here?