How do you choose the connection type for different targets?
IntermediateProductionArchitecture Decisions and Tool Comparisons
Answer
| Target | Connection | Notes |
|---|---|---|
| Linux, reachable | ssh (default) |
Pipelining and ControlPersist for speed |
| AWS instances without SSH | amazon.aws.aws_ssm |
Needs SSM agent, instance role and an S3 bucket for file transfer |
| Windows | winrm or psrp, or ssh on modern Windows |
PSRP is faster; use HTTPS and Kerberos or certificates |
| Network devices | ansible.netcommon.network_cli, netconf, httpapi |
Set ansible_network_os |
| Containers | community.docker.docker, containers.podman.podman |
For testing or one-offs, not production config |
| The controller itself | local |
API calls, cloud modules |
Set the connection per group in group_vars, not on the command line, so the right one is used every time.
More on Architecture Decisions and Tool Comparisons
Ansible or Terraform: where do you draw the line?BeginnerHow does Ansible compare with Puppet, Chef and Salt?IntermediateWhy use Ansible instead of shell scripts?BeginnerWhere does Ansible fit once you run Kubernetes?Intermediatecloud-init or Ansible for first boot configuration?IntermediateWhen would you use AWS Systems Manager instead of, or together with, Ansible?Intermediate