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

--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/19f955626f87a87944e891852b60376f%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to