Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

Ansible for Automation!

2:45:48

What you'll be learning

This tutorial is built using an older version of Symfony, but the core concepts of Ansible are still valid. New versions of Ansible may contain some features that we don't use here.
// composer.json
{
    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.1.*", // v3.1.4
        "doctrine/orm": "^2.5", // v2.7.2
        "doctrine/doctrine-bundle": "^1.6", // 1.6.4
        "doctrine/doctrine-cache-bundle": "^1.2", // 1.3.0
        "symfony/swiftmailer-bundle": "^2.3", // v2.3.11
        "symfony/monolog-bundle": "^2.8", // 2.11.1
        "symfony/polyfill-apcu": "^1.0", // v1.2.0
        "sensio/distribution-bundle": "^5.0", // v5.0.12
        "sensio/framework-extra-bundle": "^3.0.2", // v3.0.16
        "incenteev/composer-parameter-handler": "^2.0", // v2.1.2
        "doctrine/doctrine-migrations-bundle": "^1.2", // v1.2.0
        "snc/redis-bundle": "^2.0", // 2.0.0
        "predis/predis": "^1.1", // v1.1.1
        "composer/package-versions-deprecated": "^1.11" // 1.11.99
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0", // v3.0.8
        "symfony/phpunit-bridge": "^3.0", // v3.1.4
        "doctrine/data-fixtures": "^1.1", // 1.3.3
        "hautelook/alice-bundle": "^1.3" // v1.4.1
    }
}

In this screencast, we automate provision of Linux server with a wonderful automation tool named Ansible and explore the most fundamental parts of this process:

  • Configuring an entire Vagrant host for a web (Symfony) app
  • Provision hosts with Ansible
  • Inventory files
  • All about Ansible modules
  • Playbooks, plays, tasks
  • Variables and facts
  • Handlers
  • Conditionals and tags
  • Jinja2 templates (functions, filters, loops, variables, etc.)
  • Roles
  • Prompt input
  • Debugging
  • Deploying to EC2
  • Ansible Vault, for secret stuff

Are you ready to start adding some automation to your daily workflow?


Your Guides

Victor Bocharsky Ryan Weaver

Buy Access

Join the Conversation?

8
Login or Register to join the conversation

WOW I'm looking forward for this!

3 Reply
Default user avatar
Default user avatar sokphea chea | posted 5 years ago

can't wait for more.

Reply
Default user avatar
Default user avatar Micheal | posted 5 years ago

I'm really looking forward to seeing this completed. Since Ansible requires, for now at least, Python 2.7 still ( :/ ), could you add in something about virtualenv? Ubuntu and other distros are starting to move to Python 3 now and that might cause problems for people.

Reply

Hey Micheal!

Ah, great question / comment about Python 2 and 3. I'm going to check into this - there is already a little bit of this that I was dealing with earlier today :).

Cheers!

Reply
Default user avatar
Default user avatar sokphea chea | posted 5 years ago

Hello, is there any way we can link our local project folder to the host and get change instantly when we edit it? Following the the tutorial we only git clone our project in the host not link it from our local. Thank you.

Reply

Hey Sokphea,

Yes, there is! Actually, with Ansible you can do whatever you want - it's very powerful. If we're talking about virtualization - you can do it on your virtualization tool's level, i.e. share your local folder with VirtualBox and when you will make a change locally - it will instantly apply inside VirtualBox, and the reverse, if inside VirtualBox you warm up cache - you'll see those cache files locally. See Vagrant Synced folders: https://www.vagrantup.com/d... , for example, look at https://www.vagrantup.com/d... or probably better NFS: https://www.vagrantup.com/d... - it should work faster. But anyway, sharing files in real time will be much slower, so be ready that your website could load slower up to 10x times, depends on synced folder strategy.

Cheers!

Reply
Default user avatar
Default user avatar Patrick van Beck | posted 5 years ago | edited

hey there and Victor
I've watched the tutorial and it is great! Thanks a lot! I have a question left, after having seen the videos on Ansible. Currently, I have the following setup within a project:
Dev -> Test -> Prod

In Dev environment, we develop the code, run some tests and push it afterwards to the vcs (git). Then, the CI-process starts and integrates the changes on the test environment (another virtual maschine, using Jenkins and Apache Ant) and runs the tests again (and some more). When the code and tests are allright, we deploy it to a prod environment by calling some bash script from within the apache ant build xml.

What would be the workflow now using Ansible and Ansistrano? Would I still use Apache Ant for the Continuous Integration task on Test Environment, and when CI Process shows "green", I'd call the Ansible/Ansistrano playbook instead of the bash script? Or will Ansible completely replace Apache Ant (CI-Process), so I'd use Ansible (+ Ansistrano) for the Integration AND deployment process?

Best Regards,
Patrick.

Reply

Hey Patrick,

Good question! Actually, we're planning to show this workflow in Ansistrano tutorial: when the tests are green on CI - automatically deploy the code to production with Ansistrano. So I *think* yes, you could replace Apache Ant part which take care of deployment with Ansible playbook with installed Ansistrano role. So the new possible workflow for you is: ... push code to CI, CI tests the application and if tests are passed - run Ansible playbook with installed Ansistrano role to deploy this code to production.

Cheers!

Reply
Cat in space

"Houston: no signs of life"
Start the conversation!

userVoice