silpion / ansible-tomcat

Manage installation of Tomcat
Apache License 2.0
64 stars 57 forks source link

Error message about java_home #3

Closed dj-wasabi closed 9 years ago

dj-wasabi commented 9 years ago

Hi there,

I'm trying to setup the module, but I think I'm or doing wrong or I forget someting. Ik get the following error message:

TASK: [groover.tomcat | Install sysvinit Tomcat Service] ********************** 
fatal: [wdserver00] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'java_home' is undefined", 'failed': True}
fatal: [wdserver00] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'java_home' is undefined", 'failed': True}

I did setup the facts file:

[root@server ~]# cat /etc/ansible/facts.d/java.fact
[default]
java_home=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71.x86_64
[general]
java_home=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71.x86_64

When I run the setup:

ansible server -i etc/host_list -m setup -a "filter=ansible_local"
server | success >> {
    "ansible_facts": {
        "ansible_local": {
            "java": {
                "default": {
                    "java_home": "/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71.x86_64"
                }, 
                "general": {
                    "java_home": "/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71.x86_64"
                }
            }
        }
    }, 
    "changed": false
}

The directories does exists though...

What am I doing wrong or missing?

Kind regards, Werner

ghost commented 9 years ago

Hi, this is currently a design flaw in the role. java_home fact is not available to the tomcat role, if groover.java is not part of the playbook. java_home is set with set_fact in groover.java. Tomcat role should use ansible_local['java']['general']['java_home'] as your facts already told you.

dj-wasabi commented 9 years ago

Thanks. I've added the groovy.java rol and it is working now.

ghost commented 9 years ago

Hi, just updated tomcat role to version 0.5.0. This uses the java local facts now in any template. This allows to either configure /etc/ansible/facts.d/java.fact manually and have the tomcat role working without implicit dependencies to the groover.java role, or to have a dependency to groover.java without the need to have the java role run in each play (e.g. using --tags tomcat).

dj-wasabi commented 9 years ago

Sounds good! Will check it out, thanks for this update!