Error in expansible script

13 views
Skip to first unread message

Shahzad Adil shaikh

unread,
Jul 26, 2019, 2:13:11 AM7/26/19
to Ansible Project
Hello All,

I am trying to execute the following yml script but some errors are occurring ,please some help me out this error . 

Script:-
---
- hosts: all
  tasks:
   - name: Import Remi GPG key
    rpm_key: "key={{ item }} state=present"
    with_items:
  - name: Install Remi repo.
    command: "rpm -Uvh --force {{ item.href }} creates={{ item.creates }}"
    with_items:
        creates: "/etc/yum.repos.d/remi.repo"
  - name: Install EPEL repo.
    yum: name=epel-release state=present
  - name: Ensure firewalld is stopped
    service: name=firewalld state=stopped
  - name: Install Node.js and npm
    yum: name=npm state=present enablerepo=epel
  - name: Install Forever
    npm: name=forever global=yes state=latest

Error:-
ERROR! Syntax Error while loading YAML.


The error appears to have been in '/home/shahzad/playbook.yml': line 5, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

   - name: Import Remi GPG key
    rpm_key: "key={{ item }} state=present"
    ^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes.  Always quote template expression brackets when they
start a value. For instance:

    with_items:
      - {{ foo }}

Should be written as:

    with_items:
      - "{{ foo }}"

exception type: <class 'yaml.parser.ParserError'>
exception: while parsing a block collection
  in "<unicode string>", line 4, column 4
did not find expected '-' indicator
  in "<unicode string>", line 5, column 5

 

Stefan Hornburg (Racke)

unread,
Jul 26, 2019, 2:16:24 AM7/26/19
to ansible...@googlegroups.com
The indentation is incorrect in the line with "rpm_key". It needs the same position as "name".

Regards
Racke

>
>
> The error appears to have been in '/home/shahzad/playbook.yml': line 5, column 5, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>    - name: Import Remi GPG key
>     rpm_key: "key={{ item }} state=present"
>     ^ here
> We could be wrong, but this one looks like it might be an issue with
> missing quotes.  Always quote template expression brackets when they
> start a value. For instance:
>
>     with_items:
>       - {{ foo }}
>
> Should be written as:
>
>     with_items:
>       - "{{ foo }}"
>
> exception type: <class 'yaml.parser.ParserError'>
> exception: while parsing a block collection
>   in "<unicode string>", line 4, column 4
> did not find expected '-' indicator
>   in "<unicode string>", line 5, column 5
>
>  
>
> --
> 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 <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b78e0ad5-b7a4-41ae-b915-deb786f13b53%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/b78e0ad5-b7a4-41ae-b915-deb786f13b53%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Mark Anthony Garcia

unread,
Jul 26, 2019, 2:25:52 AM7/26/19
to Ansible Project
like Stefan said rpm_key and with_items needs to be in the same line as name.

Dick Visser

unread,
Jul 26, 2019, 6:01:08 AM7/26/19
to ansible...@googlegroups.com
Basically like https://gist.github.com/mariusv/71e6e75941d495956234
> --
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b78e0ad5-b7a4-41ae-b915-deb786f13b53%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
Reply all
Reply to author
Forward
0 new messages