Creating a common role
Now that we have a way to create our scaffold Playbook we can go ahead and create our first role; this role will create users, add SSH keys, and install software. I tend to find it invaluable on any server I am managing.
Getting ready
For this recipe, you need an Ubuntu 14.04 server to act as an Ansible client, and an Ubuntu 14.04 server that you wish to configure.
How to do it…
Let's create a common role:
- First, create a new
playbook
using our scaffold script, which we created in the preceding recipe:$ playbookscaffold.sh -p . -t "first_playbook"
- Edit
first_playbook/roles/common/tasks/main.yml
and insert the following code snippet:# tasks file for common - include: create_users.yml
The
include
statement tells Ansible to parse ...
Get Learning DevOps: Continuously Deliver Better Software now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.