Unable to pass dict as a parameter in the ansible module

975 views
Skip to first unread message

Dheeraj Panyam

unread,
Jun 1, 2015, 8:44:21 AM6/1/15
to ansible...@googlegroups.com
I am trying to pass a dict as a parameter in the Ansible Module but it is giving me error "{"msg": "unable to evaluate dictionary for devices", "failed": true}"

Devices is the parameter below which i am trying to pass, please help

ansible/hacking/test-module -m /usr/share/ansible/monitoring/my_maintenance.py -a "schedule_type="One-Time" devices="{"hostName":"HYDLPT326"}" start_time=2015-06-01T16:00:00+0000 end_time=2015-06-01T16:30:00+0000 timezone="Asia/Calcutta" client_id=client_2655"

O/p is below
----------------

***********************************
RAW OUTPUT
{"msg": "unable to evaluate dictionary for devices", "failed": true}


***********************************
PARSED OUTPUT
{
    "failed": true,
    "msg": "unable to evaluate dictionary for devices"
}

Lowell Alleman

unread,
Jun 13, 2015, 2:16:56 PM6/13/15
to ansible...@googlegroups.com

I was running into the same issue, and your post helped me out.


Looks like a quoting issue.  I've escaped some of the double-quotes and switched to single quotes inside the dictionary.  Maybe try this:


test-module -m /usr/share/ansible/monitoring/my_maintenance.py -a "schedule_type=One-Time devices=\"{'hostName':'HYDLPT326'}\" start_time=2015-06-01T16:00:00+0000 end_time=2015-06-01T16:30:00+0000 timezone='Asia/Calcutta' client_id=client_2655"


I was missing the double-quotes around the dictionary.


Good luck!

Reply all
Reply to author
Forward
0 new messages