O'Reilly logo

DevOps Automation Cookbook by Michael Duffy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. First, create a new playbook using our scaffold script, which we created in the preceding recipe:
    $ playbookscaffold.sh -p . -t "first_playbook"
    
  2. 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required