AnsibleUndefinedVariable
Hello all,
I have following error when I apply playbook for each one
{'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'http_port' is undefined", 'failed': True}
Could you please explain how to configure those variables ? It would be great to add a note in the readme.
Thanks for help
create a file called main.yml in roles/tomcat/vars and include ' http_port=<port_no.>'
@rashbhat : how can i pass the host info using dynamic inventory? any thoughts?
#ansible-pull -d /home/gvenka008c/reponame --key-file=/home/users/rsa.id -U [email protected]:reponame.git playbook.yml
[WARNING]: provided hosts list is empty, only localhost is available
TASK [tomcat : Configure Tomcat server] *************************************************************************************************************************************
task path: /root/ansible-examples/tomcat-standalone/roles/tomcat/tasks/main.yml:25
fatal: [Git]: FAILED! => {
"changed": false,
"failed": true,
"msg": "AnsibleUndefinedVariable: 'http_port' is undefined"
}
fatal: [jenkin]: FAILED! => {
"changed": false,
"failed": true,
"msg": "AnsibleUndefinedVariable: 'http_port' is undefined"
}
fatal: [nagios]: FAILED! => {
"changed": false,
"failed": true,
"msg": "AnsibleUndefinedVariable: 'http_port' is undefined"
}
to retry, use: --limit @/root/ansible-examples/tomcat-standalone/site.retry
PLAY RECAP ******************************************************************************************************************************************************************
Git : ok=11 changed=0 unreachable=0 failed=1
jenkin : ok=11 changed=0 unreachable=0 failed=1
nagios : ok=11 changed=0 unreachable=0 failed=1
[root@centos var]# cat main.yml
#re variables related to the Tomcat installation
include : http_port:8080
include : https_port:8443
# This will configure a default manager-gui user:
#
# admin_username: admin
# admin_password: adminsecret
#
[root@centos var]# pwd
/root/ansible-examples/tomcat-standalone/roles/tomcat/var
[root@centos var]#
I created file under create a file called main.yml in roles/tomcat/vars . Please help me to fix this error!
Hi,
I have resolved the issue as below Steps
- Create 'vars' directory in roles/tomcat
[root@instance-1 vars]# pwd
/home/user/ansible-tomcat/roles/tomcat/vars
- Copy the group_vars/tomcat-servers file to /roles/tomcat/vars/main.yml file
[root@instance-1 vars]# cat main.yml
# Here are variables related to the Tomcat installation
http_port: 8086
https_port: 8443
# This will configure a default manager-gui user:
admin_username: admin
admin_password: adminsecret
Thanks It worked :)
syamv -I faced the same issue and followed the same which you posted above. issue no more persisting.. but wanted to know why it is not taking the vars from group_vars folder wanted to know that can some one explain me