Linux Labs

Automation: Git and Ansible / Stage 4 of 6

Inventory and ad-hoc commands

Not running Starting usually ~20 s
Leave the lesson

Step 5 of 5 · summary · 3 min

Summary

  • The inventory is a list of machines: the name in Ansible, the address ansible_host, the user ansible_user and groups; ansible.cfg in the directory says where the inventory is.
  • UNREACHABLE! means SSH did not connect and the module never ran: look for the cause in the name, the address, the user and the key.
  • The ad-hoc command ansible <machines> -m <module> -a '…' does one job on every machine: CHANGED — it changed something, SUCCESS — there was nothing to change, and command always answers CHANGED.
  • -b runs the module as root through sudo, ansible_connection=local runs it on this machine without SSH.
  • app1 at the start of the lesson was out of reach because of its inventory line: the machine did not know the address app1.lab.test, and deploy had no key.
Ubuntu 24.04
Loading…