Creating a CodeDeploy Ansible role

We are first going to go into the role directory that is present at the root location of our ansible repository:

$ cd roles  

As before, we will rely on ansible-galaxy to put in place the scaffolding that is needed to create our role:

$ ansible-galaxy init codedeploy  

Our role will be very simple. We are going to edit the codedeploy/tasks/main.yml file and make a call to the new module that the aws_codedeploy library provides, as follows:

---
# tasks file for codedeploy
- name: Installs and starts the AWS CodeDeploy Agent
  aws_codedeploy: 
    enabled: yes  

At this point, we can create our new playbook for generic nodejs web servers. First, go back in the root directory of the ansible repository:

$ cd ..  

Get Effective DevOps with AWS - Second Edition 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.