Nexus符号链接不能看到install4j_java_home

问题描述:

我正在使用Ansible创建symlinkNexus符号链接不能看到install4j_java_home

这里是我创建的任务:

--- 

- name: Create nexus symlink 
    file: 
    src: "/{{ lcp }}/nex/local/lib/nexus/{{ nexus_package }}/bin/nexus" 
    path: "/etc/init.d/nexus" 
    owner: root 
    group: root 
    state: link 

- name: add nexus service 
    command: /sbin/chkconfig --add /etc/init.d/nexus 
    args: 
    chdir: /etc/init.d 

- name: set nexus service level 
    command: /sbin/chkconfig --levels 345 nexus on 
    args: 
    chdir: /etc/init.d 

- name: start nexus service 
    command: /sbin/service nexus start 
    args: 
    chdir: /etc/init.d 

我所注意到的是,Ansible运行为root。在运行我的任务时,我不得不直接指向/sbin/chkconfig,因为它正在查看bin文件夹。

我有一个用户叫nexi,我正在运行Nexus as。我的HOME目录位于/int/nex/nexi。在这个家庭目录中,我可以看到-rw-rw-r-- 1 nexi nexi 107 Oct 3 19:48 .install4j

/etc/init.d我可以看到我的符号链接创建lrwxrwxrwx 1 root root 49 Oct 2 14:20 nexus -> /int/nex/local/lib/nexus/nexus-3.4.0-02/bin/nexus

当我执行/sbin/service nexus startAnsible,然后我得到

No suitable Java Virtual Machine could be found on your system.\nThe version of the JVM must be at least 1.8 and at most 1.8.\nPlease define INSTALL4J_JAVA_HOME to point to a suitable JVM.

你可以看到,我有一个JAVA_HOME

which java 
/int/nex/local/lib/java/jdk1.8.0_131/bin/java 

而且install4j在我HOMEnexi用户

cat .install4j 
JRE_VERSION /int/nex/local/lib/java/jdk1.8.0_131 1 8 0 131 
JRE_INFO /int/nex/local/lib/java/jdk1.8.0_131 0 

我一直在关注Sonatype的的Nexus docs

我曾尝试添加在/etc/.profile.djava.sh揭露了Java位置为root。虽然我不在这里。这是我放在java.sh

export JAVA_HOME=/int/nex/local/lib/java/jdk1.8.0_131 
export PATH=$PATH:/int/nex/local/lib/java/jdk1.8.0_131/bin 

你可以看到,我有一个JAVA_HOME

是。当您运行交互式shell会话时,您可以看到(仅在交互式shell会话中)。也许出于同样的原因,你的路径不同,你必须定义可执行文件的绝对路径。

我已经尝试添加在/etc/.profile.d一个java.sh暴露根

不具有任何影响java的位置,因为Ansible在非交互模式运行壳和外壳没有源文件(例如参见man bash)。


添加JAVA_HOMEPATH作为环境Ansible模块。见Setting the Environment

+0

当我在服务器上运行'nexi'并运行'service nexus start'时,我得到了与上面相同的'INSTALL4J_JAVA_HOME'错误。我是否需要为所有任务更改'JAVA_HOME'和'PATH'? –

+1

是的,没有。形式上是的,因为每一个任务都会在一个单独的会话中运行。不,因为您可以在链接文档中阅读:“*您也可以在播放级别使用它*” – techraf