Hello,
I'm trying to create a helper role to raise ec2 instances, and I stumbled
in a problem where I wanted to deleted or ignore some module options, based
on the role vars.
First, let's say I have a playbook like this.
---
- name: Raise ec2 instance
ec2:
key_name: my_key
instance_type: m1.medium
image: i999999
region: us-east-1
zone: us-east-1e
wait: 1000
count_tags:
tag: value
* exact_count: "{{my_count}}"*
If I wanted to ignore the 'exact_count' option one may think that if you
set 'my_count' to 'null' or '!!null' it will be interpreted as 'None', the
default value for that option, and the module will behave as if it was not
set. But because of this issue
<https://github.com/ansible/ansible/issues/4812>, which created this
<https://github.com/ansible/ansible/blob/v1.8.1/lib/ansible/utils/template.py#L219-L220>
code, the interpreter now translates the None values to a empty string,
which then makes the interpreter crash like so.
*TASK: [aws-instance | Raise ec2 instance] ****************************
failed: [localhost] => {"failed": true, "parsed": false}
Traceback (most recent call last):
File
"/home/user/.ansible/tmp/ansible-tmp-9999999999.99-999999999999999/ec2",
line 2962, in <module>
main()
File
"/Users/user/.ansible/tmp/ansible-tmp-9999999999.99-999999999999999/ec2",
line 1164, in main
['exact_count', 'instance_ids']
File "/home/user/.ansible/tmp/ansible-tmp-9999999999.99-999999999999999/ec2",
line 1504, in __init__
self._check_argument_types()
File "/home/user/.ansible/tmp/ansible-tmp-9999999999.99-999999999999999/ec2",
line 2160, in _check_argument_types
self.params[k] = int(value)
ValueError: invalid literal for int() with base 10: ''
FATAL: all hosts have already failed -- aborting
IMHO this is unwanted behaviour, since there is no way to unset a module
option or even ignore then. I don't know if I'm missing something, but if I
do, please show me :)
Thanks,
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/931f80ea-91bf-4922-8850-5c1e160b7d28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.