summaryrefslogtreecommitdiffstats
path: root/roles/rust/tasks
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2025-12-02 17:32:42 +0100
committerAhmed Abdelhalim <[email protected]>2025-12-02 22:41:42 +0100
commitfc1491ba66118fcb53190f618ef22351cb0eed55 (patch)
tree7efd2be19d6bf5254e73662114631315797c4d96 /roles/rust/tasks
parent048f3154918cdfb65cc21ed2aa254adb0aa2d86b (diff)
Add rust role w/testing
Diffstat (limited to 'roles/rust/tasks')
-rw-r--r--roles/rust/tasks/main.yml38
1 files changed, 38 insertions, 0 deletions
diff --git a/roles/rust/tasks/main.yml b/roles/rust/tasks/main.yml
new file mode 100644
index 00000000..9332a16d
--- /dev/null
+++ b/roles/rust/tasks/main.yml
@@ -0,0 +1,38 @@
+---
+- name: "Check if cargo binary exists"
+ ansible.builtin.stat:
+ path: "{{ ansible_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_env.HOME }}/.cargo/bin/cargo"
+ when: not rust_cargo_binary.stat.exists
+
+- name: "Add cargo to shell profile"
+ ansible.builtin.blockinfile:
+ path: "{{ ansible_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_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 }}"