I’m in the process of writing an Ansible module.
I’ve currently got an Ansible task that includes this piece of code:
...
allowed:
- ip_protocol: 'tcp'
- port: '22'
...
AnsibleModule looks something like this:
AnsibleModule(
argument_spec=dict(
allowed=dict(type='list', elements='dict', options=dict(
IPProtocol=dict(required=True, type='str', aliases=['ip_protocol']),
ports=dict(type='list', elements='str')
))
)
)
(tldr; ip_protocol is an alias of IPProtocol).
I end up doing some work with module.params later on. I would expect module.params to look like this:
{
allowed: [
{
IPProtocol: 'tcp',
ports: '22'
}
]
}
Instead, it looks like this:
{
allowed: [
{
IPProtocol: 'tcp',
ip_protocol: 'tcp',
ports: '22'
}
]
}
Is there a way to get a version of module.params that doesn’t have each alias listed out in this way?