Chapter 11: Ansible Introduction
11.5b ansible.cfg for friendlier labs
# ansible.cfg (optional)
[defaults]
inventory = inventory/hosts.ini
host_key_checking = True
retry_files_enabled = False
stdout_callback = yaml
Keep host key checking on for real hosts. If you rebuild lab VMs often and keys change, remove the old key from ~/.ssh/known_hosts deliberately — do not disable checking casually on shared networks.
Gathering facts. Ansible collects facts (OS family, IPs) at play start. You can condition tasks with ansible_os_family later so one playbook supports Amazon Linux and Ubuntu — advanced but good to know.
- name: Install Nginx (Amazon family sketch)
ansible.builtin.yum:
name: nginx
state: present
when: ansible_os_family == "RedHat"
- name: Install Nginx (Debian family sketch)
ansible.builtin.apt:
name: nginx
state: present
update_cache: true
when: ansible_os_family == "Debian"
Use one OS for your first lab; add when: only after ping + single-OS playbook works.
Practice task
Write two when: lines (RedHat vs Debian) in your notes and name which module each branch would call for Nginx.