# \[ansible-2.0.0-0.7.rc2\] os\_server\_facts module - Syntax Error while loading YAML

**URL:** <https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [December 17, 2015, 2:26pm UTC](https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040 "2015-12-17T14:26:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stavros](https://forum.ansible.com/u/Stavros)\
**Post date:** [December 17, 2015, 2:26pm UTC](https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040/1 "2015-12-17T14:26:46Z")

</div>

Hi,

I am trying to use the os\_server\_facts module, but I get a syntax error:

The inventory file “oshost” contains only the following line:  
localhost ansible\_connection=local

The playbook “os\_server\_facts.yml” is a simple as the example given in the documentation:

- os\_server\_facts:  
server: W1
- debug:  
var: openstack\_servers

And this is what I get:

[admin:~/temp](mailto:admin@cvm01485:~/temp)\> ansible-playbook -i oshost os\_server\_facts.yml  
ERROR! Syntax Error while loading YAML.

The error appears to have been in ‘/home/admin/temp/os\_server\_facts.yml’: line 2, column 1, but may  
be elsewhere in the file depending on the exact syntax problem.  
The offending line appears to be:

- os\_server\_facts:  
server: W1  
^ here  
[admin:~/temp](mailto:admin@cvm01485:~/temp)\>

By the way, the OpemStack environment variables are loaded from the RC file. Other cloud modules, like os\_server, are working properly:

[admin:~/temp](mailto:admin@cvm01485:~/temp)\> cat os\_server\_test.yml

# Test

- name: Launch an instance  
gather\_facts: no  
tasks:
- name: Launch a “Ubuntu 14 LTS” instance  
os\_server:  
state: present  
name: Test01  
image: a79d8041-b92b-49cc-82c1-fa354469bde0  
flavor: 4488da6d-6173-4112-8870-9f76d138ad00  
key\_name: ‘oskey’  
nics:
- net-id: 00d39765-718d-43c3-8256-6c73d4bb3752  
[admin:~/temp](mailto:admin@cvm01485:~/temp)\>

Any idea, why the os\_server\_facts returns a syntax error?

Regards  
Stavros

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 17, 2015, 2:31pm UTC](https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040/2 "2015-12-17T14:31:02Z")

</div>

since there is nothing apparent from the keys or values i'm going to  
guess you have a tab somewhere.

---

<div class="post-metadata">

**Author:** ![Stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stavros](https://forum.ansible.com/u/Stavros)\
**Post date:** [December 17, 2015, 2:46pm UTC](https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040/3 "2015-12-17T14:46:39Z")

</div>

Even the syntax without any tabs, empty spaces,… brings the same error:

- os\_server\_facts:  
server: W1
- debug:  
var: openstack\_servers

The offending line appears to be:

- os\_server\_facts:  
server: W1  
^ here

Regards  
Stavros

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 17, 2015, 3:59pm UTC](https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040/4 "2015-12-17T15:59:03Z")

</div>

seems to be incorrectly indented, no sure if its just email formatting:

- os\_server\_facts:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server: W1

server should be indented farther in than os\_server\_facts, but only  
using spaces, no tabs.

---

<div class="post-metadata">

**Author:** ![Stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stavros](https://forum.ansible.com/u/Stavros)\
**Post date:** [December 18, 2015, 11:08am UTC](https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040/5 "2015-12-18T11:08:30Z")

</div>

I’ve tried that already…using spaces instead of tabs…but I still get the same error.

I use actually already successfully some of the other cloud modules…but this one returns the same syntax error.

Stavros

---

<div class="post-metadata">

**Author:** ![Stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stavros](https://forum.ansible.com/u/Stavros)\
**Post date:** [December 21, 2015, 9:06am UTC](https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040/6 "2015-12-21T09:06:25Z")

</div>

I checked that with the YAML Lint and after adding/removing a couple of spaces…

- os\_server\_facts:  
server: W1
- debug:  
var: openstack\_servers

…it doesn’t return a YAML syntax error, but:

[admin:~/temp](mailto:admin@host-160-46-99-249:~/temp)\> ansible-playbook -i oshost os\_server\_facts.yml -vvvv  
Using /home/admin/.ansible.cfg as config file  
ERROR! ‘os\_server\_facts’ is not a valid attribute for a Play  
The error appears to have been in ‘/home/admin/temp/os\_server\_facts.yml’: line 1, column 3, but may  
be elsewhere in the file depending on the exact syntax problem.  
The offending line appears to be:

- os\_server\_facts:  
^ here

‘os\_server\_facts’ is not a valid attribute?? The os\_server\_facts module exists in 2.0 as far I can see: /usr/lib/python2.7/site-packages/ansible/modules/core/cloud/openstack/os\_server\_facts.py

Should I open an issue ticket?

Stavros

---

<div class="post-metadata">

**Author:** ![Jakub\_x](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@Jakub\_x](https://forum.ansible.com/u/Jakub_x)\
**Post date:** [December 21, 2015, 10:40am UTC](https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040/7 "2015-12-21T10:40:08Z")

</div>

Can You post a whole playbook? Put it on pastebin or sth.

W dniu poniedziałek, 21 grudnia 2015 10:06:25 UTC+1 użytkownik Stavros napisał:

---

<div class="post-metadata">

**Author:** ![Stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stavros](https://forum.ansible.com/u/Stavros)\
**Post date:** [December 21, 2015, 2:56pm UTC](https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040/8 "2015-12-21T14:56:06Z")

</div>

There is actually no more (for now) than these 4 lines:

[http://pastebin.com/download/uzxvCB9k](http://pastebin.com/download/uzxvCB9k)

---

<div class="post-metadata">

**Author:** ![Stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stavros](https://forum.ansible.com/u/Stavros)\
**Post date:** [January 7, 2016, 12:26pm UTC](https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040/9 "2016-01-07T12:26:13Z")

</div>

Hi there,

I upgraded to 2.0 RC3 and tested the os\_server\_facts module…and still get the same error:

ERROR! ‘os\_server\_facts’ is not a valid attribute for a Play

---

<div class="post-metadata">

**Author:** ![Stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stavros](https://forum.ansible.com/u/Stavros)\
**Post date:** [January 11, 2016, 1:53pm UTC](https://forum.ansible.com/t/ansible-2-0-0-0-7-rc2-os-server-facts-module-syntax-error-while-loading-yaml/20040/10 "2016-01-11T13:53:00Z")

</div>

Fyi, I got it finally working with the following playbook:

- name: Retrieve facts about server instances from OpenStack  
hosts: localhost  
connection: local

tasks:

- name: Retrieve facts for all W\* servers  
os\_server\_facts:  
server: W\*  
register: result
- debug:  
var: result

Hope it helps, if someone is looking for an example … 🙂
