I posted ansible_module
crate to write Ansible modules in Rust.
You can use cargo doc
for viewing docs or see the examples section.
Testing
I provided rewrited ansible.builtin.slurp
module rewritten in Rust in the examples section of the project, so let’s try it!
git clone https://github.com/bakanovskii/ansible_module_rs.git
cd ansible_module_rs/
cargo build --examples --r
cd examples/
Test small file
Firstly let’s try to compare on a small file:
ANSIBLE_LIBRARY=../target/release/examples/ ansible-playbook test_slurp.yml
So Rust version resulted in 0.03s, while Python resulted in 0.21s
Not bad!
Test big file
Now let’s try to compare on a big file:
ANSIBLE_LIBRARY=../target/release/examples/ ansible-playbook test_slurp_big.yml
Now Rust version resulted in 16.87s, while Python resulted in 23.41s
Why not that big of a difference? Python uses C bindings for base64 encoding/decoding