1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! cdk-ansible is a development framework for defining Ansible applications, similar to AWS CDK.
//!
//! NOTE: The basic implementation is completely different from AWS CDK.
//!
//! cdk-ansible provides the following features:
//!
//! * Define Ansible Plays and Tasks using Rust code (wraps Ansible YAML files)
//! * Enable parallel execution with ease (wraps the `ansible-playbook` command)
//!
//! ## Example
//!
//! ```
//! use ::anyhow::Result;
//! use ::cdk_ansible::{
//! App, Stack, ExeParallel, ExePlay, ExeSequential, ExeSingle, Inventory,
//! InventoryChild, InventoryRoot, OptU, Play, PlayOptions,
//! };
//!
//! // Define a sample stack
//! struct SampleStack {
//! exe_play: ExePlay,
//! }
//!
//! impl SampleStack {
//! fn new(host: &str) -> Self {
//! // Define a sample play
//! let play = Box::new(Play {
//! name: "sample".into(),
//! hosts: vec![host.to_owned()].into(),
//! options: PlayOptions::default(),
//! tasks: vec![
//! // Add tasks later
//! ],
//! });
//!
//! Self {
//! exe_play: ExeSequential(vec![
//! ExeSingle(play.clone()),
//! ExeSequential(vec![ExeSingle(play.clone()), ExeSingle(play.clone())]),
//! ExeParallel(vec![
//! ExeSequential(vec![ExeSingle(play.clone()), ExeSingle(play.clone())]),
//! ExeSingle(play.clone()),
//! ExeParallel(vec![ExeSingle(play.clone()), ExeSingle(play.clone())]),
//! ]),
//! ]),
//! }
//! }
//! }
//!
//! // Stack should implement the `Stack` trait
//! impl Stack for SampleStack {
//! fn name(&self) -> &str {
//! std::any::type_name::<Self>()
//! .split("::")
//! .last()
//! .expect("Failed to get a stack name")
//! }
//!
//! fn exe_play(&self) -> &ExePlay {
//! &self.exe_play
//! }
//! }
//!
//! fn run() -> Result<()> {
//! let mut app = App::new(std::env::args().collect());
//! let inventory = Inventory {
//! name: "inventory".into(), // generate 'inventory.yaml' file
//! root: InventoryRoot {
//! all: InventoryChild {
//! hosts: OptU::Some([("localhost".into(), None)].into_iter().collect()),
//! ..Default::default()
//! },
//! },
//! };
//!
//! app.add_inventory(inventory)?;
//! app.add_stack(Box::new(SampleStack::new("localhost")))?;
//!
//! // app.run()? // replace `Ok(())` with `app.run()`
//! Ok(())
//! }
//!
//! fn main() {
//! if let Err(e) = run() {
//! eprintln!("Error: {e:?}");
//! std::process::exit(1);
//! }
//! }
//! ```
//!
//! ## Tutorial
//!
//! ### Install cdk-ansible-cli
//!
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
// Re-export macros
pub use *;