ansible-maven icon indicating copy to clipboard operation
ansible-maven copied to clipboard

interactive, not login shell support

Open PSkarzynski-SkyCash opened this issue 6 years ago • 3 comments

Task

  • name: Maven path configuration

will not work for not login shells (e.g. when role is used with docker containers), where /etc/profile is not used. Modifying ~/.bashrc solves the issue:

- name: Maven path configuration
  blockinfile:
    path: /root/.bashrc
    block: |
      M2_HOME={{maven_home_parent_directory}}/apache-maven-{{maven_version}}
      PATH=$PATH:$M2_HOME/bin
    state: present

PSkarzynski-SkyCash avatar Apr 19 '19 05:04 PSkarzynski-SkyCash

Sorry, my apologies for the late reply and thanks for the interest.

Lack of proper (& automated) testing, on my side, requires more time to test. To be honest main issue is about taking a proper decision. From the snippet provided I am not sure I have a full understanding. You suggest to replace current path configuration or to add this new block. Would non-docker installation still work after that? Is there any official documentation that supports usage of /root/.bashrc for setting PATH / env variables? Ubuntu official documentation (albeit non-docker) EnvironmentVariables

tecris avatar May 17 '19 13:05 tecris

That snippet is just a proposal of an additional task. From referenced ubuntu official documentation:

Shell config files such as ~/.bashrc, ~/.bash_profile, and ~/.bash_login are often suggested for setting environment variables. While this may work on Bash shells for programs started from the shell, variables set in those files are not available by default to programs started from the graphical environment in a desktop session.

When you run bash in docker container (e.g. docker run image_name bash), the default shell is not a login shell, which means profile files (or those in /etc/profile.d) are not sourced. ext ref.

PSkarzynski-SkyCash avatar May 23 '19 05:05 PSkarzynski-SkyCash

Hi, There is a difference between /root/.bashrc and ~/.bashrc. And the assumption that docker container will run as root might not work. As per docker documentation If a service can run without privileges, use USER to change to a non-root user Maybe one option will be to parameterize the user, however, this needs some time/thinking.

thanks again

tecris avatar May 23 '19 06:05 tecris