Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 1.4 KB

30-add-apache.md

File metadata and controls

45 lines (35 loc) · 1.4 KB

Add the Apache server deployment logic in the terraform module

Objective

This step adds the automation to deploy an Apache Server on the three workload virtual servers.

In order to implement this automation, we leverage the native terraform remote-exec provisioner. In short, the remote-exec provisioner connects to a remote resource and invokes a script on that machine.

In this step, we configure the remote-exec provisioner to run a script that installs Apache server on a worker VSI. The remote-exec provisioner is configured to access the worker nodes through our management jump box that is publicly exposed. The same private ssh key is used in this example to connect to the jump box and to the worker vsis.

Steps

resource "null_resource" "application-install" {
  count = var.number_vsi_workload
  connection {
    type         = "ssh"
    user         = "root"
    bastion_host = var.floating_ip_address
    host         = local.workload_ip_list[count.index]
    private_key  = var.ssh_private_key
    agent        = false
    timeout      = "15m"
  }

  provisioner "remote-exec" {
    inline = [
      "apt-get install apache2 -y"
    ]
  }
}

The full logic is located here.

[ TODO - steps]