RH294 Ch 9: Create and Install Roles

WebAsha wants its message-of-the-day logic in a reusable role, and its security team publishes a `baseline` role as a tarball at `http://utility/roles/baseline.tar.gz`. node1 is in `dev`, node2 in `prod`.

Tasks

  1. Create the role skeleton ~/ansible/roles/motd with ansible-galaxy role init, and give it a default variable systemowner with value [email protected].
  2. The role deploys /etc/motd from roles/motd/templates/motd.j2: line 1 This is <hostname, line 2 Owner: <systemowner. Apply the role to all hosts with a playbook ~/ansible/roles.yml.
  3. Give the role a handler (in handlers/main.yml) that the template task notifies, e.g. one that logs motd updated with logger.
  4. Write ~/ansible/roles/requirements.yml that installs the role from http://utility/roles/baseline.tar.gz under the name baseline, and install it into ~/ansible/roles.
  5. In roles.yml, apply baseline to the prod hosts only, setting its variable baselinebanner to Authorized use only. Run the playbook.