forked from NationTech/harmony
78 lines
2.1 KiB
Rust
78 lines
2.1 KiB
Rust
use harmony::{
|
|
config::secret::OPNSenseFirewallCredentials,
|
|
infra::opnsense::OPNSenseFirewall,
|
|
inventory::Inventory,
|
|
modules::{dhcp::DhcpScore, opnsense::OPNsenseShellCommandScore},
|
|
topology::LogicalHost,
|
|
};
|
|
use harmony_macros::{ip, ipv4};
|
|
use harmony_secret::{Secret, SecretManager};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let firewall = LogicalHost {
|
|
ip: ip!("192.168.1.1"),
|
|
name: String::from("opnsense-1"),
|
|
};
|
|
|
|
let opnsense_auth = SecretManager::get_or_prompt::<OPNSenseFirewallCredentials>()
|
|
.await
|
|
.expect("Failed to get credentials");
|
|
|
|
let opnsense = OPNSenseFirewall::new(
|
|
firewall,
|
|
None,
|
|
&opnsense_auth.username,
|
|
&opnsense_auth.password,
|
|
)
|
|
.await;
|
|
|
|
let dhcp_score = DhcpScore {
|
|
dhcp_range: (
|
|
ipv4!("192.168.1.100").into(),
|
|
ipv4!("192.168.1.150").into(),
|
|
),
|
|
host_binding: vec![],
|
|
next_server: None,
|
|
boot_filename: None,
|
|
filename: None,
|
|
filename64: None,
|
|
filenameipxe: Some("filename.ipxe".to_string()),
|
|
domain: None,
|
|
};
|
|
// let dns_score = OKDDnsScore::new(&topology);
|
|
// let load_balancer_score = OKDLoadBalancerScore::new(&topology);
|
|
//
|
|
// let tftp_score = TftpScore::new(Url::LocalFolder("./data/watchguard/tftpboot".to_string()));
|
|
// let http_score = StaticFilesHttpScore {
|
|
// folder_to_serve: Some(Url::LocalFolder(
|
|
// "./data/watchguard/pxe-http-files".to_string(),
|
|
// )),
|
|
// files: vec![],
|
|
// remote_path: None,
|
|
// };
|
|
let opnsense_config = opnsense.get_opnsense_config();
|
|
|
|
harmony_cli::run(
|
|
Inventory::autoload(),
|
|
opnsense,
|
|
vec![
|
|
Box::new(dhcp_score),
|
|
Box::new(OPNsenseShellCommandScore {
|
|
opnsense: opnsense_config,
|
|
command: "touch /tmp/helloharmonytouching_2".to_string(),
|
|
}),
|
|
],
|
|
None,
|
|
)
|
|
.await
|
|
.unwrap();
|
|
}
|
|
|
|
#[derive(Secret, Serialize, Deserialize, Debug)]
|
|
pub struct BrocadeSwitchAuth {
|
|
pub username: String,
|
|
pub password: String,
|
|
}
|