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
//! Gather information on hosts
//!
//! Example usage:
//!
//! ```no_run
//! use tricorder::prelude::*;
//! use tricorder::tasks::info;
//! use serde_json::json;
//!
//! let inventory = Inventory::new()
//! .add_host(
//! Host::new(Host::id("localhost").unwrap(), "localhost:22".to_string())
//! .set_user("root".to_string())
//! .add_tag(Host::tag("local").unwrap())
//! .set_var("msg".to_string(), json!("hello"))
//! .to_owned()
//! )
//! .to_owned();
//!
//! let task = info::Task::new();
//! let result = inventory.hosts.run_task_seq(&task).unwrap();
//! ```
//!
//! The result is a JSON document with the following structure:
//!
//! ```json
//! [
//! {
//! "host": "localhost",
//! "success": true,
//! "info": {
//! "id": "localhost",
//! "address": "localhost:22",
//! "user": "root",
//! "tags": ["local"],
//! "vars": {"msg": "hello"}
//! }
//! }
//! ]
//! ```
//!
//! > **NB:** In the future, will be gathered facts like:
//! > - network interfaces
//! > - hostname and FQDN
//! > - OS / Kernel version
//! > - partitions / mount points
//! > - ...
use crate*;
use json;
/// Describe an `info` task
;