{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Passed out:
{'Version': '2012-10-17', 'Statement': [{'Action': 'sts:AssumeRole', 'Principal': {'Service': 'ec2.amazonaws.com'}, 'Effect': 'Allow', 'Sid': ''}]}
Hi,
On May 5, 2016 8:14 AM, "Rob White" <robwh...@gmail.com> wrote:
>
> Hi all,
>
> This is mostly aimed at the core team...
>
> Can you explain why the file lookup plugin changes the contents of the file as far as quotes are concerned? I.e. it changes all double quotes to single quotes.
>
> I am not sure if it used to perform this action but all i know is modules that rely on loading json through a lookup('file','my.json') in to a parameter have recently started to fail and digging about has led me here.
>
> Obviously the problem is that single quotes is not valid json.
What happens if you pipe it to to_json filter.
>
> Can we not have the file lookup plugin return exactly what was passed in?
>
> Example:
>
> Passed in:
>
> {
>
> "Version": "2012-10-17",
>
> "Statement": [
>
> {
>
> "Sid": "",
>
> "Effect": "Allow",
>
> "Principal": {
>
> "Service": "ec2.amazonaws.com"
>
> },
>
> "Action": "sts:AssumeRole"
>
> }
>
> ]
>
> }
>
>
> Passed out:
>
> {'Version': '2012-10-17', 'Statement': [{'Action': 'sts:AssumeRole', 'Principal': {'Service': 'ec2.amazonaws.com'}, 'Effect': 'Allow', 'Sid': ''}]}
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
"{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"Service\": \"ec2.amazonaws.com\"\n },\n \"Action\": \"sts:AssumeRole\"\n }\n ]\n}"
:(
--
No, the check is correct, the policy string must start with a {One can easily confirm this in the AWS Console.
- in all versions of Ansible, put in a preceding space " {{lookup... ", this will skip type detection.- in the latest versions a `|to_json` and certain other filters at the end will also bypass the automatic type casting.
We are also adding a new feature for modules in 2.2 a type='json' which will accept both JSON strings and/or python data structures which will automatically be transformed to JSON. This will effectively be the same as 'the better modules' I mention above and will be 'transparent' to users, eventually eliminating the problem and confusion.
{ "add-field":{ "name":"recordNumber", "type":"string", "indexed":true, "stored":true, "docValues":true, "omitNorms":true, "omitTermFreqAndPositions":true, "sortMissingLast":true, "multiValued":false }, "add-field":{ "name":"characterization", "type":"text_general", "indexed":true, "stored":true, "omitNorms":true, "omitTermFreqAndPositions":true, "sortMissingLast":true, "multiValued":false }, "add-field":{ "name":"primaryname", "type":"text_general", "indexed":true, "stored":true, "omitNorms":true, "omitTermFreqAndPositions":true, "sortMissingLast":true, "multiValued":false }, "add-field":{ "name":"originator", "type":"text_general", "indexed":true, "stored":true, "omitNorms":true, "omitTermFreqAndPositions":true, "sortMissingLast":true, "multiValued":false }, "add-field":{ "name":"createdOn", "type":"tdate", "indexed":true, "stored":true, "docValues":true, "omitNorms":true, "omitTermFreqAndPositions":true, "multiValued":false }, "add-field":{ "name":"report", "type":"text_en_splitting", "indexed":true, "stored":true, "omitNorms":false, "omitTermFreqAndPositions":false, "multiValued":false }}
ok: [malpdwfftsla001 -> localhost] => {"changed": false, "content": "{\n \"responseHeader\":{\n \"status\":0,\n \"QTime\":0},\n \"errors\":[{\"errorMessages\":\"Error parsing schema operations :The JSON must be an Object of the form {\\\"command\\\": {...},...\"}]}\n", "content_length": "185", "content_type": "text/plain;charset=utf-8", "redirected": false, "status": 200}
- name: fetch schema json
set_fact:
schema: " {{ lookup('file', 'schema.json')}}"
- name: add the schema
uri:
url: "http://{{ solr_node }}:8983/solr/evaluation/schema"
method: POST
body: "{{ item }}"
body_format: json
return_content: yes
with_items:
schema
delegate_to: localhost