2 unstable releases

Uses new Rust 2024

0.2.0 May 8, 2025
0.1.0 May 7, 2025

#9 in #ad-hoc

Download history 248/week @ 2025-05-06 60/week @ 2025-05-13 3/week @ 2025-05-20

311 downloads per month

MIT license

5KB
82 lines

ansible

Rust API for Ansible

Progress Tracker

  • Ansible inventory command
  • Load trait for inventory to json
  • API to get hosts from inventory
  • API to get vars for host
  • Add Ansible test data to repo for use in test suite
  • Official Rust docs
  • Ansible adhoc command
  • Ansible playbook command

Features

  • Load Ansible inventory data into serde json object
use ansible::{Inventory, Load};

let inventory = Inventory::load(PathBuf::from('/path/to/inventory'))?;
let data = inventory.data
  • Get specific host from Ansible inventory
use ansible::{Inventory, Load};

let inventory = Inventory::load(PathBuf::from('/path/to/inventory'))?;
let host = inventory.get_host("<hostname>")?;
hostvars = host.get_vars()?;
  • Get all hosts from Ansible inventory
use ansible::{Inventory, Load};

let inventory = Inventory::load(PathBuf::from('/path/to/inventory'))?;
let hosts = inventory.get_hosts()?;
for host in hosts {
    hostvars = host.get_vars()?;
}

Tests

  • Execute tests with cargo test -- --nocapture to see stdout

Dependencies

~0.5–1.1MB
~22K SLoC