Hi,
I have added some export task in ~/.profile file & its added but not able to source ~/.profile in remote host.
FYI
-
name: Set .profile
lineinfile:
path: /root/.profile
line: export PROMPT_COMMAND=‘history -a >(logger -t “cmdlog[$USER:$PWD] $SSH_CLIENT”)’
tags:
-
PROMPT_CMD
-
name: source .profile
shell: source /root/.profile
args:
executable: /bin/bash
tags:
-
PROMPT_CMD
Each task inside your play is run though a completely separate SSH connection. Sourcing your .profile in one task will have no effect on other tasks.
You can verify this with the -vvv flag.
–EbH
Looks like you're trying to set some environment variable in one task,
and trying to use that in another task.
That won't work. You should define such variables in each task:
https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html
Dick
I think this code is useful for you ,try it.
- name: “create java.sh file with permissions.”
file:
path: “/etc/profile.d/java.sh”
state: touch
mode: 0755
- name: “create java.sh file with content”
copy:
dest: “/etc/profile.d/java.sh”
content: |
export JRE_HOME={{ destination_folder }}java/jre
export PATH=$PATH:$JRE_HOME/bin
export JAVA_HOME={{ destination_folder }}java
export JAVA_PATH=$JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
export JBOSS_HOME={{ destination_folder }}adobe/adobe_experience_manager_Forms/jboss
export PATH=$PATH:$JBOSS_HOME/bin/init.d
ignore_error: true
- shell: “source /etc/profile.d/java.sh”
name: “Configure Java by java.sh”