[Charlotte-pm] Is there an Ansible solution to this deployment process?
Yanick Champoux
yanick at babyl.ca
Thu Aug 26 07:58:40 PDT 2021
## Step 4 of ?: Creating the onboard role
In Ansible you have the notion of playbooks and
roles. They both use the same syntax, and the difference
is more organizational than anything else.
A role is a reusable set of actions. So, e.g., you can have
roles to install apache, create a set of users, or -- in this
case -- onboard a new machine.
A playbook is a set of actions you're applying to a group
of hosts. Some of those actions might end up being roles, natch.
Roles typically have a structured set of subdirectories. I won't
list them all here, just mention the ones that will be relevant for this
specific discussion:
tasks/ # the actions of that role. The main file is main.yml
files/ # any asset you need for that role. Template files,
# scripts to copy, etc
vars/ # variables we might want to use for that role. Main file is
# also main.yml
defaults/ # ditto, but with lower priority than `vars`. Don't think
# too much about it now.
handlers/ # when some actions trigger changes, you can auto-restart
# services and whatnots. This is where those "react on change"
# events are dealt with.
In this use-case, your onboard role does 3 things: setup a service, configure
nginx, and setup SSL. So let's mirror that in `tasks/main.yml`:
```
# in ./roles/onboard/tasks/main.yml
- name: install service
include_tasks: ./install_service.yml
- name: setup nginx
include_tasks: ./setup_nginx.yml
- name: setup ssl
include_tasks: ./setup_ssl.yml
```
More to come,
`/anick`
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/charlotte-pm/attachments/20210826/21b57d29/attachment.html>
More information about the Charlotte-pm
mailing list