Inventory and access
Group Linux servers, define SSH connection details, and verify Ansible can reach the intended hosts.
Inventory tells Ansible which hosts exist and how they are grouped. Keep environment, region, and role visible so an operator can target the intended machines without memorizing hostnames.
Create a YAML inventory
Aliases such as web-01 remain stable if an IP changes. Groups let one playbook target servers by purpose. For a larger fleet, use group_vars/ and host_vars/ rather than filling the inventory with settings.
Keep shared values separate
Do not store passwords, private keys, cloud credentials, or unencrypted tokens in inventory or variable files. Use SSH keys for access and Ansible Vault or the team’s secret manager for values a playbook needs.
Validate what Ansible sees
Read the host list before running a change. A correct playbook against the wrong group is still an outage.
Verify SSH and Python
First test SSH directly:
Then use Ansible’s ping module. It checks that Ansible can authenticate and run Python on the managed host; it is not an ICMP network ping.
The gathered facts include ansible_distribution and ansible_os_family. Playbooks can use these values when package names or configuration paths differ.
Prepare Python when it is missing
Minimal cloud images may not include Python. The raw module does not require Python and can bootstrap it.
Run this only for a tightly scoped new_servers group. After Python is present, use normal Ansible modules.
Access is ready when
Direct SSH works, ansible-inventory --graph shows the intended groups, ansible all -m ping succeeds, and privilege escalation has been tested on a non-production host.