Skip to content

Instantly share code, notes, and snippets.

@victorskl
Forked from carlessanagustin/ansible-path.md
Created May 7, 2017 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorskl/0b7ac82bbc1e3181b3084e47cc82887b to your computer and use it in GitHub Desktop.
Save victorskl/0b7ac82bbc1e3181b3084e47cc82887b to your computer and use it in GitHub Desktop.
updating PATH with ansible - system wide

Option 1

- name: compile sources
  shell:
    coffee -o lib -c src 
    chdir=${mysourcedir}
  environment:
    PATH: $PATH:/opt/node/bin

Option 2

- name: add {{extra_path}} to path
  lineinfile:
    dest: /etc/environment
    state: present
    backrefs: yes
    regexp: 'PATH=(["]*)((?!.*?{{extra_path}}).*?)(["]*)$'
    line: "PATH=\1\2:{{extra_path}}\3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment