Repository: ansible/ansible

Issue:
YAML with colon and equal sign
##### ISSUE TYPE
 - Bug Report

##### ANSIBLE VERSION
```
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/m/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609]

```
##### OS / ENVIRONMENT
N/A

##### SUMMARY
iam trying to solve problem with variables filled from files in form of items. 
I want to start from beginning with items, but even example doesnt work for me, so iam quite in "circle" and iam not able to solve my problem. Thank you for help. 


##### STEPS TO REPRODUCE

```yaml
- name: "loop through list"
  debug: msg="An item: {{item}}"
  with_items:
    - 1
    - 2
    - 3
```

##### EXPECTED RESULTS
list of items 

##### ACTUAL RESULTS
```
ERROR! Syntax Error while loading YAML.


The error appears to have been in '/home/m/Documents/Vagrant/postgresql/tests/roles/psql/tasks/main.yml': line 3, column 23, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: "loop through list"
  debug: msg= "An item: {{item}}"
                      ^ 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.scanner.ScannerError'>
exception: mapping values are not allowed in this context
  in "<unicode string>", line 3, column 23
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

```
  


Discussion:
@gitm1993 Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information. 

Here are the items we could not find in your description:
- component name

Please set the description of this issue with this template:
https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE.md

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: issue_missing_data --->
@gitm1993 Thanks for reporting this issue. I can reproduce this. You can workaround this as 

```yaml
    - debug:
        msg: "item : {{ item }}"
      with_items:
        - 1
        - 2
        - 3
```

which will give you something 

```
TASK [debug] *******************************************************************************************************************
ok: [localhost] => (item=1) => {
    "changed": false,
    "item": 1,
    "msg": "item : 1"
}
ok: [localhost] => (item=2) => {
    "changed": false,
    "item": 2,
    "msg": "item : 2"
}
ok: [localhost] => (item=3) => {
    "changed": false,
    "item": 3,
    "msg": "item : 3"
}
```
```yaml
    - debug: msg="An item {{':'}} {{ item }}"
      with_items:
        - 1
        - 2
        - 3
```
This also works.
@gitm1993 I think this is already documented, that you need to quote colon. You can read about the [gotchas](http://docs.ansible.com/ansible/latest/YAMLSyntax.html#gotchas).
thank you, this one work. Can you help little bit more?

what is the problem with this example? 

role/name/tasks/main.yml

    - debug: msg="An item {{':'}} {{ item }}"
      with_items: "{{ numbers }}"

role/name/default/main.yml

    numbers:
     - 1
     - 2 
     - 3

fatal: [default]: FAILED! => {"msg": "'numbers' is undefined"}
  
@Akasurde  iam not suer i understand. I read this article. Which colon i did not quote? 
You can read variable like this 

main.yml

```yaml
---
- hosts: localhost
  become_method: sudo
  gather_facts: no
  vars_files:
    - vars.yml
  tasks:
    - debug: msg="An item {{':'}} {{ item }}"
      with_items:
        "{{ numbers }}"
```

vars.yml

```
---
- numbers:
    - 1
    - 2
    - 3
```

Output:
```
TASK [debug] *******************************************************************************************************************
task path: /main.yml:7
ok: [localhost] => (item=1) => {
    "changed": false,
    "item": 1,
    "msg": "An item : 1"
}
ok: [localhost] => (item=2) => {
    "changed": false,
    "item": 2,
    "msg": "An item : 2"
}
ok: [localhost] => (item=3) => {
    "changed": false,
    "item": 3,
    "msg": "An item : 3"
}
```
@Akasurde  thank you for help. I already tried this out, but it did not work for me. Anyway can you tell me what is the difference between your and my example? Only one differnce is see is the dash (- numbers:). and of course i did not specified vars file. But by the documentation i dont need to specify vars file.Variables should be fill from /default/main.yml or /vars/main.yml. I dont think it is problem with including file with variables. There is some problem with content which iam not able to solve.

I really want to understand ansible, but it is little frustrating if iam not able to understand where is my problem. I read documentation (loops,variables,items) many times but didnt help. May be there is some misunderstading in syntax. But i follow:

http://docs.ansible.com/ansible/latest/YAMLSyntax.html#gotchas

and by the yamllint syntax is ok... 
  
i solved, thank you very much. 

Resolving patch:
diff --git a/lib/ansible/plugins/lookup/items.py b/lib/ansible/plugins/lookup/items.py
--- a/lib/ansible/plugins/lookup/items.py
+++ b/lib/ansible/plugins/lookup/items.py
@@ -23,7 +23,8 @@
 
 EXAMPLES = """
 - name: "loop through list"
-  debug: msg="An item: {{item}}"
+  debug:
+    msg: "An item: {{item}}"
   with_items:
     - 1
     - 2


Test patch: