Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2023-03-12T18:14:54.497Z
Answers: 2023-03-12T18:15:12.470Z
Answers: 2023-03-12T18:15:12.470Z
Answers: Sebian
Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2022-02-13T20:23:48.957Z
Answers: 2022-02-13T20:23:48.957Z
Answers: Nathan Curry
Body: <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>
  
Comments: CC BY-SA 4.0
Comments: 2022-01-31T19:00:16.040Z
Comments: 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/
Comments: Arvind Rawat
Comments: CC BY-SA 4.0
Comments: 2022-02-07T14:56:06.707Z
Comments: 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.
Comments: Kristian Kanchev
Comments: CC BY-SA 4.0
Comments: 2022-02-07T16:28:43.403Z
Comments: @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
Comments: Evan Carroll
Tags: <kubernetes><openstack>
Title: How can I deploy a Kubernetes cluster onto OpenStack with Terraform?
UserDisplayName: Evan Carroll
ThreadText: # 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**: @username_2 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?
  
  
  ---
  
  