How to build VM using Kickstart and Ansible Playbook ?

5,476 views
Skip to first unread message

Patel Parimal

unread,
Jan 5, 2015, 8:54:06 AM1/5/15
to pysp...@googlegroups.com
Hi,
I am newbie to Ansible. I have referred the documentation for creating new VM on Ansible Docs - vsphere_guest.

Is there any way to provide kickstart file in Ansible Playbook (say for ex. static HTTP URL like http://192.168.0.1/ks/ks.cfg) to VM for installing OS without any human intervention ?

Thanks,
Parimal
Message has been deleted

Noam Greenberg

unread,
Mar 28, 2015, 10:14:36 AM3/28/15
to pysp...@googlegroups.com
Hi 

Ansible can create VM for you but you will need to make your own PXE server 

you need to understand Ansible as PUPPET or chef must have OS install ( linux ) ansible use ssh for config the linux box so ... 

see what i answer you about pxe server 

for the ansible 
- name: Test
  hosts: servers
  connection: local
  
  tasks:
    - name: New Vmware guest vm
      vsphere_guest:
        vcenter_hostname: vsenter.domain.com
        username: na...@domain.com
        password: mypass
        guest: "{{inventory_hostname_short}}"
        state: powered_on
        vm_extra_config:
          vcpu.hotadd: yes
          mem.hotadd: yes
          notes: "{{inventory_hostname_short}}"
        vm_disk:
          disk1:
            size_gb: 10
            type: thin
            datastore: mydatastore
        vm_nic:
          nic1:
            type: vmxnet3
            network: Server
            network_type: standard
        vm_hardware:
          memory_mb: 2048
          num_cpus: 2
          osid: centos64Guest
          scsi: paravirtual
        vm_hw_version: vmx-09
        esxi:
          datacenter: mydatacenter
          hostname: ESX-IP ADDRESS

Noam

Stuart Cracraft

unread,
Feb 5, 2016, 7:05:57 PM2/5/16
to pysphere

Hi,

I use Ansible playbook yml to attempt to deploy a vm in vmware/vsphere with pysphere yet it just gives this message when DHCP doesn't respond on the vSphere console and there's no human to hit an F12 there -- that's the point to avoid -- to force it over to the kickstart server. My question is how to force it over to the kickstart server and/or get beyond the F12. I would be comfortable with an Ansible-only solution or secondarily a setting on vSphere to force all Linux reboots to go to kickstart and bypass dhcp.

Network boot from VMware VMXNET3
Copyright (C) 2003-2008 VMware, Inc.
Copyright (C) 1997-2000 Intel Corporation

CLIENT MAC ADDR: 00 50 56 8A F9 16 GUID: 420A20B9-EEFD-9BF8-29AD-7EE989411540
PXE-E51: No DHCP or proxyDHCP offers were received.

PXE-M0F: Exiting Intel PXE ROM.
Operating System not found


Ansible playbook:

- hosts: 127.0.0.1
  connection: local
  user: root
  sudo: false
  gather_facts: false
  serial: 1

  tasks:
  - vsphere_guest:
      vcenter_hostname: sna-vcsa.ourdomain.com
      username: ansible
      password: ouransiblepassword
      guest: SOMENEWHOSTNAME

      state: powered_on
      vm_extra_config:
        vcpu.hotadd: yes
        mem.hotadd: yes
      vm_disk:
        disk1:
         size_gb: 1
         type: thin
         datastore: SOMEDATASTORE
      vm_nic:
        nic1:
         type: vmxnet3
         network: vm
         network_type: standard
      vm_hardware:
        memory_mb: 1024
        num_cpus: 1
        osid: ubuntu64Guest
        scsi: paravirtual
        vm_cdrom:
          type: "iso"
          iso_path: "DATASTOREISO/SOMEOS.iso"
      esxi:
        datacenter: SNA
        hostname: sna1.ourdomain.com

afro...@gmail.com

unread,
Feb 23, 2016, 8:23:42 AM2/23/16
to pysphere
Hi Stuart,

i made a playbook which creates vm machine along with attached iso. i mean, when the vm starts its boot from os. i wanted to use kickstart without pxe could please tell me what i need to add more in my playbook for the same.

My Playbook is:---

---
- name: create some vms
  hosts: localhost
  connection: local
  vars_prompt:
    - name: "vcenter_host"
      prompt: "Enter vcenter host"
      private: no
      default: "vcsa"
    - name: "vcenter_user"
      prompt: "Enter vcenter username"
      private: no
    - name: "vcenter_pass"
      prompt: "Enter vcenter password"
      private: yes
    - name: "vcenter_datacenter"
      prompt: "Enter datacenter name"
      private: no
    - name: "vcenter_datastore"
      prompt: "Enter datastore name"
      private: no
    - name: "esxi_host"
      prompt: "Enter vsphere host"
      private: no
  vars:
#    - vcenter_folder: 'beta'
    - vms:
        - guest: 'test04'
          state: 'powered_on'
          vcpu_hotadd: 'yes'
          mem_hotadd: 'yes'
          notes: 'Ansible Created'
          num_disks: '1'
          disks:
            disk1:
              size: '10'
              type: 'thin'
          network: 'VM Network'
          memory: '1024'
          cpus: '1'
          osid: 'rhel6_64Guest'
  tasks:
    - name: create vms (Single Disk)
      vsphere_guest:
        vcenter_hostname: "{{ vcenter_host }}"
        username: "{{ vcenter_user }}"
        password: "{{ vcenter_pass }}"
        guest: "{{ item.guest }}"
        state: "{{ item.state }}"
        vm_extra_config:
          vcpu.hotadd: "{{ item.vcpu_hotadd|default(omit) }}"
          mem.hotadd: "{{ item.mem_hotadd|default(omit) }}"
          notes: "{{ item.notes|default(omit) }}"
 #         folder: "{{ vcenter_folder }}"
        vm_disk:
          disk1:
            size_gb: "{{ item.disks.disk1.size }}"
            type: "{{ item.disks.disk1.type }}"
            datastore: "{{ vcenter_datastore }}"
 #          folder: "{{ vcenter_folder }}"
        vm_nic:
          nic1:
            type: "vmxnet3"
            network: "{{ item.network }}"
            network_type: "standard"
        vm_hardware:
          memory_mb: "{{ item.memory }}"
          num_cpus: "{{ item.cpus }}"
          osid: "{{ item.osid }}"
          scsi: "paravirtual"
          vm_cdrom:
            type: "iso"
            iso_path: "datastore1/rhel-server-6.6-x86_64-dvd.iso"
        esxi:
          datacenter: "{{ vcenter_datacenter }}"
          hostname: "{{ esxi_host }}"
      with_items: vms
      when: item.num_disks == '1'

Stuart Cracraft

unread,
Feb 23, 2016, 10:19:42 AM2/23/16
to pysp...@googlegroups.com, Stuart Cracraft
Would you like a working session over the network via shared console to try to get some breakthroughs together?

What company do you work for?
--
Has recibido este mensaje porque estás suscrito a un tema del grupo "pysphere" de Grupos de Google.
Para anular la suscripción a este tema, visita https://groups.google.com/d/topic/pysphere/iTNRGbtbans/unsubscribe.
Para anular la suscripción a este grupo y a todos sus temas, envía un correo electrónico a pysphere+u...@googlegroups.com.
Para acceder a más opciones, visita https://groups.google.com/d/optout.

afro...@gmail.com

unread,
Feb 26, 2016, 2:43:34 PM2/26/16
to pysphere, smcra...@me.com
yes, when is it possible ? i am in hcl

Gilberto Valentin

unread,
Jun 19, 2016, 9:04:03 AM6/19/16
to pysphere
Was there ever any progress on this? I definitely would be interested in provisioning the resources of a virtual machine in VMware and then have the VM run via Kickstart for the installation without the need of a PXE environment. I can provision the VM just fine with Ansible but I still have to manually pxeboot and select a profile. If there is a way to just pass some Kickstart options, that would be great

Stuart Cracraft

unread,
Jun 19, 2016, 9:23:16 AM6/19/16
to pysp...@googlegroups.com, Stuart Cracraft
None.

We’re going to Apache Mesos with Docker and getting rid of VMware.

> On Jun 19, 2016, at 9:04 AM, Gilberto Valentin <gvale...@gmail.com> wrote:
>
> Was there ever any progress on this? I definitely would be interested in provisioning the resources of a virtual machine in VMware and then have the VM run via Kickstart for the installation without the need of a PXE environment. I can provision the VM just fine with Ansible but I still have to manually pxeboot and select a profile. If there is a way to just pass some Kickstart options, that would be great
>
> --
> Has recibido este mensaje porque estás suscrito a un tema del grupo "pysphere" de Grupos de Google.
> Para anular la suscripción a este tema, visita https://groups.google.com/d/topic/pysphere/iTNRGbtbans/unsubscribe.
> Para anular la suscripción a este grupo y a todos sus temas, envía un correo electrónico a pysphere+u...@googlegroups.com.
> Para obtener más opciones, visita https://groups.google.com/d/optout.

Alejandro Cortina

unread,
Jul 20, 2016, 2:47:48 AM7/20/16
to pysphere
Gilberto,

I was stuck as you. packer.io will do the trick quite nicely!

in packer you define in a json file everything and packer will connect to esxi, upload iso, upload kickstart file, install everything and confirm it went ok.

Take a look at a json sample I have working:

https://groups.google.com/forum/#!topic/packer-tool/axerLqRe59E

You only need to create a "folder" directory with the kickstart file and point the json to it.

Cheers,

Stuart Cracraft

unread,
Jul 20, 2016, 9:41:54 AM7/20/16
to pysp...@googlegroups.com
We eventually gave up and are going to Apache Mesos for multi-data-center resource management including clusters.

Reply all
Reply to author
Forward
0 new messages