- hosts: tag_v3_elasticsearch_prod_True
vars:
- ansible_ssh_private_key_file: "{{ ec2_tag_ssh_key | default('sv3.key') }}"
- ansible_ssh_port: "{{ ec2_tag_ssh_port | default(22) }}"
- ansible_ssh_user: "{{ ec2_tag_ssh_user | default('ubuntu') }}"
tasks:
- SOME TASKS....
---
- hosts: tag_v3_elasticsearch_prod_True
vars:
- ssh_private_key_file: "{{ ec2_tag_ssh | from_json }}"
- ssh_port: "{{ ec2_tag_ssh | from_json }}"
- ssh_user: "{{ ec2_tag_ssh | from_json }}"
tasks:
- debug: var=ssh_private_key_file
- debug: var=ssh_port
- debug: var=ssh_user
[WARNING]: non fatal error while trying to template play variables: Failed to
template {{ ec2_tag_ssh | from_json }}: an unexpected type error occurred.
Error was expected string or buffer
PLAY [tag_v3_elasticsearch_prod_True] *****************************************
GATHERING FACTS ***************************************************************
ok: [x.x.x.xxx]
TASK: [debug var=ssh_private_key_file] ****************************************
ok: [x.x.x.xxx] => {
"var": {
"ssh_private_key_file": {
"ssh_key": "prod.pem",
"ssh_port": "22",
"ssh_user": "ansible"
}
}
}
TASK: [debug var=ssh_port] ****************************************************
ok: [x.x.x.xxx] => {
"var": {
"ssh_port": {
"ssh_key": "prod.pem",
"ssh_port": "22",
"ssh_user": "ansible"
}
}
}
TASK: [debug var=ssh_user] ****************************************************
ok: [x.x.x.xxx] => {
"var": {
"ssh_user": {
"ssh_key": "prod.pem",
"ssh_port": "22",
"ssh_user": "ansible"
}
}
}
PLAY RECAP ********************************************************************
x.x.x.xxx : ok=4 changed=0 unreachable=0 failed=0
- hosts: tag_v3_elasticsearch_prod_True
vars:
- ansible_ssh_private_key_file: "{{ ec2_tag_ssh.ssh_key }}"
- ansible_ssh_port: "{{ ec2_tag_ssh.ssh_port }}"
- ansible_ssh_user: "{{ ec2_tag_ssh.ssh_user }}"
tasks:
- debug: var=ansible_ssh_private_key_file
- debug: var=ansible_ssh_port
- debug: var=ansible_ssh_user
PLAY [tag_v3_elasticsearch_prod_True] *****************************************
GATHERING FACTS ***************************************************************
fatal: [x.x.x.xxx] => Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ansible/runner/__init__.py", line 582, in _executor
exec_rc = self._executor_internal(host, new_stdin)
File "/usr/local/lib/python2.7/dist-packages/ansible/runner/__init__.py", line 785, in _executor_internal
return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args)
File "/usr/local/lib/python2.7/dist-packages/ansible/runner/__init__.py", line 885, in _executor_internal_inner
actual_private_key_file = template.template(self.basedir, actual_private_key_file, inject, fail_on_undefined=True)
File "/usr/local/lib/python2.7/dist-packages/ansible/utils/template.py", line 122, in template
varname = template_from_string(basedir, varname, templatevars, fail_on_undefined)
File "/usr/local/lib/python2.7/dist-packages/ansible/utils/template.py", line 371, in template_from_string
res = jinja2.utils.concat(rf)
File "<template>", line 8, in root
File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.7.3-py2.7.egg/jinja2/runtime.py", line 485, in _fail_with_undefined_error
raise self._undefined_exception(hint)
UndefinedError: 'unicode object' has no attribute 'ssh_key'
TASK: [debug var=ansible_ssh_private_key_file] ********************************
FATAL: no hosts matched or all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/galindro/play.retry
x.x.x.xxx : ok=0 changed=0 unreachable=1 failed=0
--
Brian Coca
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/zr_vdVki_EM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8m3W6rMraYoZ_vFbeQegqEU2xhXR6hUQBVxhGH%3D915PnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.