TASK [set_fact] *************************************************************************************************************************************************************************
task path: /home/admin/create_instances.yaml:107
ok: [127.0.0.1] => {
"ansible_facts": {
"endpoint": "something.amazonaws.com"
},
"changed": false
}
Read vars_file 'vars/sts.yml'
Read vars_file 'vars/default.yml'
TASK [Print endpoint] *******************************************************************************************************************************************************************
task path: /home/admin/create_instances.yaml:110
ok: [127.0.0.1] => {
"msg": "sonmething.amazonaws.com"
}
TASK [replace] **************************************************************************************************************************************************************************
task path: /home/admin/voice-conf/playbooks/create_instances.yaml:335
fatal: [18.206.82.39]: FAILED! => {
"msg": "The task includes an option with an undefined variable. The error was: 'endpoint' is undefined\n\nThe error appears to have been in '/home/admin/create_instances.yaml': line 335, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - replace:\n ^ here\n"
}
fatal: [18.206.108.97]: FAILED! => {
"msg": "The task includes an option with an undefined variable. The error was: 'endpoint' is undefined\n\nThe error appears to have been in '/home/admin/create_instances.yaml': line 335, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - replace:\n ^ here\n"
}
1- which version of ansible you use?
$ ansible-playbook --version
ansible-playbook 2.5.2
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/admin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2]
My playbook has 2 "tasks":
I first gather some info, including the hosts to work on, then add them with add_hosts, and then start again some new tasks, could this be it?
There are some vars set on the cli that are not lost, could those be global and the ones set in the playbook not be global?
--
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 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/491d0f10-323c-4542-abb9-9101665c245a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
- name: 1st play that runs on localhost and defines the var
hosts: localhost
tasks:
- name: set variable/fact on the first play for localhost
set_fact:
my_var: abc
- name: 2nd play that runs on another host
hosts: other-group
tasks:
- name: output my_var registered on localhost
debug:
var: hostvars['localhost']['my_var']
Hello Jordan,
That's exactly my problem! Now i understand why it's not on the second play. I get the variable again on the second play and it's working properly.
Thanks a lot for the exaplanation!
David
--
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 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/423db0a1-4405-4f50-bab4-3afe35ec23a9%40googlegroups.com.