How to set environmental variables using Ansible

前端 未结 3 1918
广开言路
广开言路 2020-12-02 22:56

I need to set the variables like JAVA_HOME and update PATH. There are a number of ways of doing this. One way is to update the /etc/environm

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 23:22

    Update to the lineinfile approach. The JAVA_HOME value should not include the bin directory. The following worked for centos:

    - name: Set JAVA_HOME
      lineinfile:
        dest: /etc/environment
        state: present
        regexp: '^JAVA_HOME'
        line: 'JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk'
    

提交回复
热议问题