Configuring several servers with Ansible
Sign in to read this lesson
The first playbook installed a few packages. Now the real job — building a full web server — with variables, templates, handlers and vault. In the end, one playbook prepares srv-web01 as a web server and srv-db01 as a database server, and gives the same result however many times you run it.
What you will learn
- Variables (
vars,group_vars/web.yml) adapt the same playbook to different servers. - The template module fills in a Jinja2 file (
{{ variable }}) for each server and puts it in place. - A handler only runs when a setting changes:
notify: restart httpd— no needless restarts. when:gives a condition,loop:a repetition; several plays in one playbook do different work for different groups.- Passwords are encrypted with ansible-vault:
ansible-vault create,--ask-vault-pass; only the encrypted file goes into Git.
The lesson has 5 key points, an explanation and 5 questions. It opens with a package.