Skip to content

Latest commit

 

History

History
74 lines (47 loc) · 1.96 KB

File metadata and controls

74 lines (47 loc) · 1.96 KB

Test Webserver Provisioning

imgix-klWUhr-wPJ8-unsplash

This repo is used to provision a new test server on DigitalOcean. It uses Terraform for provisioning and Ansible for configuration.

Terraform | Config

Before Terraform can be applied, some configuration must be handled. The terraform.tfvars.template file should be renamed terraform.tfvars. It will then be protected by version control. It should contain the following content:

ssh_key_fingerprint = "ssh-key-fingerprint"
do_token            = "do-token"

You should replace the two values with your own from DigitalOcean.

Terraform | Provisioning

The Terraform plan can be checked by running:

terraform plan

To apply the plan and provision the server, run:

terraform apply

Terraform | Tearing Down the Server

The test server can easily be torn down with:

terraform destroy

Ansible | Configuring the Inventory

Before the play can be run, the inventory file need to be configured.

Change the name of the inventory.template file to inventory. This will protect it from version control, and it should have the following content:

[webservers]
rcjourney.test.webserver ansible_host=<host_ipv4> ansible_connection=ssh ansible_user=root

Replace <host_ip4> with the public IPv4 address returned by the Terraform output from above.

To check the inventory, run:

ansible-inventory -i inventory --list

Ansible | Configuring the External Variables

Next, change the name of the external_vars.yml.template file to external_vars.yml. This will protect it from version control, and it should have the following content:

---
app_root: /var/www/rcjourney.test.webserver/html

Ansible | Running the Play

To run the Ansible play, run:

ansible-playbook -i inventory playbook.yml