Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • Matthieu Paturot 4:05 pm on January 17, 2020 Permalink | Reply  

    from Bitbucket to TFS #realquick #memo 

    I had to do a move from Bitbucket to TFS

     

    It was done without pain… There were few steps :

    git clone –bare
    git push –mirror
    git rm –cached

    REDACTION IN PROGRESS

     
  • Matthieu Paturot 2:32 pm on January 16, 2020 Permalink | Reply  

    Clone VMs by snap fingers – Terraform and vSphere 

    In the past, I played with Terraform but it was not in a professional context 

    Now, I had to use it for my job with vSphere :)

    Not a big deal ! 

    I wanted to create a bunch of VMs from a template, the configuration is simple, you have to “declare” :

    • a datacenter
    • a resource pool
    • a host
    • a datastore
    • a network
    • a template
    • a FOLDER

    Before to continue, I want to talk about the FOLDER… I had to use this resource for creating my VMs, otherwise it was not possible :/

    resource “vsphere_folder” “folder” {
    path = “XX/XX/testing-infra”
    type = “vm”
    datacenter_id = “${data.vsphere_datacenter.dc.id}”
    }

    In other terms, I don’t know how to add VMs to an existing folder, so each time I have new friend !

    For the rest of the configuration, you have to use “count” with the number of your choice :

    resource “vsphere_virtual_machine” “vm” {
    count  = 3
    name = “${var.servername}-${count.index + 1}
    num_cpus = 2
    memory = 2048
    datastore_id = “${data.vsphere_datastore.datastore.id}”
    host_system_id = “${data.vsphere_host.host.id}”
    resource_pool_id = “${data.vsphere_resource_pool.pool.id}”
    guest_id = “${data.vsphere_virtual_machine.template.guest_id}”
    scsi_type = “${data.vsphere_virtual_machine.template.scsi_type}”
    folder = “${vsphere_folder.folder.path}

    Then you can add the variable ${count.index + 1}” to increment automatically the name of your VMs for example or the hostname, IP address and so on.

    You can have a look in my repo. There are two files :

    • main.tf, the playbook
    • variables.tf, the variables defined in main.tf like this “${var.vsphere_user}” for the user by example.

    Fill Log me in

    Logs are important and you know it :

    export TF_LOG=”TRACE”
    export TF_LOG_PATH=”terraform.txt”

    Plug me in

    I almost forgot to talk about the plugin vSphere for Terraform :p

    You can take it here

    Then after the unzip, put it in this directory :

    .terraform/plugins/linux_amd64

    The folder .terraform should be in a directory with main.tf and variables.tf

    Happy Three Friends

    ./terraform init
    ./terraform plan
    ./terraform apply

    Commands to run the playbook :

    • init, to fetch the provider before deploying for example and in our case it’s about vSphere
    • plan, to validate the plan
    • apply, to apply the plan

    Mea Culpa

    As you can see, I’m not an expert and you can find easily more information about this topic but I hope I will help you to start your journey :) I am only a small INN where you can have a rest and good time !

    On board !

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel