From 96239c08f23f346bf81af95ab044f1d8238fb8f4 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 13 Feb 2024 18:27:40 +0200 Subject: rust-rustup: add variable for user for whom to install Rust Signed-off-by: Lars Wirzenius Sponsored-by: author --- ansible/roles/rust-rustup/defaults/main.yml | 1 + ansible/roles/rust-rustup/tasks/main.yml | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 ansible/roles/rust-rustup/defaults/main.yml diff --git a/ansible/roles/rust-rustup/defaults/main.yml b/ansible/roles/rust-rustup/defaults/main.yml new file mode 100644 index 0000000..e1c0df8 --- /dev/null +++ b/ansible/roles/rust-rustup/defaults/main.yml @@ -0,0 +1 @@ +rust_rustup_user: liw diff --git a/ansible/roles/rust-rustup/tasks/main.yml b/ansible/roles/rust-rustup/tasks/main.yml index c97aca2..ceb4a69 100644 --- a/ansible/roles/rust-rustup/tasks/main.yml +++ b/ansible/roles/rust-rustup/tasks/main.yml @@ -9,16 +9,16 @@ set -eu if command -v rustup > /dev/null then - sudo -u liw rustup update + sudo -u {{ rust_rustup_user }} rustup update else curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustup.sh - sudo -u liw -i sh /tmp/rustup.sh -y --no-modify-path + sudo -u {{ rust_rustup_user }} -i sh /tmp/rustup.sh -y --no-modify-path fi - sudo -u liw -i /home/liw/.cargo/bin/rustup self update - sudo -u liw -i /home/liw/.cargo/bin/rustup component add clippy \ + sudo -u {{ rust_rustup_user }} -i /home/{{ rust_rustup_user }}/.cargo/bin/rustup self update + sudo -u {{ rust_rustup_user }} -i /home/{{ rust_rustup_user }}/.cargo/bin/rustup component add clippy \ rust-src rust-analyzer - name: "cargo install applications" when: rustup_cargo_install is defined shell: | - sudo -i -u liw sh -c '. $HOME/.cargo/env && cargo install {{ rustup_cargo_install }}' + sudo -i -u {{ rust_rustup_user }} sh -c '. $HOME/.cargo/env && cargo install {{ rustup_cargo_install }}' -- cgit v1.2.1