Git Product home page Git Product logo

hc-meetup-terraform-ansible's Introduction

HashiCorp Meetup 2021-04-15

This Meetup talk covers the configuration of terraform for proxmox and the usage of ansible to configure vms and containers created with terraform on an proxmox system.

Prepare your system setup

Install Proxmox VE

Version: 6.3-6

Installation of proxmox is described in the proxmox online documentation and not covered in this repository and talk. Visit first steps üpage of the proxmox website to download the system and get a walkthrough of the installation.

Install container template

To launch a lxc container we need to setup a image template. Go to local storage > CT Templates and click templates to install one or more container templates.

Setup VM template via Ansible

The project ships a playbook playbook-setup-proxmox.yml to setup the proxmox system with a ubuntu 20.04 cloud init template.

cd ansible
ansible-playbook playbook-setup-proxmox.yml

Setup Terraform

Version: 0.14.9

Terraform can be installed from the HashiCorp download page.

Next take a look at the README to setup the proxmox provider.tf file in the terraform folder.

Setup Ansible

Version: 2.9.19

Ansible has an installation guide in its great documentation.

Setup with Vagrant

Version: 2.2.14

To avoid installing terraform, ansible and other needed dependecies manually, we prefere a vagrant box that setups the needed software for the current project. Why do with preferre it? Imagin you have different customers running different versions of terraform or ansible to provision and configure their systems, to avoid switching between version, every customer can get a own vagrant box with the need versions to automate their systems.

To use HashiCorp Vagrant you need a virtualization provider. For this sample you need to use virtual box.

Provisioning and Configuration

If you want to use the vagrant box please connect via ssh.

vagrant ssh

Check VM template

Check if you run the VM template playbook, if not do it now.

cd ansible
ansible-playbook playbook-setup-proxmox.yml

Provision VMs with Terraform

Change to the terraform folder.

cd ~/terraform

Create a file called local.tfvars and add your root@pam password for proxmox

touch local.tfvars

add

pm_password = "your-password"

Init Terroform and run the plan command with your local vars file.

terraform init

terraform plan -var-file=local.tfvars

Provision the VMs with

terraform apply -var-file=local.tfvars

Configure VMs with Ansible

Change to the ansible folder.

cd ~/ansible

First check if ansible is able to connect your vms

ansible-playbook playbook-connection-test.yml

After the check is done and all lights are green we can now configure our k8s cluster.

ansible-playbook playbook-setup-lab.yml

When the configuration is finished we can connect to the master vm and check the nodes or copy the kube config to start interacting with the k8s cluster.

Clean up

To remove all infrastructe let terrafrom destroy everything.

cd ~/terraform
terraform destroy -var-file=local.tfvars

Useful Links

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.