Skip to main content

devops_armory/
lib.rs

1//! DevOps Armory
2//!
3//! Library created to improve DevOps work.
4//!
5//! ## Example Standalone
6//! 
7//! ```rust
8//!     use devops_armory::{
9//!         rustible::vm::vm_remote::vm_remote::exec_command_on_remote, 
10//!         toml_parser::parser::toml_parser
11//!         };
12//!     use actix_web;
13//! 
14//!     #[actix_web::main]
15//!     async fn test_function() -> Result<(), std::io::Error> {
16//!     
17//!         let ssh_user = "user".to_string();
18//!         let ssh_key_location = "path_to_your_private_ssh_key".to_string();
19//!         let toml_file = "path_to_your_config.toml".to_string();
20//!         let toml_data = toml_parser(toml_file);
21//!         let f = toml_data.unwrap_or_default();
22//!         let g = &f.rustible[0];
23//!         let slack_vm_address_list = &g.vm[0].slackware.ip_address_list;
24//!         let slack_vm_commands = &g.vm[0].slackware.commands;
25//!         exec_command_on_remote(ssh_user, ssh_key_location, slack_vm_address_list.to_vec(), slack_vm_commands.to_vec()).await;
26//!         Ok(())
27//!     
28//!     }
29//! ```
30//! 
31//! ## Example Interactive - Clap Cli
32//! 
33//! ```rust
34//!     use devops_armory::rustible::vm::vm_remote::vm_remote::exec_command_on_remote_cli;
35//!     use actix_web;
36//!     
37//!     #[actix_web::main]
38//!     async fn main() -> Result<(), std::io::Error> {
39//!     
40//!         let x = exec_command_on_remote_cli().await;
41//!     
42//!         match x {
43//!             Ok(s) => s,
44//!             Err(e) => println!("{}", e)
45//!         }
46//!         Ok(())
47//!     
48//!     }
49//! ```
50
51pub mod toml_parser;
52pub mod rustible;
53pub mod cloud;
54pub mod logging;
55pub mod ini_parser;
56pub mod logrotate;
57
58#[cfg(test)]
59mod tests {
60
61    use crate::rustible::vm::vm_remote::vm_remote::exec_command_on_remote;
62    use tokio;
63
64    #[tokio::test]
65    async fn check_rustible_standalone() {
66
67        //Test to pass need actual data to process
68        //Change user, ssh_key_path, ip_list to real values
69        let user = "user".to_string();
70        let ssh_key_path = "path_to_your_key".to_string();
71        let ip_list = vec!["SERVER_IP_to_connect".to_string()];
72        let commands = vec!["ls".to_string(), "pwd".to_string()];
73
74        let test_standalone_result = exec_command_on_remote(user, ssh_key_path, ip_list, commands).await;
75        assert!(test_standalone_result.is_ok());
76    }
77
78}
79