Lab 12 - Solution

Important

This is just an example of a solution.

  • You can also split the project into more roles and work with dependencies

    • mysql role (reusable for other projects)
    • gunicorn role (reusable for other projects)
    • flask role (reusable for other projects)
    • git role (reusable for other projects)
  • Use fixed variables inside the roles in vars/main.yml

  • Manage the whole my.cnf as template and add the ansible_managed header

  • Verify, if the database already exists (to replace the ignore_errors)

  • Use fixed versions for the packages (gunicorn, mysql-server, ...) to make sure, the application works with this versions

  • put the RedHat / Debian part into own files redhat.yml / ``debian.yml

  • Verify, if the application (gunicorn) is already running (to make the task idempotent)

  • use tags

Commit your changes

  • add all files to your git repo and commit it
git status
git add *
git commit -m 'lab 12'