blob: 69e6c557de9b89894da7c2bc92ccd29dc8a70021 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
---
- name: "Check if cargo binary exists"
ansible.builtin.stat:
path: "{{ ansible_facts['env']['HOME'] }}/.cargo/bin/cargo"
register: rust_cargo_binary
- name: "Download rustup installer"
ansible.builtin.get_url:
url: "https://sh.rustup.rs"
dest: "/tmp/install_rustup.sh"
mode: "0755"
when: not rust_cargo_binary.stat.exists
- name: "Run rustup installer"
ansible.builtin.command:
cmd: "/tmp/install_rustup.sh -y --default-toolchain {{ rust_toolchain }} --profile minimal"
args:
creates: "{{ ansible_facts['env']['HOME'] }}/.cargo/bin/cargo"
when: not rust_cargo_binary.stat.exists
- name: "Ensure default toolchain is set"
ansible.builtin.command:
cmd: "{{ ansible_facts['env']['HOME'] }}/.cargo/bin/rustup default {{ rust_toolchain }}"
changed_when: false
- name: "Remove cargo default shell profile modification"
ansible.builtin.lineinfile:
path: "{{ ansible_facts['env']['HOME'] }}/.bashrc"
line: '. "$HOME/.cargo/env"'
state: "absent"
- name: "Add cargo to shell profile"
ansible.builtin.blockinfile:
path: "{{ ansible_facts['env']['HOME'] }}/.bashrc"
state: "present"
prepend_newline: true
append_newline: true
marker: "# ==== {mark} ANSIBLE RUST CONFIG"
block: |
if [ -f "$HOME/.cargo/env" ]; then
source "$HOME/.cargo/env"
fi
- name: "Install rust components"
ansible.builtin.command:
cmd: "{{ ansible_facts['env']['HOME'] }}/.cargo/bin/rustup component add {{ item }}"
register: rust_component_result
changed_when: "'is up to date' not in rust_component_result.stdout"
loop: "{{ rust_components }}"
|