Stavros
(Stavros)
December 17, 2015, 2:26pm
1
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:
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
(Brian Coca)
December 17, 2015, 2:31pm
2
since there is nothing apparent from the keys or values i'm going to
guess you have a tab somewhere.
Stavros
(Stavros)
December 17, 2015, 2:46pm
3
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
(Brian Coca)
December 17, 2015, 3:59pm
4
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.
Stavros
(Stavros)
December 18, 2015, 11:08am
5
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
(Stavros)
December 21, 2015, 9:06am
6
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’ 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
(Jakub x)
December 21, 2015, 10:40am
7
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ł:
Stavros
(Stavros)
December 21, 2015, 2:56pm
8
There is actually no more (for now) than these 4 lines:
http://pastebin.com/download/uzxvCB9k
Stavros
(Stavros)
January 7, 2016, 12:26pm
9
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
Stavros
(Stavros)
January 11, 2016, 1:53pm
10
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 …