Provision a Host with an Ansible Playbook
MediumDevOps20-30 minConfiguration management means declaring the state you want and letting the tool make it so — idempotently. Write an Ansible playbook that provisions this host to a target state, then run it. The grader checks the resulting system state, not how you got there, but the intended path is a short playbook with three tasks.
Bring the host to this state:
1. A system user named deploy exists.
2. A directory /srv/deploy exists, owned by deploy.
3. A file /etc/deploy.conf exists and contains the line MANAGED_BY=ansible.
Ansible is installed. Because there's only this one box, run the playbook against localhost with a local connection — no SSH needed:
ansible-playbook -i 'localhost,' -c local site.yml
Use the user, file, and copy modules. Re-running your playbook should change nothing the second time — that's idempotence, the whole point of Ansible.
- Write an Ansible playbook (hosts: localhost, connection: local, become: true)
- Create the system user 'deploy' (user module)
- Create /srv/deploy owned by deploy (file module)
- Write /etc/deploy.conf containing MANAGED_BY=ansible (copy module)
- Apply it: ansible-playbook -i 'localhost,' -c local site.yml
Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.
