O'Reilly logo

Learning Ansible 2 - Second Edition by Fabio Alessandro Locati

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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] ***************************************************** ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required