Ansible – writing the code and deploying our infrastructure
In Chapter 4, Deploying to Microsoft Azure, we briefly covered the Ansible code to deploy our Azure environment. Let’s take a step back and cover some of the basics we skipped.
While we can have one big YAML file containing our playbook code, I tend to split mine into more manageable chunks using roles. Roles can be used for a few things. In some cases, they can be stand-alone distributable tasks that can be reused across multiple projects; or, in our case, they can be used to manage more complex playbooks.
A copy of the site.yml
file that will be used to deploy our WordPress environment in AWS looks like the following:
- name: Deploy and configure the AWS Environment hosts: localhost connection: local gather_facts: true vars_files: - group_vars/aws.yml - group_vars/common.yml roles: ...