pub struct DefaultsBuilder { /* private fields */ }Expand description
Builder for constructing Defaults instances.
This builder provides a fluent interface for creating inventory defaults with optional
configuration fields. All fields start as None and can be set individually using the
builder methods before calling build() to create the final Defaults instance.
Defaults define base configuration values that apply to all hosts and groups in the inventory unless overridden at the group or host level. This allows for centralized management of common connection parameters and data.
Unlike Host and Group, defaults do not support groups membership.
§Fields
-
hostname- Optional default hostname or IP address. Applied to hosts/groups that don’t specify their own hostname. -
port- Optional default port number for connections. Applied to hosts/groups that don’t specify their own port. -
username- Optional default username for authentication. Applied to hosts/groups that don’t specify their own username. -
password- Optional default password for authentication. Applied to hosts/groups that don’t specify their own password. -
platform- Optional default platform identifier (e.g., “linux”, “cisco_ios”). Applied to hosts/groups that don’t specify their own platform. -
data- Optional arbitrary JSON data that applies to all hosts/groups by default. Can be overridden or merged at the group or host level. -
connection_options- Optional map of connection-specific overrides keyed by connection plugin name. Allows per-connection-plugin-name customization of default parameters.
§Examples
let defaults = Defaults::builder()
.username("admin")
.port(22)
.platform("linux")
.build();
assert_eq!(defaults.username(), Some("admin"));
assert_eq!(defaults.port(), Some(22));Implementations§
Source§impl DefaultsBuilder
impl DefaultsBuilder
pub fn new() -> Self
pub fn hostname<S>(self, hostname: S) -> Self
pub fn port(self, port: u16) -> Self
pub fn username<S>(self, username: S) -> Self
pub fn password<S>(self, password: S) -> Self
pub fn platform<S>(self, platform: S) -> Self
pub fn data(self, data: Data) -> Self
Sourcepub fn connection_options<S>(self, name: S, options: ConnectionOptions) -> Self
pub fn connection_options<S>(self, name: S, options: ConnectionOptions) -> Self
Adds or updates connection-specific options for defaults.
§Parameters
name- A string-like value identifying the connection plugin name (e.g., “ssh”, “netconf”).options- AConnectionOptionsinstance containing connection-specific configuration.
§Returns
Returns Self with the connection options updated, allowing for method chaining.
If no connection options map exists, one is created before inserting the new options.