From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12BA720487E for ; Sat, 18 Oct 2025 02:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760754741; cv=none; b=ahDrK0M09klEcv0avEmBVDQnv7DR27HHzF57dEceuUytaB3atuwGk1Dzg3Lp9IlxP6ZTFkhkrT8N3rxAE54DXZjxsqOpt0Ti8f2acrkf2dAT4b5SwOQ4bqaaE9mGcA2/BQWQPn1llamjo7BCoLhvolHHPxEPF2gVaNXjyh/Xwzk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760754741; c=relaxed/simple; bh=uT1GtMvcRYmdmWd/ltOihjGpFhK8q2oy+BdVR5jRDiY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mWcFcZ3/ZxjM0+o5XLSHEISTx69LAlmgkto1nPuQdaN80GrgDlS8Uz57lAqwTO/pu7lw0MzGvnjDfK6kpUkW7wE/TlymdftsvwxhbKR4faovoHnQfrLSlX7cEh7Zu70CNF47VNmfcaOZerzFlG59hsONNBx0soHnurK9jV6e5zw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=jKlPrbsp; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="jKlPrbsp" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=KfpVSRqBxcq6SyooXKCG8uk/EAMhmT77dwWuJISTBcE=; b=jKlPrbsp3GdkQilwTF8v7KZ/gh FBiVGwYD4vc+FK0h5QIdm/ruf5aLbwF3nQ3CAVmWjiACL4TQ+Uqj2BaZ/RT1FBYsEw0+sQrrrunRf WA5ijKK5v0DMhk01EUJsQ/5snW13c6hKxP/FiqYy7TkPMw+2DESN6O4AQTUYJ2o0TOj6MeyzliC/Q Y7fPV034zfRQOQtjYFUsDAy3jjIPV/zgiQr8IoF3IU7OMb6PZubiApugSxYw1j9XxetzLguD33Ev2 +oG4wpye6ySQWIAz8lQgmC+/gLGiNVfdfFI4chpncDGmynE6OJOU77+4ZHzbYE7SZ+ICl/3aScCYm pPUmfiCw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1v9wjz-00000009Onn-2ahJ; Sat, 18 Oct 2025 02:32:19 +0000 From: Luis Chamberlain To: Chuck Lever , Daniel Gomez , kdevops@lists.linux.dev Cc: Luis Chamberlain Subject: [PATCH 1/5] install-rust-deps: Add generic Rust toolchain role Date: Fri, 17 Oct 2025 19:32:13 -0700 Message-ID: <20251018023218.2240269-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251018023218.2240269-1-mcgrof@kernel.org> References: <20251018023218.2240269-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain Add reusable install-rust-deps role that provides consistent Rust toolchain installation across all distributions: - Debian/Ubuntu: cargo, rustc, pkg-config - Fedora/RHEL: cargo, rust, pkgconfig - SUSE: cargo, rust, pkg-config This modular role can be included by any workflow or role needing Rust support, following kdevops patterns for dependency management. Adopt Linux kernel's .rustfmt.toml configuration to enforce consistent Rust code formatting across kdevops. This enables 'cargo fmt' to automatically format Rust code according to kernel standards, ensuring code quality and consistency. Generated-by: Claude AI Signed-off-by: Luis Chamberlain --- .rustfmt.toml | 12 +++ playbooks/roles/install-rust-deps/README.md | 90 +++++++++++++++++++ .../tasks/install-deps/debian/main.yml | 12 +++ .../tasks/install-deps/fedora/main.yml | 11 +++ .../tasks/install-deps/main.yml | 21 +++++ .../tasks/install-deps/redhat/main.yml | 11 +++ .../tasks/install-deps/suse/main.yml | 11 +++ .../roles/install-rust-deps/tasks/main.yml | 15 ++++ 8 files changed, 183 insertions(+) create mode 100644 .rustfmt.toml create mode 100644 playbooks/roles/install-rust-deps/README.md create mode 100644 playbooks/roles/install-rust-deps/tasks/install-deps/debian/main.yml create mode 100644 playbooks/roles/install-rust-deps/tasks/install-deps/fedora/main.yml create mode 100644 playbooks/roles/install-rust-deps/tasks/install-deps/main.yml create mode 100644 playbooks/roles/install-rust-deps/tasks/install-deps/redhat/main.yml create mode 100644 playbooks/roles/install-rust-deps/tasks/install-deps/suse/main.yml create mode 100644 playbooks/roles/install-rust-deps/tasks/main.yml diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 00000000..3de5cc49 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,12 @@ +edition = "2021" +newline_style = "Unix" + +# Unstable options that help catching some mistakes in formatting and that we may want to enable +# when they become stable. +# +# They are kept here since they are useful to run from time to time. +#format_code_in_doc_comments = true +#reorder_impl_items = true +#comment_width = 100 +#wrap_comments = true +#normalize_comments = true diff --git a/playbooks/roles/install-rust-deps/README.md b/playbooks/roles/install-rust-deps/README.md new file mode 100644 index 00000000..f6dd654a --- /dev/null +++ b/playbooks/roles/install-rust-deps/README.md @@ -0,0 +1,90 @@ +# install-rust-deps Role + +Generic Ansible role for installing Rust toolchain dependencies across multiple +Linux distributions. + +## Purpose + +Provides consistent Rust build environment setup for any kdevops workflow or +role that needs Rust support. This modular role can be included via +`ansible.builtin.include_role` to ensure cargo, rustc, and pkg-config are +available. + +## Packages Installed + +### Debian/Ubuntu +- `cargo` - Rust package manager and build tool +- `rustc` - Rust compiler +- `pkg-config` - Helper tool for compiling applications + +### Fedora/RHEL/CentOS +- `cargo` - Rust package manager and build tool +- `rust` - Rust compiler +- `pkgconfig` - Helper tool for compiling applications + +### SUSE/openSUSE +- `cargo` - Rust package manager and build tool +- `rust` - Rust compiler +- `pkg-config` - Helper tool for compiling applications + +## Rust Code Quality Tools + +This role provides the foundation for Rust development in kdevops. After +installation, the following tools are available: + +### cargo fmt +Automatic code formatter using Linux kernel rustfmt standards: +```bash +cd workflows/rcloud # or any Rust project +cargo fmt +``` + +Configuration is provided via `.rustfmt.toml` in the kdevops root directory +(included with this role). + +### cargo clippy +Linter for catching common mistakes and non-idiomatic code: +```bash +cd workflows/rcloud # or any Rust project +cargo clippy --all-targets --all-features -- -D warnings +``` + +**Always run both tools before committing Rust code:** +1. `cargo fmt` - Auto-format according to kernel standards +2. `cargo clippy` - Fix all warnings (treated as errors with `-D warnings`) + +## Usage + +### Include in Your Role + +```yaml +- name: Install Rust build dependencies + ansible.builtin.include_role: + name: install-rust-deps +``` + +### Example Workflows Using This Role + +- **bootlinux**: Kernel builds with Rust support +- **rcloud**: Private cloud infrastructure written in Rust + +## Files Provided + +- `.rustfmt.toml` - Linux kernel Rust formatting configuration + - Edition 2021 + - Unix newlines + - Consistent code style across all kdevops Rust code + +## Design Philosophy + +This role follows kdevops patterns: +- Distribution-agnostic with distro-specific task files +- No conditional installation guards (always ensures packages present) +- Minimal dependencies +- Reusable across workflows + +## See Also + +- `install-go-deps` - Similar role for Go toolchain +- `install-rcloud-deps` - Uses this role for rcloud workflow +- `CLAUDE.md` - Code quality requirements including Rust guidelines diff --git a/playbooks/roles/install-rust-deps/tasks/install-deps/debian/main.yml b/playbooks/roles/install-rust-deps/tasks/install-deps/debian/main.yml new file mode 100644 index 00000000..9526fd55 --- /dev/null +++ b/playbooks/roles/install-rust-deps/tasks/install-deps/debian/main.yml @@ -0,0 +1,12 @@ +--- +- name: Install Rust build dependencies + become: true + become_method: sudo + ansible.builtin.apt: + name: + - cargo + - rustc + - pkg-config + state: present + update_cache: false + tags: ["rust", "deps"] diff --git a/playbooks/roles/install-rust-deps/tasks/install-deps/fedora/main.yml b/playbooks/roles/install-rust-deps/tasks/install-deps/fedora/main.yml new file mode 100644 index 00000000..d87c50f2 --- /dev/null +++ b/playbooks/roles/install-rust-deps/tasks/install-deps/fedora/main.yml @@ -0,0 +1,11 @@ +--- +- name: Install Rust build dependencies + become: true + become_method: sudo + ansible.builtin.dnf: + name: + - cargo + - rust + - pkgconfig + state: present + tags: ["rust", "deps"] diff --git a/playbooks/roles/install-rust-deps/tasks/install-deps/main.yml b/playbooks/roles/install-rust-deps/tasks/install-deps/main.yml new file mode 100644 index 00000000..23cda58e --- /dev/null +++ b/playbooks/roles/install-rust-deps/tasks/install-deps/main.yml @@ -0,0 +1,21 @@ +--- +- name: Import optional distribution specific variables + ansible.builtin.include_vars: "{{ item }}" + ignore_errors: true + with_first_found: + - files: + - "{{ ansible_facts['os_family'] | lower }}.yml" + skip: true + tags: vars + +- name: Distribution specific setup + ansible.builtin.import_tasks: debian/main.yml + when: ansible_facts['os_family']|lower == 'debian' +- ansible.builtin.import_tasks: suse/main.yml + when: ansible_facts['os_family']|lower == 'suse' +- ansible.builtin.import_tasks: redhat/main.yml + when: + - ansible_facts['os_family']|lower == 'redhat' + - ansible_facts['distribution']|lower != "fedora" +- ansible.builtin.import_tasks: fedora/main.yml + when: ansible_facts['distribution']|lower == "fedora" diff --git a/playbooks/roles/install-rust-deps/tasks/install-deps/redhat/main.yml b/playbooks/roles/install-rust-deps/tasks/install-deps/redhat/main.yml new file mode 100644 index 00000000..d87c50f2 --- /dev/null +++ b/playbooks/roles/install-rust-deps/tasks/install-deps/redhat/main.yml @@ -0,0 +1,11 @@ +--- +- name: Install Rust build dependencies + become: true + become_method: sudo + ansible.builtin.dnf: + name: + - cargo + - rust + - pkgconfig + state: present + tags: ["rust", "deps"] diff --git a/playbooks/roles/install-rust-deps/tasks/install-deps/suse/main.yml b/playbooks/roles/install-rust-deps/tasks/install-deps/suse/main.yml new file mode 100644 index 00000000..cc806b14 --- /dev/null +++ b/playbooks/roles/install-rust-deps/tasks/install-deps/suse/main.yml @@ -0,0 +1,11 @@ +--- +- name: Install Rust build dependencies + become: true + become_method: sudo + community.general.zypper: + name: + - cargo + - rust + - pkg-config + state: present + tags: ["rust", "deps"] diff --git a/playbooks/roles/install-rust-deps/tasks/main.yml b/playbooks/roles/install-rust-deps/tasks/main.yml new file mode 100644 index 00000000..946b9c8e --- /dev/null +++ b/playbooks/roles/install-rust-deps/tasks/main.yml @@ -0,0 +1,15 @@ +--- +- name: Import optional extra_args file + ansible.builtin.include_vars: "{{ item }}" + ignore_errors: true + with_first_found: + - files: + - "../extra_vars.yml" + - "../extra_vars.yaml" + - "../extra_vars.json" + skip: true + tags: vars + +# Install Rust build dependencies +- name: Install Rust build dependencies + ansible.builtin.include_tasks: install-deps/main.yml -- 2.51.0