Nexus符号链接无法看到install4j_java_home

时间:2017-10-04 13:50:36

标签: ansible nexus symlink sonatype

我正在使用symlink创建Ansible

这是我创建的任务:

---

- 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。我的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 start执行Ansible时,我正在

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

并在HOME用户nexi中安装4j

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

我尝试在java.sh中添加/etc/.profile.d来公开root的java位置。我不是这里的亲。这就是我在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

1 个答案:

答案 0 :(得分:1)

  

您可以看到我有JAVA_HOME

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

  

我尝试在java.sh中添加/etc/.profile.d来公开root的java位置

这没有任何影响,因为Ansible在非交互模式下运行shell而shell不提供此文件(例如,参见man bash)。

JAVA_HOMEPATH作为环境添加到Ansible模块。请参阅Setting the Environment