Skip to content

Latest commit

 

History

History
118 lines (84 loc) · 2.96 KB

File metadata and controls

118 lines (84 loc) · 2.96 KB

Rust Role

Rust toolchain installation and configuration via rustup with cargo support.

Description

The Rust role installs the complete Rust programming language toolchain using rustup, the official Rust toolchain installer. It provides a secure, up-to-date Rust development environment with cargo package manager and essential components.

Requirements

  • Ubuntu 20.04 LTS or later
  • Ansible 2.12 or later
  • Common role (automatically included as dependency)
  • Internet connectivity for rustup installation

Role Variables

Available Variables

The following variables can be set in defaults/main.yml:

# Rust toolchain configuration
rust_toolchain: "stable"
rust_profile: "default"

# Rustup configuration
rustup_url: "https://sh.rustup.rs"
rustup_checksum: "expected_checksum_here"

# Components to install
rust_components:
  - rustfmt
  - clippy
  - rust-src

# User configuration
target_user: "{{ ansible_user }}"
rust_home: "{{ ansible_user_dir }}/.cargo"

Variable Descriptions

  • rust_toolchain: Rust toolchain to install (stable, beta, nightly, or specific version)
  • rust_profile: Installation profile (minimal, default, complete)
  • rustup_url: URL for rustup installation script
  • rustup_checksum: Expected checksum for security validation
  • rust_components: Additional Rust components to install
  • target_user: The user for which Rust is being configured
  • rust_home: Cargo home directory location

Dependencies

  • common: Base system setup and essential packages

Example Playbook

---
- hosts: servers
  become: yes
  roles:
    - common
    - rust

Features

  • Secure Installation: Downloads and validates rustup installer with checksum verification
  • Toolchain Management: Configures specified Rust toolchain (stable by default)
  • Component Installation: Installs essential Rust components (rustfmt, clippy, rust-src)
  • Cargo Configuration: Sets up cargo package manager and environment
  • User Environment: Configures Rust environment for specified user
  • Path Integration: Ensures cargo binaries are available in PATH

Security

The role includes several security features:

  • Checksum Validation: Verifies rustup installer integrity
  • User-level Installation: Installs Rust in user space, not system-wide
  • Official Sources: Downloads only from official Rust infrastructure
  • Non-root Execution: Rust installation runs as target user

Customization

You can customize the Rust installation by overriding variables:

# Install nightly toolchain
rust_toolchain: "nightly"

# Minimal installation
rust_profile: "minimal"

# Additional components
rust_components:
  - rustfmt
  - clippy
  - rust-src
  - rust-analyzer

Validation

The role includes validation to ensure:

  • Rust toolchain is properly installed
  • Cargo is available and functional
  • Components are installed correctly
  • Environment variables are set

License

MIT

Author Information

Development Team - Internal Use