<p>Terraform + Ansible could be the best path forward.</p>
<p>Terraform also has local and remote exec provisioners when provisioning VMs. Local exec runs scripts from the local machine you're deploying from and remote exec spins up an on demand SSH server using a local public key for authentication to run commands on the deployed VM for configuration (eg setup.sh)</p>
<p><a href="https://developer.hashicorp.com/terraform/language/resources/provisioners/remote-exec" rel="nofollow noreferrer">https://developer.hashicorp.com/terraform/language/resources/provisioners/remote-exec</a></p>
<pre><code>resource &quot;aws_instance&quot; &quot;web&quot; {
  # ...

  # Establishes connection to be used by all
  # generic remote provisioners (i.e. file/remote-exec)
  connection {
    type     = &quot;ssh&quot;
    user     = &quot;root&quot;
    password = var.root_password
    host     = self.public_ip
  }

  provisioner &quot;remote-exec&quot; {
    inline = [
      &quot;puppet apply&quot;,
      &quot;consul join ${aws_instance.web.private_ip}&quot;,
    ]
  }
}
</code></pre>

CC BY-SA 4.0
2023-03-12T18:14:54.497Z
2023-03-12T18:15:12.470Z
2023-03-12T18:15:12.470Z
Sebian
<p>Most likely the best path forward is to provision the VMs using Terraform, and the rest with Ansible.</p>
<p>OpenStack can be set up a number of ways, but I believe the only hook in the terraform provider that would allow you to execute code on the node would be via cloud-init user data (bash script).</p>
<p>What I would do is provision nodes with terraform and have it provide outputs, have python generate Ansible hosts and vars from those outputs, and then run Ansible.</p>
<p>What flavor of k8s are you looking at? k0s, k3s, microk8s, etc?</p>

CC BY-SA 4.0
2022-02-13T20:23:48.957Z
2022-02-13T20:23:48.957Z
Nathan Curry
<p><em><a href="https://devops.stackexchange.com/q/15385/18965">I know OpenStack has a supported method of installing a Container Container Orchestration Engine (COE) like Kubernetes using Magnum</a>. I can not use Magnum because I am not an administrator on OpenStack and we do not have the &quot;Service Endpoint&quot; for Magnum installed.</em></p>
<hr />
<p>Terraform has the ability to provision resources on OpenStack: I have this working. Is there any easy way to provision multiple resources and to configure a Kubernetes cluster on top of OpenStack from a non-admin level of permissions? I'm open to using other tools like Ansible to get this job done. I'm just wondering if this is possible as a regular non-admin of OpenStack to easily set up a Kubernetes cluster from the resources I <em>can</em> provision?</p>

CC BY-SA 4.0
2022-01-31T19:00:16.040Z
You can try rancher Kubernetes Engine (rke), that helps us to configure the Openstack provider in the Kubernetes cluster for creating resources like persistent volumes, Loadbalancers etc.
https://rancher.com/docs/rke/latest/en/config-options/cloud-providers/openstack/
Arvind Rawat
CC BY-SA 4.0
2022-02-07T14:56:06.707Z
Can you give more info on what kind of permissions are we talking about? I use the Terraform helm_provider to directly deploy applications, controllers, and basically everything. You can also use kubernetes or kubectl manifest(again terraform resource) to accomplish this, but it's a bit messy for my taste. So I basically have an EKS cluster built with Terraform, and I have deployed all the resources and controllers with the helm_provider and I maintain it fully with that.
Kristian Kanchev
CC BY-SA 4.0
2022-02-07T16:28:43.403Z
@KristianKanchev I want to answer that question, but I don't know how. So I asked a follow up https://devops.stackexchange.com/q/15407/18965
Evan Carroll
<kubernetes><openstack>
How can I deploy a Kubernetes cluster onto OpenStack with Terraform?
Evan Carroll
# How can I deploy a Kubernetes cluster onto OpenStack with Terraform?

(Asked by: username_0 on 2022-01-27)

*[I know OpenStack has a supported method of installing a Container Container Orchestration Engine (COE) like Kubernetes using Magnum](https://devops.stackexchange.com/q/15385/18965). I can not use Magnum because I am not an administrator on OpenStack and we do not have the "Service Endpoint" for Magnum installed.*

---

Terraform has the ability to provision resources on OpenStack: I have this working. Is there any easy way to provision multiple resources and to configure a Kubernetes cluster on top of OpenStack from a non-admin level of permissions? I'm open to using other tools like Ansible to get this job done. I'm just wondering if this is possible as a regular non-admin of OpenStack to easily set up a Kubernetes cluster from the resources I *can* provision?

**Tags:** kubernetes, openstack

> **Comments:**
> **username_1**: You can try rancher Kubernetes Engine (rke), that helps us to configure the Openstack provider in the Kubernetes cluster for creating resources like persistent volumes, Loadbalancers etc. https://rancher.com/docs/rke/latest/en/config-options/cloud-providers/openstack/  
> **username_2**: Can you give more info on what kind of permissions are we talking about? I use the Terraform helm_provider to directly deploy applications, controllers, and basically everything. You can also use kubernetes or kubectl manifest(again terraform resource) to accomplish this, but it's a bit messy for my taste. So I basically have an EKS cluster built with Terraform, and I have deployed all the resources and controllers with the helm_provider and I maintain it fully with that.  
> **username_0**: @KristianKanchev I want to answer that question, but I don't know how. So I asked a follow up https://devops.stackexchange.com/q/15407/18965  

---

## 2 answers

### Answer by username_3 on 2023-03-12. Score: 0

Terraform + Ansible could be the best path forward.
Terraform also has local and remote exec provisioners when provisioning VMs. Local exec runs scripts from the local machine you're deploying from and remote exec spins up an on demand SSH server using a local public key for authentication to run commands on the deployed VM for configuration (eg setup.sh)
https://developer.hashicorp.com/terraform/language/resources/provisioners/remote-exec
resource "aws_instance" "web" {
  # ...

  # Establishes connection to be used by all
  # generic remote provisioners (i.e. file/remote-exec)
  connection {
    type     = "ssh"
    user     = "root"
    password = var.root_password
    host     = self.public_ip
  }

  provisioner "remote-exec" {
    inline = [
      "puppet apply",
      "consul join ${aws_instance.web.private_ip}",
    ]
  }
}


---

### Answer by username_4 on 2022-02-13. Score: 0

Most likely the best path forward is to provision the VMs using Terraform, and the rest with Ansible.

OpenStack can be set up a number of ways, but I believe the only hook in the terraform provider that would allow you to execute code on the node would be via cloud-init user data (bash script).

What I would do is provision nodes with terraform and have it provide outputs, have python generate Ansible hosts and vars from those outputs, and then run Ansible.

What flavor of k8s are you looking at? k0s, k3s, microk8s, etc?


---

