Ansible Yaml Editor

47 views
Skip to first unread message

Maha Sallam

unread,
Oct 4, 2018, 7:02:48 AM10/4/18
to Ansible Project
Hello ,
I am new to Ansible and I am trying to follow the steps in the below links to to Install nginx and webserver but when I am copy the code as it is and run it  , it gives me an error similar to "ERROR! Syntax Error while loading YAML." although I am using online Yaml Validator and it says "YAML IS VALID" 

I need Ansible/Yaml Editor when I past the code on it , it can restructure the file automatically to a valid one and adjust spaces and tabs!

---
- hosts: Appserver
  become: true
  tasks:
        - name: install apache
          apt: name=apache2 state=present update_cache=yes
        - name: deleted index.html
          file: path=/var/www/html/index.html state=absent
          notify: restart apache2

  handlers:
        - name: restart apache2
          service: name=apache2 state=restarted

- hosts: App1
  become: true
  tasks:
        - name: set up index.html for first web server
          copy: content="<html><header><title>Welcome to Server 1</title></header><body>Hello from Server 1!</body></html>" dest=/var/www/html/index.html mode=0644
          notify: restart apache2

  handlers:
        - name: restart apache2
          service: name=apache2 state=restarted

- hosts: App2
  become: true
  tasks:
        - name: set up index.html for second web server
          copy: content="<html><header><title>Welcome to Server 2</title></header><body>Hello from Server 2!</body></html>" dest=/var/www/html/index.html mode=0644
          notify: restart apache2

  handlers:
        - name: restart apache2
          service: name=apache2 state=restarted

  • Sample output after Running Playbook:
The offending line appears to be:

- hosts: Appserver
    become: true
          ^ here


Jean-Yves LENHOF

unread,
Oct 4, 2018, 7:39:33 AM10/4/18
to ansible...@googlegroups.com, Maha Sallam
Le 2018-10-04 13:02, Maha Sallam a écrit :
> Hello ,
> I am new to Ansible and I am trying to follow the steps in the below
> links to to Install nginx and webserver but when I am copy the code as
> it is and run it , it gives me an error similar to "ERROR! Syntax
> Error while loading YAML." although I am using online Yaml Validator
> and it says "YAML IS VALID"
>
> I need Ansible/Yaml Editor when I past the code on it , it can
> restructure the file automatically to a valid one and adjust spaces
> and tabs!

Visual Studio Code from Microsoft with some ansible plugins is quite a
good choice

Regards,

JYL

Kai Stian Olstad

unread,
Oct 4, 2018, 7:57:07 AM10/4/18
to ansible...@googlegroups.com
On 04.10.2018 13:02, Maha Sallam wrote:
> I need Ansible/Yaml Editor when I past the code on it , it can
> restructure
> the file automatically to a valid one and adjust spaces and tabs!

Hopefully it wont adjust tabs since tabs isn't allow to be used in
indentation of YAML.

I don't know of any editors that restructure YAML/Ansible YAML on paste,
but there are editors that can help in showing where the error is.
If you are using vim there are several plugins out there, one of them is
https://github.com/pearofducks/ansible-vim

--
Kai Stian Olstad

Jonathan Lozada De La Matta

unread,
Oct 4, 2018, 7:57:31 AM10/4/18
to ansible...@googlegroups.com, maha.hu...@gmail.com

--
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/53c4bf3ccfc8e2fe31e858a48772d3d6%40lenhof.eu.org.
For more options, visit https://groups.google.com/d/optout.


--

Jonathan lozada de la matta

AUTOMATION PRACTICE



 

Reply all
Reply to author
Forward
0 new messages