How to use Ansible only to Deploy

Greetings.
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:

wordpress_sites:
  example.com:
    local_path: '../site' # path targeting local Bedrock site directory (relative to Ansible root)
    repo: git@github.com:roots/bedrock.git
    branch: master
    # env section only needed if you need to generate a `.env` file
    env:
      wp_home: http://staging.example.com
      wp_siteurl: http://staging.example.com/wp
      wp_env: staging
      db_name: example_staging
      db_user: example_dbuser
      db_password: example_dbpassword
      # Generate your keys here: https://api.wordpress.org/secret-key/1.1/salt/
      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.

2 Likes

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

Thank you!!!

2 Likes

I’d love to try this too

@apintocr Did you get it to work?

1 Like