Ansible (ver 2.3.1) python module with boto3 successful but always get "msg": "MODULE FAILURE", "rc": 0

Hello All,

Disclaimer this is my first Ansible (python) module.
I wrote for it for AWS RDS instance creation (because currently the ansible RDS module only provisions instances with magnetic media and we require gp2/ssd).

I am passing ENV vars and other standard variables to the module and it completes and creates the RDS instances fine via boto3 calls, however, I’m stuck on perhaps preventing boto3 from returning stdout (which is not in json format), from the module which is causing the failure status?

'Read the Ansible modules and boto docs and tried wrapping the boto3 response with json, but then got errors that the boto3 stdout “is not JSON serializable”
print json.dumps(response)

print json.dumps(error)

Below is my verbose stdout (omitting a lot of our vars/details)

`
ansible-playbook -i “localhost,” main.yml -vvv

fatal: [localhost]: FAILED! => {
“changed”: false,
“failed”: true,
“module_stderr”: “”,
“module_stdout”: "{u’DBInstance’: {u’PubliclyAccessible’: False, u’MasterUsername’…

‘Accept-Encoding’, ‘content-length’: ‘4847’, ‘content-type’: ‘text/xml’, ‘date’: ‘Wed, 07 Jun 2017 20:13:33 GMT’}}}\n",
“msg”: “MODULE FAILURE”,
“rc”: 0
}
`

For now, I have set ignore to true, but would be grateful for any pointers on how best to resolve this.
Thank you!
Chris

Hi Chris,

Could you point us to your module? Did you create a net new module, or have you tried adding to the existing module (Preferred approach I might add).

Also, I suggest reaching out to ansible-devel. Someone there might be able to help you!

Hello Dylan/All,

I created a new module for our internal use, because the Ansible rds module defaults to use magnetic media which is not an option, or it will deploy with provisioned iops (where iops=1,000 is the minimum) which is too expensive for our use case.

Note (played around with this today to find) the minimum allowable vol size and iops rate which can be used to force the ansible rds module to not use magnetic and use io1 (provisioned iops). My bad if this is in the docs somewhere.

size: 100
iops: 1000

Perhaps I should have just kept my solution as a simple python script?
I did read previous work-arounds where folks were creating ansible “command” tasks which essentially call ‘aws cli’ to create an rds instance, but wanted to take another approach.

here is the public gist:
https://gist.github.com/cmcconnell1/aede4a19a2a41ab2850d55c16ee523f3

Thank you for time and your response,

Chris