CDK Ansible by Rust
This project is under construction.
cdk-ansible is a CDK (Cloud Development Kit) for Ansible, and inspired by AWS CDK.
While Ansible's playbook and inventory files are written in YAML format, managing YAML templating can be challenging.
cdk-ansible enables you to generate Ansible files using Rust as a type-safe programming language.
Features
- cdk-ansible crate helps you to generate Ansible Playbook and Inventory files.
- cdk-ansible-cli (
cdk-ansiblecommand) generates Rust packages for existing Ansible modules.
Install Command
binstall
shell
See the latest release page and run the command like below.
# ex) vX.Y.Z
|
cargo install
Usage
Init cdk-ansible project
Note: (Future feature) cdk-ansible project to create a new cdk-ansible's template project.
proj-root/
`-- cdk-ansible/
`-- Cargo.toml ... workspace cargo
define `workspace.dependencies.cdk-ansible`.
Create Ansible Module package for the workspace
# specify module name like below.
#
# '<namespace>.<collection>.<module>' only generates the specified module.
# '<namespace>.<collection>' generates all modules in the collection.
# '<namespace>' generates all modules in the namespace.
# If you don't specify `--module-name` or `--module-name-regex`,
# all modules accessible from your ansible environment will be generated.
# (This is the same as `--module-name-regex '*'`)
# If you are using uv to manage your ansible project, move to the directory or specify the `--project` option.
proj-root/
`-- cdk-ansible/
|-- Cargo.toml
`-- crates/
`-- cdkam_ansible/ ... auto-generated by `cdk-ansible module` command
|-- Cargo.toml
`-- src/
|-- lib.rs
|-- m/ansible/builtin/debug.rs
`-- ...
Define your app
your-app project should be like simple-sample.
proj-root/
`-- cdk-ansible/
`-- crates/
|-- cdkam_ansible/
`-- your-app/ ... Implement `cdk_ansible::Synthesizer` and call `cdk_ansible::run`
Synthesize Ansible files
proj-root/
|-- cdk-ansible/
`-- ansible/ ... Your ansible project
|-- inventory/ ... auto-generated by `cdk-ansible synth` command
|-- playbooks/ ... auto-generated by `cdk-ansible synth` command
|-- ...
`-- pyproject.toml
Because synth subcommand generates 'json' files, not yaml yet, you need to convert them to yaml manually.
|