Creating your First WordPress Site with Ansible

A low-cost High-Availability Cloud Server is one of the best ways to host websites and other web apps. However, deploying the software can be time-consuming depending on your experience level. Luckily, with our included Ansible Control Node and WordPress UltraStack Ansible Playbook, you can deploy a WordPress site with all necessary dependencies easily. In this guide, we’ll show you how to run an Ansible playbook to get a WordPress site up and running in just minutes.

In this article: 

Add SSH Keys to your Server

  1. If this is your first time accessing AMP after purchasing a Cloud Server, clicking on “Access My Server” will also take you directly to the Manage SSH Keys section.
  2. Open Terminal or Powershell.
  3. Type the following then hit Enter.
    ssh-keygen -t rsa -b 4096
  4. Press Enter again when you see a prompt to “Enter file in which to save the key“.
  5. When prompted, type a secure passphrase, then press Enter.
  6. When prompted type the secure passphrase again to confirm, then press Enter. This will generate a public and private key.
  7. Open the public key (/home/username/.ssh/id_rsa.pub) and copy the entire text.
  8. On the Manage SSH Keys page, click the blue ADD KEY button.
  9. In the Label field, put a name to help you identify what the key is for.
  10. In the Public Key field paste the public key you generated and copied in the first section. By default it will usually be called “id_rsa.pub” and the first line should start with “ssh-rsa“.
  11. Choose your server from the “Install To” drop-down menu.
  12. Click the ADD KEY button.

Test your SSH Connection

You can test if your key was added successfully by connecting to your server via SSH.

  1. Go to the main AMP page by clicking My Account
  2. Click the Account Technical Details button.
  3. Use your IP address or Hostname to SSH into your server as the “root” user. For example:
    ssh [email protected]
    ssh [email protected]
  4. Log out of your server with the exit command.
    exit

Add SSH Key and Start Ansible Control Node

  1. On the main AMP page, click the Ansible Control Node button.
  2. On the first visit to the Ansible Control Node page, you’ll be prompted to select an existing public key or add a new key. Choose your existing key then click the Add Key button.
  3. Now scroll down and click the Start Ansible Button.
  4. Save the provided username, port, and IP address

SSH into the Ansible Control Node

  1. Open Terminal or Powershell and SSH into your Ansible Control Node using the username, port, and IP address you just saved. e.g. ssh username@IPaddress -p port-number.
    ssh [email protected] -p 1234
  2. Create an SSH key on the Ansible Control Node by running the following command.
    ssh-keygen -t rsa -b 4096
    Press Enter again when you see a prompt to “Enter file in which to save the key“.
  3. When prompted, type a secure passphrase, then press Enter.
  4. When prompted type the secure passphrase again to confirm, then press Enter. This will generate a public and private key.
  5. Open the public key (/home/username/.ssh/id_rsa.pub) and copy the entire text.

Add Your Ansible Control Node Public Key to your Target Cloud Server

  1. In AMP, click the Manage SSH Keys button.
  2. Click the blue ADD KEY button.
  3. In the Label field put a name to help you identify what the key is for.
  4. Paste your key into the Public Key field. The first line should start with “ssh-rsa“.
  5. Choose your server from the “Install To” drop-down menu.
  6. Click the blue ADD KEY button at the bottom of the popup once you have finished filling in the fields. Once the installation is complete, you will see a message stating “Public key successfully installed“.

Customize and Run Ansible Playbook

  1. If you are not still connected, SSH into your Ansible Control Node using the username, port, and IP address.
    ssh [email protected] -p 1234
  2. You should be in the /home/ansible directory. Navigate to the playbook with the following command.
    cd wordpress-ultrastack-ansible
  3. Copy the sample inventory.yml file to a new file with this command.
    cp inventory.sample.yml inventory.yml
  4. Edit inventory.yml in your preferred text editor. For example:
    nano inventory.yml
  5. In the new inventory.yml file, you will need to edit the placeholder values under hosts for site_domain, site_email, site_user, and site_pass. At a minimum, you will need to change the references to domain.tld
    For example, instead of domain.tld you can use the IP address or hostname of your server listed under Account Technical Details in AMP.
  6. Run the playbook in your Ansible control Node with the following command.
    ansible-playbook -i inventory.yml site.deploy.yml
  7. You will be prompted for your secure passphrase. Type it then click the Enter key.
  8. The playbook will then run and create your site. This will take several minutes to complete.

After your playbook runs successfully, visit the address you chose as the replacement for “domain.tld” to see your new WordPress website!

JB
John-Paul Briones Content Writer II

John-Paul is an Electronics Engineer that spent most of his career in IT. He has been a Technical Writer for InMotion since 2013.

More Articles by John-Paul

Was this article helpful? Join the conversation!

Shop the Black Friday Sale
Hurry! These Deals Won't Last Long

X