我正在使用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
答案 0 :(得分:1)
您可以看到我有
JAVA_HOME
是。运行交互式shell会话时,您可以看到(仅在交互式shell会话中)。可能出于同样的原因,您的路径不同,您必须定义可执行文件的绝对路径。
我尝试在
java.sh
中添加/etc/.profile.d
来公开root的java位置
这没有任何影响,因为Ansible在非交互模式下运行shell而shell不提供此文件(例如,参见man bash
)。
将JAVA_HOME
和PATH
作为环境添加到Ansible模块。请参阅Setting the Environment。