Ravindra BagaleCourses & study guides

Chapter 11: Ansible Introduction

11.12 Lab — playbook installs Nginx welcome

Lab

Automate a welcome page for badge API with Ansible.

  1. Pick one lab VM you can SSH into (from AWS course labs or local).
  2. Write inventory with that host in group badge-api_web.
  3. ansible -m ping succeeds.
  4. Write playbooks/web_welcome.yml (package + copy index + service).
  5. Run ansible-playbook; curl the web shop counter from your allowed IP.
  6. Run playbook again; note changed=0 (or only expected changes) in the recap.
  7. Optional: convert tasks into roles/web_welcome and call the role.
  8. Commit playbook + inventory example (no real private keys, no production IPs you care about leaking). Use a sanitized hosts.example.ini.

Practice task

Explain idempotence to a teammate in four sentences using the "run Nginx playbook twice" story.