Ansible modules

Are you aware of any Ansible module written in Rust? I want to create one, and I hope there's one I can use as an example.

It looks like ansible modules just work with JSON written over STDIN/STDOUT. There probably won't be any tutorials or examples of implementing a module in Rust, but it shouldn't be too hard to read through their Python example and adapt it to Rust.

Some useful links:

  • std::io::stdin() - something that lets you read data from STDIN
  • serde - a framework for doing serialization and deserialization
  • serde_json::from_reader() - deserialize JSON data into some type that you define by reading from some reader (i.e. std::io::Stdin)
  • serde_json::to_string() - for converting your output struct into JSON text
  • println!() for actually printing the output to STDOUT

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.