zuul-jobs/roles/ensure-rust/tasks/rustup.yaml
Ian Wienand 67ae84ce39 ensure-rust: rework global install
I think the secondary "rustup default" was intended to make sure the
Zuul user sets up to use the installed rust toolchain
(I32f9b285904a7036f9a80ada8a49fa9cf31b5163) but actually results in a
re-download of components and another local installation.  This isn't
really the intention, and also doubles the time spent installing.

From the linked comment, it seems like we're not doing our global
install correctly; even putting it in /usr doesn't avoid the need for
RUST_HOME to be set.  Take it's suggestion and install out-of-the-way
in /opt, use a small /usr/local/bin wrapper to call with correct env
vars set and then setup the installed global binary names to be called
via that.

Change-Id: I28ef747b809a17664305bfd9754022251390647b
2021-10-04 11:43:22 +11:00

28 lines
784 B
YAML

- name: Install Rust
shell: | # noqa command-instead-of-module
set -o pipefail
curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain {{ ensure_rust_rustup_toolchain }}
environment:
RUSTUP_HOME: '{{ ensure_rust_rustup_path }}'
CARGO_HOME: '{{ ensure_rust_rustup_path }}'
args:
executable: /bin/bash
become: yes
# Install wrappers that set env vars for global usage. See
# https://github.com/rust-lang/rustup/issues/1085#issuecomment-296604244
- name: Install wrapper helper script
template:
src: rust-wrap-setup.sh.j2
dest: /usr/local/bin/rust-wrap-setup
owner: root
group: root
mode: 0755
become: yes
- name: Run wrapper installation
shell: |
/usr/local/bin/rust-wrap-setup
become: yes