From: Luis Chamberlain <mcgrof@kernel.org>
To: Chuck Lever <cel@kernel.org>, Daniel Gomez <da.gomez@kruces.com>,
kdevops@lists.linux.dev
Cc: Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH 1/5] install-rust-deps: Add generic Rust toolchain role
Date: Fri, 17 Oct 2025 19:32:13 -0700 [thread overview]
Message-ID: <20251018023218.2240269-2-mcgrof@kernel.org> (raw)
In-Reply-To: <20251018023218.2240269-1-mcgrof@kernel.org>
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 <mcgrof@kernel.org>
---
.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
next prev parent reply other threads:[~2025-10-18 2:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-18 2:32 [PATCH 0/5] rust + rcloud support Luis Chamberlain
2025-10-18 2:32 ` Luis Chamberlain [this message]
2025-10-18 2:32 ` [PATCH 2/5] CLAUDE.md: Add Rust code quality requirements Luis Chamberlain
2025-10-18 2:32 ` [PATCH 3/5] bootlinux: Integrate Rust toolchain dependencies Luis Chamberlain
2025-10-18 2:32 ` [PATCH 4/5] install-go-deps: Add generic Go toolchain role Luis Chamberlain
2025-10-18 2:32 ` [PATCH 5/5] rcloud: Add experimental private cloud infrastructure for bare metal Luis Chamberlain
2025-10-18 18:22 ` [PATCH 0/5] rust + rcloud support Chuck Lever
2025-10-21 16:58 ` Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251018023218.2240269-2-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=cel@kernel.org \
--cc=da.gomez@kruces.com \
--cc=kdevops@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox