2022-08-01 00:42:23 -05:00
|
|
|
---
|
2022-08-01 02:12:33 -05:00
|
|
|
- name: Set environment variables if not set
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
cargo_home: "{{ cargo_home | default(xdg_data_home + '/cargo') }}"
|
|
|
|
rustup_home: "{{ rustup_home | default(xdg_data_home + '/rustup') }}"
|
|
|
|
|
2022-08-01 00:42:23 -05:00
|
|
|
- name: Check if Cargo is installed
|
2022-08-01 01:48:49 -05:00
|
|
|
ansible.builtin.command: which cargo
|
2022-08-01 00:42:23 -05:00
|
|
|
register: cargo_installed
|
2022-08-01 01:48:49 -05:00
|
|
|
failed_when: cargo_installed.rc > 1
|
2022-08-01 00:42:23 -05:00
|
|
|
changed_when: false
|
2022-08-01 02:12:33 -05:00
|
|
|
environment:
|
|
|
|
CARGO_HOME: "{{ cargo_home }}"
|
|
|
|
RUSTUP_HOME: "{{ rustup_home }}"
|
2022-08-01 00:42:23 -05:00
|
|
|
|
|
|
|
- name: Download Rust installer
|
2022-08-01 01:52:41 -05:00
|
|
|
when: cargo_installed.rc != 0
|
2022-08-01 00:42:23 -05:00
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: http://sh.rustup.rs
|
|
|
|
dest: /tmp/sh.rustup.rs
|
|
|
|
mode: 0755
|
|
|
|
force: true
|
|
|
|
tags:
|
|
|
|
- rust
|
|
|
|
- prereq
|
|
|
|
|
|
|
|
- name: Install Rust & Cargo
|
2022-08-01 01:52:41 -05:00
|
|
|
when: cargo_installed.rc != 0
|
2022-08-01 00:42:23 -05:00
|
|
|
environment:
|
2022-08-01 02:02:21 -05:00
|
|
|
CARGO_HOME: "{{ cargo_home }}"
|
|
|
|
RUSTUP_HOME: "{{ rustup_home }}"
|
2022-08-01 00:42:23 -05:00
|
|
|
ansible.builtin.command:
|
|
|
|
argv:
|
2022-08-01 01:54:03 -05:00
|
|
|
- /tmp/sh.rustup.rs
|
2022-08-01 00:42:23 -05:00
|
|
|
- -y
|
|
|
|
changed_when: true
|
|
|
|
tags:
|
|
|
|
- rust
|
|
|
|
- prereq
|
2022-08-01 02:02:21 -05:00
|
|
|
|
|
|
|
- name: Set Rustup's toolchain
|
|
|
|
ansible.builtin.command:
|
|
|
|
argv:
|
2022-08-01 04:02:02 -05:00
|
|
|
- "{{ cargo_home }}/bin/rustup"
|
2022-08-01 02:02:21 -05:00
|
|
|
- default
|
|
|
|
- "{{ rustup_toolchain | default('stable') }}"
|
|
|
|
environment:
|
|
|
|
CARGO_HOME: "{{ cargo_home }}"
|
|
|
|
RUSTUP_HOME: "{{ rustup_home }}"
|
|
|
|
changed_when: true
|
2022-08-01 02:13:40 -05:00
|
|
|
when: cargo_installed.rc != 0
|