<!DOCTYPE html><html><head><title></title><style type="text/css">
p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>## Step 4 of ?: Creating the onboard role<br></div><div><br></div><div>In Ansible you have the notion of playbooks and<br></div><div>roles. They both use the same syntax, and the difference<br></div><div>is more organizational than anything else.<br></div><div><br></div><div>A role is a reusable set of actions. So, e.g., you can have<br></div><div>roles to install apache, create a set of users, or -- in this<br></div><div>case -- onboard a new machine.<br></div><div><br></div><div>A playbook is a set of actions you're applying to a group<br></div><div>of hosts. Some of those actions might end up being roles, natch.<br></div><div><br></div><div>Roles typically have a structured set of subdirectories. I won't<br></div><div>list them all here, just mention the ones that will be relevant for this<br></div><div>specific discussion:<br></div><div><br></div><div>    tasks/    # the actions of that role. The main file is main.yml<br></div><div>    files/    # any asset you need for that role. Template files,<br></div><div>              # scripts to copy, etc<br></div><div>    vars/     # variables we might want to use for that role. Main file is<br></div><div>              # also main.yml<br></div><div>    defaults/ # ditto, but with lower priority than `vars`. Don't think<br></div><div>              # too much about it now.<br></div><div>    handlers/ # when some actions trigger changes, you can auto-restart<br></div><div>              # services and whatnots. This is where those "react on change"<br></div><div>              # events are dealt with.<br></div><div><br></div><div><br></div><div>In this use-case, your onboard role does 3 things: setup a service, configure<br></div><div>nginx, and setup SSL. So let's mirror that in `tasks/main.yml`:<br></div><div><br></div><div>```<br></div><div># in ./roles/onboard/tasks/main.yml<br></div><div><br></div><div>- name: install service<br></div><div>  include_tasks: ./install_service.yml<br></div><div><br></div><div>- name: setup nginx<br></div><div>  include_tasks: ./setup_nginx.yml<br></div><div><br></div><div>- name: setup ssl<br></div><div>  include_tasks: ./setup_ssl.yml<br></div><div>```<br></div><div><br></div><div><br></div><div>More to come,<br></div><div>`/anick`<br></div><div><br></div></body></html>