Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

AnsibleUndefinedVariable #135

Open
mbettan opened this issue Nov 3, 2015 · 6 comments
Open

AnsibleUndefinedVariable #135

mbettan opened this issue Nov 3, 2015 · 6 comments

Comments

@mbettan
Copy link

mbettan commented Nov 3, 2015

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

@rashbhat
Copy link

create a file called main.yml in roles/tomcat/vars and include ' http_port=<port_no.>'

@gvenka008c
Copy link

@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 git@github.com:reponame.git playbook.yml

[WARNING]: provided hosts list is empty, only localhost is available

@fahdkecheri
Copy link

fahdkecheri commented Jul 21, 2017

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!

@syamv
Copy link

syamv commented Mar 26, 2018

Hi,

I have resolved the issue as below
Steps

  1. Create 'vars' directory in roles/tomcat
[root@instance-1 vars]# pwd
/home/user/ansible-tomcat/roles/tomcat/vars
  1. 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

@himaja-ala
Copy link

Thanks It worked :)

@sreekanth564
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants