pub struct AnsibleClient { /* private fields */ }Expand description
A specialized Ansible client for configuration management.
This client provides a consistent interface for Ansible operations:
- Run playbooks against target hosts
- Execute ad-hoc commands
- Manage inventory and configuration
Uses CommandExecutor as a collaborator for actual command execution.
Implementations§
Source§impl AnsibleClient
impl AnsibleClient
Sourcepub fn new<P: Into<PathBuf>>(working_dir: P) -> Self
pub fn new<P: Into<PathBuf>>(working_dir: P) -> Self
Creates a new AnsibleClient
§Arguments
working_dir- Path to the directory containingAnsibleconfiguration files
Sourcepub fn run_playbook(
&self,
playbook: &str,
extra_args: &[&str],
) -> Result<String, CommandError>
pub fn run_playbook( &self, playbook: &str, extra_args: &[&str], ) -> Result<String, CommandError>
Run an Ansible playbook with optional extra arguments
§Arguments
playbook- Name of the playbook file (without .yml extension)extra_args- Optional extra arguments to pass to ansible-playbook
§Returns
Ok(String)- The stdout output if the command succeedsErr(CommandError)- Error describing what went wrong
§Errors
This function will return an error if:
- The Ansible playbook execution fails
- The playbook file does not exist in the working directory
- There are issues with the inventory or configuration
§Examples
// Run without extra args (backward compatible)
client.run_playbook("install-docker", &[]).unwrap();
// Run with extra variables
client.run_playbook("configure-firewall", &["-e", "@variables.yml"]).unwrap();Sourcepub fn working_dir(&self) -> &Path
pub fn working_dir(&self) -> &Path
Get the working directory path
Auto Trait Implementations§
impl Freeze for AnsibleClient
impl RefUnwindSafe for AnsibleClient
impl Send for AnsibleClient
impl Sync for AnsibleClient
impl Unpin for AnsibleClient
impl UnsafeUnpin for AnsibleClient
impl UnwindSafe for AnsibleClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request