ansible.plugins.connection package¶
- 
class 
ansible.plugins.connection.ConnectionBase(play_context, new_stdin, *args, **kwargs)[source]¶ Bases:
objectA base class for connections to contain common code.
- 
has_pipelining= False¶ 
- 
become_methods= ['sudo', 'su', 'pbrun', 'pfexec', 'runas', 'doas', 'dzdo']¶ 
- 
module_implementation_preferences= ('',)¶ 
- 
allow_executable= True¶ 
- 
connected¶ Read-only property holding whether the connection to the remote host is active or closed.
- 
set_host_overrides(host, hostvars=None)[source]¶ An optional method, which can be used to set connection plugin parameters from variables set on the host (or groups to which the host belongs)
Any connection plugin using this should first initialize its attributes in an overridden def __init__(self):, and then use host.get_vars() to find variables which may be used to set those attributes in this method.
- 
transport¶ String used to identify this Connection class from other classes
- 
exec_command(*args, **kwargs)[source]¶ Run a command on the remote host.
Parameters: - cmd (bytestring) – byte string containing the command
 - in_data – If set, this data is passed to the command’s stdin. This is used to implement pipelining. Currently not all connection plugins implement pipelining.
 - sudoable – Tell the connection plugin if we’re executing a command via a privilege escalation mechanism. This may affect how the connection plugin returns data. Note that not all connections can handle privilege escalation.
 
Returns: a tuple of (return code, stdout, stderr) The return code is an int while stdout and stderr are both byte strings.
When a command is executed, it goes through multiple commands to get there. It looks approximately like this:
[LocalShell] ConnectionCommand [UsersLoginShell (*)] ANSIBLE_SHELL_EXECUTABLE [(BecomeCommand ANSIBLE_SHELL_EXECUTABLE)] Command
LocalShell: Is optional. It is run locally to invoke the Connection Command. In most instances, theConnectionCommandcan be invoked directly instead. The ssh connection plugin which can have values that need expanding locally specified via ssh_args is the sole known exception to this. Shell metacharacters in the command itself should be processed on the remote machine, not on the local machine so no shell is needed on the local machine. (Example,/bin/sh)ConnectionCommand: This is the command that connects us to the remote machine to run the rest of the command. ansible_ssh_user,ansible_ssh_hostand so forth are fed to this piece of the command to connect to the correct host (Examplesssh,chroot)UsersLoginShell: This shell may or may not be created depending on the ConnectionCommand used by the connection plugin. This is the shell that the ansible_ssh_userhas configured as their login shell. In traditional UNIX parlance, this is the last field of a user’s/etc/passwdentry We do not specifically try to run theUsersLoginShellwhen we connect. Instead it is implicit in the actions that theConnectionCommandtakes when it connects to a remote machine.ansible_shell_typemay be set to inform ansible of differences in how theUsersLoginShellhandles things like quoting if a shell has different semantics than the Bourne shell.ANSIBLE_SHELL_EXECUTABLE: This is the shell set via the inventory var ansible_shell_executableor viaconstants.DEFAULT_EXECUTABLEif the inventory var is not set. We explicitly invoke this shell so that we have predictable quoting rules at this point.ANSIBLE_SHELL_EXECUTABLEis only settable by the user because some sudo setups may only allow invoking a specific shell. (For instance,/bin/bashmay be allowed but/bin/sh, our default, may not). We invoke this twice, once after theConnectionCommandand once after theBecomeCommand. After the ConnectionCommand, this is run by theUsersLoginShell. After theBecomeCommandwe specify that theANSIBLE_SHELL_EXECUTABLEis being invoked directly.BecomeComand ANSIBLE_SHELL_EXECUTABLE: Is the command that performs privilege escalation. Setting this up is performed by the action plugin prior to running exec_command. So we just get passed :param cmd which has the BecomeCommand already added. (Examples: sudo, su) If we have a BecomeCommand then we will invoke a ANSIBLE_SHELL_EXECUTABLE shell inside of it so that we have a consistent view of quoting.Command: Is the command we’re actually trying to run remotely. (Examples: mkdir -p $HOME/.ansible, python $HOME/.ansible/tmp-script-file) 
- 
 
Submodules¶
ansible.plugins.connection.accelerate module¶
- 
class 
ansible.plugins.connection.accelerate.Connection(*args, **kwargs)[source]¶ Bases:
ansible.plugins.connection.ConnectionBaseraw socket accelerated connection
- 
transport= 'accelerate'¶ 
- 
has_pipelining= False¶ 
- 
become_methods= frozenset(['pbrun', 'pfexec', 'dzdo', 'sudo', 'su', 'doas'])¶ 
- 
 
ansible.plugins.connection.chroot module¶
- 
class 
ansible.plugins.connection.chroot.Connection(play_context, new_stdin, *args, **kwargs)[source]¶ Bases:
ansible.plugins.connection.ConnectionBaseLocal chroot based connections
- 
transport= 'chroot'¶ 
- 
has_pipelining= True¶ 
- 
become_methods= frozenset(['pbrun', 'pfexec', 'dzdo', 'runas', 'sudo', 'doas'])¶ 
- 
 
ansible.plugins.connection.docker module¶
- 
class 
ansible.plugins.connection.docker.Connection(play_context, new_stdin, *args, **kwargs)[source]¶ Bases:
ansible.plugins.connection.ConnectionBaseLocal docker based connections
- 
transport= 'docker'¶ 
- 
has_pipelining= True¶ 
- 
become_methods= frozenset(['pbrun', 'pfexec', 'dzdo', 'runas', 'sudo', 'doas'])¶ 
- 
 
ansible.plugins.connection.funcd module¶
ansible.plugins.connection.jail module¶
ansible.plugins.connection.libvirt_lxc module¶
- 
class 
ansible.plugins.connection.libvirt_lxc.Connection(play_context, new_stdin, *args, **kwargs)[source]¶ Bases:
ansible.plugins.connection.ConnectionBaseLocal lxc based connections
- 
transport= 'libvirt_lxc'¶ 
- 
has_pipelining= True¶ 
- 
become_methods= frozenset(['pbrun', 'pfexec', 'dzdo', 'runas', 'sudo', 'doas'])¶ 
- 
 
ansible.plugins.connection.local module¶
- 
class 
ansible.plugins.connection.local.Connection(play_context, new_stdin, *args, **kwargs)[source]¶ Bases:
ansible.plugins.connection.ConnectionBaseLocal based connections
- 
transport= 'local'¶ 
- 
has_pipelining= True¶ 
- 
 
ansible.plugins.connection.lxc module¶
- 
class 
ansible.plugins.connection.lxc.Connection(play_context, new_stdin, *args, **kwargs)[source]¶ Bases:
ansible.plugins.connection.ConnectionBaseLocal lxc based connections
- 
transport= 'lxc'¶ 
- 
has_pipelining= True¶ 
- 
become_methods= frozenset(['pbrun', 'pfexec', 'runas', 'sudo', 'su', 'doas', 'dzdo'])¶ 
- 
 
ansible.plugins.connection.lxd module¶
- 
class 
ansible.plugins.connection.lxd.Connection(play_context, new_stdin, *args, **kwargs)[source]¶ Bases:
ansible.plugins.connection.ConnectionBaselxd based connections
- 
transport= 'lxd'¶ 
- 
has_pipelining= True¶ 
- 
 
ansible.plugins.connection.paramiko_ssh module¶
- 
class 
ansible.plugins.connection.paramiko_ssh.MyAddPolicy(new_stdin, connection)[source]¶ Bases:
objectBased on AutoAddPolicy in paramiko so we can determine when keys are added and also prompt for input.
Policy for automatically adding the hostname and new host key to the local L{HostKeys} object, and saving it. This is used by L{SSHClient}.
- 
class 
ansible.plugins.connection.paramiko_ssh.Connection(play_context, new_stdin, *args, **kwargs)[source]¶ Bases:
ansible.plugins.connection.ConnectionBaseSSH based connections with Paramiko
- 
transport= 'paramiko'¶ 
- 
 
ansible.plugins.connection.ssh module¶
- 
class 
ansible.plugins.connection.ssh.Connection(*args, **kwargs)[source]¶ Bases:
ansible.plugins.connection.ConnectionBasessh based connections
- 
transport= 'ssh'¶ 
- 
has_pipelining= True¶ 
- 
become_methods= frozenset(['pbrun', 'pfexec', 'dzdo', 'sudo', 'su', 'doas'])¶ 
- 
 
ansible.plugins.connection.winrm module¶
ansible.plugins.connection.zone module¶
- 
class 
ansible.plugins.connection.zone.Connection(play_context, new_stdin, *args, **kwargs)[source]¶ Bases:
ansible.plugins.connection.ConnectionBaseLocal zone based connections
- 
transport= 'zone'¶ 
- 
has_pipelining= True¶ 
- 
become_methods= frozenset(['pbrun', 'pfexec', 'dzdo', 'runas', 'sudo', 'doas'])¶ 
-