Ansible connects over SSH and applies tasks described in YAML. No agent is needed on the servers.
inventory.ini:
[web]
10.0.1.11
10.0.1.12
[web:vars]
ansible_user=ubuntu
site.yml:
- hosts: web
become: true
tasks:
- name: Install nginx
ansible.builtin.apt:
name: nginx
state: present
update_cache: true
- name: Start and enable nginx
ansible.builtin.service:
name: nginx
state: started
enabled: true
python3 -m pip install ansible-core==2.13.*
ansible web -i inventory.ini -m ping
ansible-playbook -i inventory.ini site.yml --check --diff
ansible-playbook -i inventory.ini site.yml
Tasks are idempotent: running again changes nothing if the server is already correct. Use --check first, keep secrets in Ansible Vault, and use fully qualified module names as shown, which newer releases expect.