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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//! # Regent SDK
//!
//! A **multi-paradigm configuration management system as a library**.
//!
//! Regent SDK provides an engine for declarative configuration management,
//! allowing you to define expected system states and automatically assess/remedy compliance.
//! Because it's an engine, you still have to embed it in something else, such as a all-in-one CLI tool,
//! a distributed system wich a control node and workers, a monitoring system which feeds a web interface
//! in real time with systems status, an agent which regularly fetches a remote git repository and applies
//! configuration on its localhost... whatever suits your needs and specific constraints !
//!
//! *Note: While inspired by Ansible in several ways, Regent does not aim to reproduce its API or behaviors.
//!
//! ## Core Concepts
//!
//! Regent is built around three key concepts:
//!
//! - **Expected State**: The desired configuration of your system, defined via [`ExpectedState`]
//! - **Attributes**: Building blocks that describe that state (see [`attribute`] module)
//! - **Compliance**: Whether a host matches its expected state, with methods to **assess** or **enforce** it
//!
//! ## Features
//!
//! Enable the following Cargo features for additional capabilities:
//!
//! - `aws-secretsmanager`: Enable AWS Secrets Manager support via `SecretProvider::aws_secretsmanager`
//! - `gcp-secretmanager`: Enable Google Cloud Secret Manager support via `SecretProvider::gcp_secretmanager`
//! - `windows`: Enable Windows support, including Windows OS detection, command execution, and service management
//!
//! ## Capabilities
//!
//! - **Declarative State Management**: Define infrastructure as code using [`ExpectedState`] and [`Attribute`]
//! - **Multi-Protocol Host Management**: Connect to hosts via [`Ssh2HostHandler`] or [`LocalHostHandler`]
//! - **Comprehensive Resource Modules**: Manage packages, services, users, groups, cron jobs, files, iptables, and more
//! - **Secret Management**: Secure secret retrieval from multiple providers using [`SecretProvidersPoolBuilder`]
//! - **Task Distribution**: Serializable tasks for distributed workload execution using [`RegentTask`] and [`Job`]
//! - **Compliance Engine**: Automatic assessment and remediation via [`ManagedHost::assess_compliance`] and [`ManagedHost::reach_compliance`]
//! - **Idempotent Operations**: All operations are designed to be idempotent
//! - **Templating Support**: Variable substitution using Tera templates
//!
//! ## Usage
//!
//! The primary workflow with Regent's Rust API:
//!
//! ```no_run
//! use regent_sdk::{Attribute, ConnectionMethod, ExpectedState, ManagedHostBuilder, Privilege};
//! use regent_sdk::{SecretProvider, SecretProvidersPoolBuilder, TargetUser};
//! use regent_sdk::attribute::system::service::{ServiceBlockExpectedState, ServiceExpectedState};
//!
//! #[tokio::main]
//! async fn main() {
//! // 1. Create a secret providers pool
//! let secrets_pool = SecretProvidersPoolBuilder::new()
//! .add_default_provider("files", SecretProvider::files())
//! .build()
//! .unwrap();
//!
//! // 2. Define and connect to the target host
//! let mut managed_host = ManagedHostBuilder::new(
//! "web-server-01",
//! "192.168.1.100:22",
//! Some(ConnectionMethod::Localhost(TargetUser::current_user())),
//! )
//! .build(Some(secrets_pool))
//! .await
//! .unwrap();
//!
//! managed_host.connect().unwrap();
//!
//! // 3. Define the expected state using attributes
//! let nginx_service = ServiceBlockExpectedState::state("nginx", ServiceExpectedState::Started, true);
//!
//! let expected_state = ExpectedState::new()
//! .with_attribute(Attribute::service(
//! nginx_service,
//! Privilege::WithSudo,
//! Some("Ensure nginx is running".to_string()),
//! ))
//! .build();
//!
//! // 4. Assess compliance
//! let status = managed_host
//! .assess_compliance(&expected_state)
//! .await
//! .unwrap();
//!
//! if !status.is_already_compliant() {
//! // 5. Or enforce it directly
//! managed_host.reach_compliance(&expected_state).await.unwrap();
//! }
//! }
//! ```
//!
//! For YAML-based configuration, see [`ExpectedState::from_raw_yaml`] and [`Inventory`].
//!
//! ## Attribute Categories
//!
//! Available attribute modules for defining expected state:
//!
//! - **[`attribute::system`]**: System resources (services, users, groups, cron, hostname)
//! - **[`attribute::package`]**: Package management (apt, yum/dnf, pacman, repositories)
//! - **[`attribute::network`]**: Network configuration (iptables)
//! - **[`attribute::shell`]**: Shell commands
//! - **[`attribute::utilities`]**: Utilities (line in file, debug, ping)
//! - **[`attribute::ai`]**: AI integration (Ollama)
//!
//! ## Connection Methods
//!
//! Connect to hosts using:
//!
//! - **[`hosts::handlers::localhost::LocalHostHandler`]**: Execute on the local machine
//! - **[`hosts::handlers::ssh2::Ssh2HostHandler`]**: Connect to remote hosts via SSH2
//!
//! ## Secret Management
//!
//! Securely retrieve secrets from:
//!
//! - **Local**: Files and environment variables
//! - **Cloud**: AWS Secrets Manager, Google Cloud Secret Manager (enable via features)
//!
//! See [`SecretProvidersPoolBuilder`] for configuration options.
//!
//! ## Task Distribution
//!
//! Create serializable tasks for distributed execution:
//!
//! ```no_run
//! use regent_sdk::{Job, RegentTask};
//!
//! let task = RegentTask::from(managed_host_builder, expected_state, Job::Assess);
//! let serialized = serde_json::to_string(&task).unwrap();
//! let mut task: RegentTask = serde_json::from_str(&serialized).unwrap();
//! let result = task.run(Some(secrets_pool)).await.unwrap();
//! ```
pub use RegentError;
pub use ;
pub use ;
pub use ;
pub use Inventory;
pub use ;
pub use Privilege;
pub use ;
pub use ExpectedState;
pub use attribute;
pub use Attribute;
pub use ;