Lab 11 - Solution """"""""""""""""" Mandatory ========= Create a new host group ----------------------- * Create a new host group for ``flask_app`` in both inventories ``test`` and ``prod`` .. code-block:: yaml # file: test and prod [flask_app:children] web db * Change the ``test`` and ``prod`` host group to use the new hostgroup ``flask_app`` .. code-block:: yaml # file: test [test:children] flask_app .. code-block:: yaml # file: prod [prod:children] flask_app * Create the variable ``flask_app_source`` only for the ``flask_app`` group with the value ``https://github.com/pstauffer/flask-mysql-app.git`` .. code-block:: yaml # file: group_vars/flask_app.yml --- flask_app_source: https://github.com/pstauffer/flask-mysql-app.git Extend your flask_app role -------------------------- * Use the defined ``flask_app_source`` variable in your task file for the git checkout .. code-block:: yaml # file: roles/flask_app/tasks/main.yml --- - name: checkout flask_app git: repo: '{{ flask_app_source }}' dest: /opt/flask_app version: '{{ flask_app_version }}' * Create a dependency on the already created ``python-pip`` role .. code-block:: yaml # file: roles/flask_app/meta/main.yml --- dependencies: - python-pip * Run the playbook ``deploy.yml`` for both inventories ``test`` and ``prod`` ansible-playbook -i test deploy.yml ansible-playbook -i prod deploy.yml * Verify the checkout of the correct version .. code-block:: bash ssh web1..lab cd /opt/flask_app git describe --tags v1.0 ssh web2..lab cd /opt/flask_app git describe --tags v1.1 Commit your changes ------------------- * add all files to your git repo and commit it .. code-block:: bash git status git add roles/* git commit -m 'lab 11'