diff options
| -rw-r--r-- | molecule/archlinux/converge.yml | 1 | ||||
| -rw-r--r-- | molecule/debian/converge.yml | 1 | ||||
| -rw-r--r-- | molecule/raspberrypi/converge.yml | 3 | ||||
| -rw-r--r-- | molecule/ubuntu/converge.yml | 1 | ||||
| -rw-r--r-- | roles/rust/defaults/main.yml | 3 | ||||
| -rw-r--r-- | roles/rust/meta/argument_specs.yml | 15 | ||||
| -rw-r--r-- | roles/rust/meta/main.yml | 20 | ||||
| -rw-r--r-- | roles/rust/tasks/main.yml | 38 |
8 files changed, 82 insertions, 0 deletions
diff --git a/molecule/archlinux/converge.yml b/molecule/archlinux/converge.yml index d9b67f8d..10edc00d 100644 --- a/molecule/archlinux/converge.yml +++ b/molecule/archlinux/converge.yml @@ -35,6 +35,7 @@ - role: "gateway" - role: "python" - role: "go" + - role: "rust" - role: "docker" - role: "podman" - role: "ansible" diff --git a/molecule/debian/converge.yml b/molecule/debian/converge.yml index 83d91214..ee29ae0c 100644 --- a/molecule/debian/converge.yml +++ b/molecule/debian/converge.yml @@ -46,6 +46,7 @@ - role: "gateway" - role: "python" - role: "go" + - role: "rust" - role: "docker" - role: "podman" - role: "ansible" diff --git a/molecule/raspberrypi/converge.yml b/molecule/raspberrypi/converge.yml index 36f4bfbe..38cc511e 100644 --- a/molecule/raspberrypi/converge.yml +++ b/molecule/raspberrypi/converge.yml @@ -35,6 +35,9 @@ - role: "password_policy" - role: "locales" - role: "timezone" + - role: "python" + - role: "go" + - role: "rust" - role: "wireguard" - role: "gateway" - role: "nginx" diff --git a/molecule/ubuntu/converge.yml b/molecule/ubuntu/converge.yml index c04a299b..5a1b0265 100644 --- a/molecule/ubuntu/converge.yml +++ b/molecule/ubuntu/converge.yml @@ -35,6 +35,7 @@ - role: "gateway" - role: "python" - role: "go" + - role: "rust" - role: "docker" - role: "podman" - role: "ansible" diff --git a/roles/rust/defaults/main.yml b/roles/rust/defaults/main.yml new file mode 100644 index 00000000..a23ee6dc --- /dev/null +++ b/roles/rust/defaults/main.yml @@ -0,0 +1,3 @@ +--- +rust_toolchain: "stable" +rust_components: [] diff --git a/roles/rust/meta/argument_specs.yml b/roles/rust/meta/argument_specs.yml new file mode 100644 index 00000000..93ebc36e --- /dev/null +++ b/roles/rust/meta/argument_specs.yml @@ -0,0 +1,15 @@ +--- +argument_specs: + main: + short_description: "Install Rust via rustup on Linux distributions" + description: "Install Rust via rustup on Linux distributions" + options: + rust_toolchain: + type: "str" + description: "The Rust toolchain to install (stable, beta, nightly)" + default: "stable" + rust_components: + type: "list" + description: "Additional rustup components to install" + elements: "str" + default: [] diff --git a/roles/rust/meta/main.yml b/roles/rust/meta/main.yml new file mode 100644 index 00000000..7f664eef --- /dev/null +++ b/roles/rust/meta/main.yml @@ -0,0 +1,20 @@ +--- +dependencies: + - role: "bash" + - role: "curl" +galaxy_info: + author: "a14m" + description: "Install Rust via rustup on Linux distributions" + company: "kartoffeln.work GmbH." + license: "MIT" + min_ansible_version: "2.18" + platforms: + - name: "ArchLinux" + versions: + - "all" + - name: "Ubuntu" + versions: + - "noble" + - name: "Debian" + versions: + - "bookworm" 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 }}" |
