Skip to content

A project for the purposes of learning Terraform and Ansible with deploying a Wordpress website on DigitalOcean

Notifications You must be signed in to change notification settings

jzarzycki/WordpressTerraformAnsible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Purpose

A project for the purposes of learning Terraform and Ansible with deploying a Wordpress website on DigitalOcean.
Long ago I've created a CV/Blog website using Wordpress as a project in order to better understand the Linux OS in the process.
Now that I've learned Terraform and Ansible It only made sense to revisit this old project of mine and adapt it to use the Infrastructure as Code approach.

Usage

Create the infrastructure

Before trying to create the resources specify the required variables inside terraform/terraform.tfvars (example file provided at terraform/terraform.tfvars.example) and login to terraform cloud (remember to update values in terraform/providers.tf).
When you completed setting up you can finally run:

cd terraform
terraform init
terraform plan -no-color -out plan.txt
terraform apply plan.txt

Provision the infrastrucutre

The playbook ansible/main.yml needs to be executed in order to provision the infrastructure created by terraform.
Terraform creates the ansible inventory file ansible/inventory as part of its configuration. In order to be able to execute this playbook you need to provide values for the ansible/roles/webserver/files/.env file, example configuration can be found inside .env.example.

cd ../ansible
ansible-playbook -i inventory main.yml

The login user for ssh can be specified as such:

ansible-playbook -i inventory main.yml --extra-vars "login_user=username"

Project structure

WordpressTerraformAnsible # The project repository
├── ansible # This is where all of the Ansible code resides
│‎ ‎ ‎ └── roles
│‎ ‎ ‎ ‎ ‎ ‎ ‎ ├── common # Configuration common for all servers, like ssh config, basic securing of the server, etc
│‎ ‎ ‎ ‎ ‎ ‎ ‎ ├── docker # Configuration regarding installing and configuring docker
│‎ ‎ ‎ ‎ ‎ ‎ ‎ └── webserver # Configuration needed to provision the wordpress site on a prepared docker host
└── terraform # This is where all of the Terraform code resides
‎ ‎ ‎ ‎ └── modules
‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ └── infrastructure # Module containing implementation of infrastructure for my website.
‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ └── networking # Module containing networking related configuration for my website.

About

A project for the purposes of learning Terraform and Ansible with deploying a Wordpress website on DigitalOcean

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published