Any Tool to write ansible because to many syntax issue are getting in terminal.?

20 views
Skip to first unread message

Linux Tech

unread,
Nov 19, 2018, 11:03:56 PM11/19/18
to Ansible Project
when ever i try to write something in ansible yml file it always show me syntax error.

Jonathan Lozada De La Matta

unread,
Nov 19, 2018, 11:06:25 PM11/19/18
to ansible...@googlegroups.com
well a lot of this tools are to do that more automated or give you more insight before you get to the point of running them.

On Mon, Nov 19, 2018 at 11:04 PM Linux Tech <raghuba...@gmail.com> wrote:
when ever i try to write something in ansible yml file it always show me syntax error.

--
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/28bd12f2-7ae1-4f74-ae1e-18310aa9096a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Jonathan lozada de la matta

AUTOMATION PRACTICE



 

cyril...@zi.uzh.ch

unread,
Nov 20, 2018, 12:34:01 PM11/20/18
to Ansible Project
Hi

On Tuesday, 20 November 2018 05:03:56 UTC+1, Linux Tech wrote:
when ever i try to write something in ansible yml file it always show me syntax error.


Beware of the spaces/intendation you use. If you have a list like this:
fruits:
    - Apple
    - Orange
    - Strawberry
    - Mango
All the dashes are in one line (column) and the dash starts 4 spaces after the line starts. Always write your yml files like this and avoid mixed intendations like:
fruits:
  - Apple
    - Orange
      - Strawberry
- Mango
You can also use the --syntax-check flag with ansible-playbook command on your yaml files. But it might produce errors even if there are none.

Furthermore if you start a new yaml file start with as less stuff in it as possible and test it out. Then add more stuff and test again. It is really hard to find a mistake in a 100 line long file. Much easier if you only have three lines. So start with
fruits:
    - Apple
Then when you can run that without errors you can add more fruits to the list etc.

Hope it helps,
Cyril

Reply all
Reply to author
Forward
0 new messages