Syntax Error while loading YAML.

23 views
Skip to first unread message

Pankaj Navneet

unread,
Feb 28, 2017, 1:05:33 AM2/28/17
to Ansible Project
Hi All,

I have written a YAML to install Nginx on my AWS Slave server. But every time i got below error while running my playbook. I googled to resolve this issue, but unable to do so. Can you guys help me in sorting what i am doing wrong here. I am using Ubuntu 16 and my YAML is,

- hosts: AWS_Slave
  tasks:
        - name: nginx
        apt_key: url=http://nginx.org/keys/nginx_signing.key state=present

        - name: nginx | Adding sources.list deb url for nginx
        lineinfile: dest=/etc/apt/sources.list line="deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx"

        - name: nginx | Updating apt cache
                apt:
                update_cache: yes

        - name: nginx | Installing nginx
                apt:
                pkg: nginx
                state: latest

        - name: nginx | Starting nginx
                service:
                name: nginx
                state: started

Kai Stian Olstad

unread,
Feb 28, 2017, 3:09:55 AM2/28/17
to ansible...@googlegroups.com
On 28.02.2017 06:24, Pankaj Navneet wrote:
> Hi All,
>
> I have written a YAML to install Nginx on my AWS Slave server. But
> every
> time i got below error while running my playbook. I googled to resolve
> this
> issue, but unable to do so. Can you guys help me in sorting what i am
> doing
> wrong here. I am using Ubuntu 16 and my YAML is,

In YAML indentation is very important, and you need to be consistent in
the indentation.


> - hosts: AWS_Slave
> tasks:
> - name: nginx
> apt_key: url=http://nginx.org/keys/nginx_signing.key
> state=present
>
> - name: nginx | Adding sources.list deb url for nginx
> lineinfile: dest=/etc/apt/sources.list line="deb
> http://nginx.org/packages/mainline/ubuntu/ xenial nginx"
>
> - name: nginx | Updating apt cache
> apt:
> update_cache: yes
>
> - name: nginx | Installing nginx
> apt:
> pkg: nginx
> state: latest
>
> - name: nginx | Starting nginx
> service:
> name: nginx
> state: started


Here is an example with indentation that should work.

- hosts: AWS_Slave
tasks:
- name: nginx
apt_key: url=http://nginx.org/keys/nginx_signing.key state=present

- name: nginx | Adding sources.list deb url for nginx
lineinfile: dest=/etc/apt/sources.list line="deb
http://nginx.org/packages/mainline/ubuntu/ xenial nginx"

- name: nginx | Updating apt cache
apt:
update_cache: yes

- name: nginx | Installing nginx
apt:
pkg: nginx
state: latest

- name: nginx | Starting nginx
service:
name: nginx
state: started

--
Kai Stian Olstad

Josh Smift

unread,
Feb 28, 2017, 9:49:29 AM2/28/17
to ansible...@googlegroups.com
KSO> In YAML indentation is very important, and you need to be consistent
KSO> in the indentation.

Also, all indentation should be space characters, not tabs.

(If you've got tabs in your playbook, could Ansible catch that and
identify the problem more clearly than it currently does?)

-Josh (j...@care.com)

(apologies for the automatic corporate disclaimer that follows)
This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
Reply all
Reply to author
Forward
0 new messages