diff --git a/local/tasks/conda-env-install.yml b/local/tasks/conda-env-install.yml index 9b4c0e2..980d447 100644 --- a/local/tasks/conda-env-install.yml +++ b/local/tasks/conda-env-install.yml @@ -20,17 +20,6 @@ become_user: "{{ vm_user }}" when: bin_patterns is defined and bin_patterns | length > 0 block: - - name: "Create ~/.local/bin" - ansible.builtin.file: - path: "/home/{{ vm_user }}/.local/bin" - state: directory - mode: "0755" - - name: "Add ~/.local/bin to PATH in .bashrc" - ansible.builtin.blockinfile: - path: "/home/{{ vm_user }}/.bashrc" - marker: "## {mark} ANSIBLE MANAGED BLOCK (~/.local/bin)" - block: | - export PATH="$HOME/.local/bin:$PATH" - name: "Find binaries matching patterns" ansible.builtin.find: paths: "/home/{{ vm_user }}/.conda/envs/{{ conda_env }}/bin" diff --git a/local/tasks/setup-local-bin.yml b/local/tasks/setup-local-bin.yml new file mode 100644 index 0000000..9677cdd --- /dev/null +++ b/local/tasks/setup-local-bin.yml @@ -0,0 +1,23 @@ +--- +# Create ~/.local/bin and prepend it to PATH in .bashrc. +# The export is inserted at BOF so conda init (appended later by the miniforge +# installer) ends up AFTER it in .bashrc, letting conda env activation prepend +# its own bin/ and win on PATH resolution. + +- name: "Create ~/.local/bin" + become: true + become_user: "{{ vm_user }}" + ansible.builtin.file: + path: "/home/{{ vm_user }}/.local/bin" + state: directory + mode: "0755" + +- name: "Add ~/.local/bin to PATH in .bashrc" + become: true + become_user: "{{ vm_user }}" + ansible.builtin.blockinfile: + path: "/home/{{ vm_user }}/.bashrc" + marker: "## {mark} ANSIBLE MANAGED BLOCK (~/.local/bin)" + insertbefore: BOF + block: | + export PATH="$HOME/.local/bin:$PATH" diff --git a/playbook-build-dev.yml b/playbook-build-dev.yml index e4aba8e..8f22ead 100644 --- a/playbook-build-dev.yml +++ b/playbook-build-dev.yml @@ -122,6 +122,10 @@ ansible.builtin.import_role: name: marvel-nccr.slurm + - name: "Setup ~/.local/bin on PATH" + tags: [local-bin] + ansible.builtin.import_tasks: local/tasks/setup-local-bin.yml + - name: Install conda+mamba tags: [conda] ansible.builtin.import_role: