Syntax Error while loading YAML script, cron.yml

320 views
Skip to first unread message

Chris Olido

unread,
Sep 8, 2014, 12:17:25 AM9/8/14
to ansible...@googlegroups.com
I am creating a cron playbook, my code is as follow.

- - - - -

# Creates an entry like "* 5,2 * * ls -alh > /dev/null"
- cron: name="daily_stats" hour="* 12 * * *" job="/home/ec2-user/send_report_stats.sh"

and change to 

# Creates an entry like "* 5,2 * * ls -alh > /dev/null"

- Name Creates cron job to run the reports.

  cron: name="daily_stats" hour="* 12 * * *" job="/home/ec2-user/send_report_stats.sh"


- - - - - 

SNOTRA:TimePhone chrisolido$ ansible-playbook -i hosts cron.yml --check

ERROR: Syntax Error while loading YAML script, cron.yml

Note: The error may actually appear before this position: line 11, column 87


# Creates an entry like "* 5,2 * * ls -alh > /dev/null"

- cron: name="daily_stats" hour="* 12 * * *" job="/home/ec2-user/send_report_stats.sh"

                                                                                      ^

We could be wrong, but this one looks like it might be an issue with 

unbalanced quotes.  If starting a value with a quote, make sure the 

line ends with the same set of quotes.  For instance this arbitrary 

example:


    foo: "bad" "wolf"


Could be written as:


    foo: '"bad" "wolf"'


I tried following the example always having the same error.


TIA,

Chris

Michael DeHaan

unread,
Sep 8, 2014, 9:21:57 AM9/8/14
to ansible...@googlegroups.com
I'm missing the following example part you tried, but when you have:

- cron: name="daily_stats" hour="* 12 * * *" job="/home/ec2-user/send_report_stats.sh"


One of these is:

- cron: 'name="daily_stats" hour="* 12 * * *" job="/home/ec2-user/send_report_stats.sh"'


Or even:


- cron: 

      name: "daily_stats" 

      hour: "* 12 * * *" 

      job: "/home/ec2-user/send_report_stats.sh"


Which can be simplified to:


- cron: 

      name: daily_stats

      hour: "* 12 * * *"

      job: /home/ec2-user/send_report_stats.sh




Though the simplest thing is to just leave off quotes:

- cron: name=daily_stats hour="* 12 * * *" job=/home/ec2-user/send_report_stats.sh





--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bf35ade1-6587-4943-a87f-a8fedbd14de7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages