How to use Ansible only to Deploy

From what I’ve understood, Ansible replaces Capistrano if you want to use it to setup your development and production servers.

I have my own VPS that has cPanel to manage multiple user accounts (technically making my VPS a shared hosting environment with SSH access).

I would love to use Ansible to only to deploy to one of the cpanel accounts, not to setup the whole server; after the first reply I will want to keep it updated using Ansible.

Is this viable? If so where to start?
Should I really use Capistrano? (I’ve tried but I do not like it, Ansible seems much more friendly).

Thank you :slight_smile:

It should be possible. I do intend to split out the deploy role to make this easier. There’s a placeholder issue for it.

Are your sites Bedrock-based or not? It would definitely take more work for non-Bedrock sites.

Basic steps would be:

  1. Follow normal installation
  2. Add your server to a hosts file
  3. Configure the matching group_vars file to define a site under wordpress_sites (these settings should match up with your existing WP install)
  4. Just run the deploy command/playbook

You could get away with only defining the minimum set of variables for a WP site. Something like this:

    local_path: '../site' # path targeting local Bedrock site directory (relative to Ansible root)
    branch: master
    # env section only needed if you need to generate a `.env` file
      wp_env: staging
      db_name: example_staging
      db_user: example_dbuser
      db_password: example_dbpassword
      # Generate your keys here:
      auth_key: "generateme"
      auth_salt: "generateme"
      logged_in_key: "generateme"
      logged_in_salt: "generateme"
      nonce_key: "generateme"
      nonce_salt: "generateme"
      secure_auth_key: "generateme"
      secure_auth_salt: "generateme"

If your site isn’t Bedrock based, it would take more work to override some defaults in the deploy role.

You’d also have to manually figure out adding SSH keys but that’s the same as Capistrano.


Thank you @swalkinshaw, this is exactly what I was looking for… and a lot more simple than what I was messing with.

Thank you!!!


I’d love to try this too

@apintocr Did you get it to work?

1 Like