Não consigo descobrir como passar um dicionário / hash-map de pares de valores-chave como o valor de uma opção em tarefas ansiosas.
Opções padrão:
# roles/ec2/defaults/main.yml
ec2:
key_name: "{{ key_name }}"
instance_type: m3.medium
image: ami-xxxx
group_id: sg-xxxxx
vpc_subnet_id: subnet-xxxxx
region: us-east-1
wait: yes
instance_tags:
Name: "{{ env_name }}-{{ group_name }}-{{ ansible_date_time.epoch }}"
Type: "{{ env_name }}-{{ group_name }}-{{ ansible_date_time.epoch }}"
Tentativa 1
# roles/ec2/tasks/main.yml
- name: launch single instance
ec2: "{{ ec2 }}"
register: instance
Stacktrace
fatal: [localhost] => Traceback (most recent call last):
File "/usr/local/Cellar/ansible/1.8.2/libexec/lib/python2.7/site-packages/ansible/runner/__init__.py", line 590, in _executor
exec_rc = self._executor_internal(host, new_stdin)
File "/usr/local/Cellar/ansible/1.8.2/libexec/lib/python2.7/site-packages/ansible/runner/__init__.py", line 792, in _executor_internal
return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args)
File "/usr/local/Cellar/ansible/1.8.2/libexec/lib/python2.7/site-packages/ansible/runner/__init__.py", line 994, in _executor_internal_inner
num_args_post = self._count_module_args(module_args)
File "/usr/local/Cellar/ansible/1.8.2/libexec/lib/python2.7/site-packages/ansible/runner/__init__.py", line 434, in _count_module_args
vargs = split_args(args)
File "/usr/local/Cellar/ansible/1.8.2/libexec/lib/python2.7/site-packages/ansible/module_utils/splitter.py", line 73, in split_args
args = args.strip()
AttributeError: 'dict' object has no attribute 'strip'
Tentativa 2
# roles/ec2/tasks/main.yml
- name: launch single instance
ec2: "{{ ec2 | to_nice_yaml }}"
register: instance
Stacktrace
failed: [localhost] => {"failed": true}
msg: this module requires key=value arguments (['assign_public_ip:', 'true', 'group_id:', 'sg-xxxxx', 'image:', 'ami-xxxxx', 'instance_tags:', 'Environment:', 'stage', 'Name:', 'stage-analytics-stack', 'Type:', 'analytics-stack', 'instance_type:', 'm3.medium', 'key_name:', '2014-10-xxxxxx', 'region:', 'us-east-1', 'vpc_subnet_id:', 'subnet-xxxxx', 'wait:', 'true
Obrigado!