[ansible-2.0.0-0.7.rc2] os_server_facts module - Syntax Error while loading YAML

639 views
Skip to first unread message

Stavros

unread,
Dec 17, 2015, 9:28:35 AM12/17/15
to Ansible Project
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> 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



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

admin:~/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>

Any idea, why the os_server_facts returns a syntax error?

Regards
Stavros

Brian Coca

unread,
Dec 17, 2015, 9:31:10 AM12/17/15
to Ansible Project
since there is nothing apparent from the keys or values i'm going to
guess you have a tab somewhere.



--
Brian Coca

Stavros

unread,
Dec 17, 2015, 9:46:39 AM12/17/15
to Ansible Project
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

Brian Coca

unread,
Dec 17, 2015, 10:59:09 AM12/17/15
to Ansible Project
seems to be incorrectly indented, no sure if its just email formatting:

- os_server_facts:
server: W1

server should be indented farther in than os_server_facts, but only
using spaces, no tabs.
--
Brian Coca

Stavros

unread,
Dec 18, 2015, 6:08:31 AM12/18/15
to Ansible Project
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

Stavros

unread,
Dec 21, 2015, 4:06:25 AM12/21/15
to Ansible Project
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> 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

Jakub x

unread,
Dec 21, 2015, 9:35:51 AM12/21/15
to Ansible Project
Can You post a whole playbook? Put it on pastebin or sth.

Stavros

unread,
Dec 21, 2015, 9:56:06 AM12/21/15
to Ansible Project
There is actually no more (for now) than these 4 lines:



Stavros

unread,
Jan 7, 2016, 7:26:14 AM1/7/16
to Ansible Project
Hi there,

I upgraded to 2.0 RC3 and tested the os_server_facts module...and still get the same error:

Stavros

unread,
Jan 11, 2016, 8:53:00 AM1/11/16
to Ansible Project
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 ...  :-) 
Reply all
Reply to author
Forward
0 new messages