Deploying a web app with revision control systems

For this example, we are going to deploy a simple PHP application that will be composed of only a single PHP page. The source is available on the following repository: https://github.com/Fale/demo-php-app.

To deploy it, we will need the following code placed in playbooks/manual/rcs_deploy.yaml:

- hosts: web 
  user: ansible 
  tasks: 
  - name: Install or update website 
    git: 
      repo: https://github.com/Fale/demo-php-app.git 
      dest: /var/www/application 
    become: True 

We can now run the deployer with the following command:

ansible-playbook -i inventory/production playbooks/manual/rcs_deploy.yaml

This is the expected result:

PLAY [web] *******************************************************


TASK [setup] ***************************************************** ...

Get Learning Ansible 2 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.