Build automation using ESXi, Ansible, Pysphere

6,692 views
Skip to first unread message

Patel Parimal

unread,
Jan 6, 2015, 4:07:53 AM1/6/15
to ansible...@googlegroups.com
Hi,
I am newbie to Ansible. 

I have gone through the online documentation and examples for creating new VM on Ansible Docs - vsphere_guest (http://docs.ansible.com/vsphere_guest_module.html).

I want to automate VM creation and OS installation process using Ansible.

Currently I have VMWare ESXi available which doesn't support VM cloning, so I need to create a new VM every time from scratch and install OS(RHEL 6) into it.

Is there any way to provide kickstart file URL in Ansible Playbook (for example, static HTTP URL like http://192.168.0.1/ks/ks.cfg) so after newly built VM is powered on, OS will be installed into it ?

Thanks and regards,
Parimal

Earl Robinson

unread,
Jan 7, 2015, 11:28:34 AM1/7/15
to ansible...@googlegroups.com
Parimal,

To use kickstart you first need to present a boot media which is configured to pull the kickstart file
See: http://www.centos.org/docs/5/html/5.2/Installation_Guide/s1-kickstart2-howuse.html

You can use ansible to present the VM with such bootable media by launching it in a VLAN with a PXE boot server which will present the media, or by presenting the VM with a CD image with the kickstart file built in.

I've gone the CD image route with ansible, you can specify a cd image to boot like this:

vsphere_guest:
  vm_hardware:
    vm_cdrom:
      type: "iso"
      iso_path: "DatastoreName/cd-image.iso"


Of course you need to give the vsphere_guest module all other required arguments, but this is the simplest way I've found to kiskstart a vm using ansible.

-earl


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/da56aeef-01f0-41f6-8dc9-3cd1bdd138d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael DeHaan

unread,
Jan 7, 2015, 12:10:38 PM1/7/15
to ansible...@googlegroups.com
If you don't want to bake in the ks.cfg (for instance, if you have different install profiles coming off the same OS), supplying the kernel argument ks=http://server.example.com/foo.ks also works.



Mark Phillips

unread,
Jan 7, 2015, 12:49:39 PM1/7/15
to ansible...@googlegroups.com
Hello,

I've recently done just this - and I coupled the VM creation with PXE booting. I have two PXE menus in place, the default one just says 'boot to HD'. The other one is the install menu, with a kickstart line. I control the use of this with Ansible by doing the following:

Stephen Granger

unread,
Jan 7, 2015, 2:25:45 PM1/7/15
to ansible...@googlegroups.com
Hi Mark,

Thanks for posting that code, I've been unsure of how to extra the mac address for newly created VM's. I can now parse that to cobbler to create/update vm's.

Is anyone else using a similar workflow? I'm only using cobbler because we presently use it allows us to use our existing kickstart files.


Thanks!

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Steve

Jason Hiatt

unread,
May 10, 2015, 4:51:37 PM5/10/15
to ansible...@googlegroups.com
We have recently setup a similar workflow for RHEL 6 and 7.  Here are the steps if anyone is interested.
  1. We enter the server's information into our custom database (MySQL) that we use to track our inventory.  We also use this table to create our dynamic inventory for Ansible.  The table contains the server's name, IP and other server specific information.
  2. We kick off an Ansible playbook that does the following
    • Checks to see if the VM has already been created
    • Creates the VM using the vsphere_guest module.  The VM is setup to boot on a network with DHCP.
    • Collects facts about the VM.    We need this in order to get the MAC address of the newly created VM.
    • Updates our database with the MAC of the new VM.
    • Powers on the new VM.
  3. The server is powered on with a custom RHEL ISO attached.  The custom ISO is pointing to web service that will dynamically build our kickstart file. (http://kickstart.example.com/ws/ks.php).  The custom ISO also has the inst.ks.sendmac, ks.sendmac and kssendmac parameters set on the kernel line.  This will send the VM's MAC address to the web service which allow it to figure out the VM's IP information.
  4. The kickstart script installs base packages, subscribes the VM with Satellite, installs VM tools and adds the server to our AD domain.  The last thing the script does is send a web call to a web service that will change the VM's network from the DHCP network to the network that the VM is supposed to be on.
  5. Once the VM is up it is ready to have our standard Ansible plays ran on it.

Our last deployment consisted of 4 servers, we had the entire environment up and running and ready to hand off to our customer in 15 minutes!

Ansible rocks, thanks to the Ansible team for such a great product!


Hiatt

Larry Smith

unread,
May 13, 2015, 7:39:27 AM5/13/15
to ansible...@googlegroups.com
Patel,
Have you had any luck on this yet? I have gone down this path about a month or so ago. I am in the process of sharing back on the processes that I have come up with. Below is the flow.
1. Deploy TFTP server via Ansible which includes Ubuntu Netboot and configures all required services (TFTP,DHCP) and etc.
2. Create a project folder which includes some shell scripts that run each process flow of the build.
3. Provision VMs (VM PXE boots and auto installs Ubuntu from TFTP server)
4. Bootstrap VMs
5. Deploy apps

here is the link to my github repo that I will be populating over the next while with some of this.


Hope this helps. Let me know if you have any questions.
Message has been deleted

Mihai Cristian Satmarean

unread,
Nov 6, 2015, 11:19:23 AM11/6/15
to Ansible Project

@Michael, thanks! This might be exactly what I am looking for in this stage, but I cannot find an example of how to insert the arguments at boot to point to the remote kickstart.

Mihai Satmarean

Mark Phillips

unread,
Nov 6, 2015, 12:33:56 PM11/6/15
to Ansible Project
If it's from a CD boot Mihai just hit 'tab' then put ks= as Michael suggested.

Otherwise, with PXE boot you can specify the option on the kernel line, like:

Mihai Cristian Satmarean

unread,
Nov 11, 2015, 11:58:00 AM11/11/15
to Ansible Project
Thanks Mark,
We are already doing both, I thought that there is a module or an Ansible trick that you can specify the boot parameter in the vsphere boot :) that would be helpful.

Mark Phillips

unread,
Nov 11, 2015, 12:18:29 PM11/11/15
to Ansible Project
Hello Mihai,

Well, it's two other products there that are in effect needing control of. You need vSphere to interact with the Linux boot disc menu - so not easy, really.

See my earlier post in this thread - set up a network boot (PXE) and have two menu items. Or, alternatively, use something like iPXE (http://ipxe.org) to make a specific boot disc image which you 'insert' into the VMware VM CDROM to boot.

Cheers

Mihai Cristian Satmarean

unread,
Nov 12, 2015, 3:11:44 AM11/12/15
to Ansible Project
Hi Mark,

I get your point. Sorry for not being very clear (I am working on that).
I am using this already  based on what is out there, 
what I only miss is a way from vSphere to tell back to Ansible that the VM was rebooted.
that would be the killer feature for now.
Thanks!

Mark Phillips

unread,
Nov 12, 2015, 4:27:35 AM11/12/15
to Ansible Project
Not a problem Mihai! *There is always a way*.

There are choices here, as per usual - you could always use 'wait_for'[1] in an Ansible play, or you could use a 'phone home' type solution - i.e. the newly provisioned virtual machine boots and the first thing it does is 'look for' a centralised Ansible point to tell it 'hello, I'm booted'.

This is an example I did with Amazon earlier this year of a phone home - https://github.com/phips/tiad_demo/blob/master/plays/new.yml#L31 The actual script, highlighted in that line, is here: https://github.com/phips/tiad_demo/blob/master/scripts/ec2_bootstrap.sh All it is doing is a curl back an Ansible Tower instance, which runs a given job against the newly booted machine.

Hope that helps.

Mihai Cristian Satmarean

unread,
Nov 12, 2015, 5:34:26 AM11/12/15
to Ansible Project
Great Mark - *There is always a way* even if is the crazyest way :)
I will investigate for now the wait for idea and ping the port or something.
Thanks a lot!

Jason Hiatt

unread,
Nov 12, 2015, 7:18:10 AM11/12/15
to ansible...@googlegroups.com
We do something similar with our builds. The last thing we do in the post section of our Kickstart script is make a web service call. The web service moves the VM to the correct network. 
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Holm0CFBbLo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

afro...@gmail.com

unread,
Feb 26, 2016, 3:46:11 PM2/26/16
to Ansible Project
Hi Mark, 

bit confusion, need your suggestion...

i made a play book to create vm machine and  attached iso_path. when i run the playbook it creates a vm automatically boot from rhel6 iso. 
if it is booting from iso automatically then why i need to use pxe ? can i install rhel6 OS by kickstart ? if yes then what more syntax i need to define in my script.
please find the below mentioned my playbook and suggest me the right way.

---
- 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'

Jason Hiatt

unread,
Feb 26, 2016, 7:36:11 PM2/26/16
to ansible...@googlegroups.com
You will need to open up the ISO and add a few parameters to boot config. 

I added the location of my dynamic kickstart web service (ks=http://example.com/ks.php) and the kssendmac parameter. 

Once you modify that file recreate your ISO. 
This link should help. 


Copy the new iso to your data store and reference it you Ansible play. 
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Holm0CFBbLo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

afroz. khan

unread,
Feb 28, 2016, 12:39:42 PM2/28/16
to ansible...@googlegroups.com
Hi Jason,

Thanks for your quick response....
Now i have made custom iso of linux. and upload it esxi datastore. do i need to add any parameter in ansible playbook for kickstart or just need to run same play book after define the customer iso path ? 

 vm_cdrom:
            type: "iso"
            iso_path: "datastore1/boot.iso"

boot.iso is a RHEL 7 iso file which i have customized..


Regards,
Afroz Khan


Jason Hiatt

unread,
Feb 28, 2016, 8:25:20 PM2/28/16
to ansible...@googlegroups.com
The kickstart path should be set in your ISO

It should look something like ks=http://example.com/ks.php kssendmac

The kssendmac parameter sends the VMs MAC address to the kickstart file. 

Here is an example play and and scripts I use. 


Hope this helps. 

Dibyendu Paul

unread,
Apr 21, 2016, 11:01:44 AM4/21/16
to Ansible Project
I have a question on this.
In the above example I see only one node that was used for deployment through custom boot iso but in case there are multiple nodes? the same kickstart iso cannot be used right. because the IP address for each node would be different. how to dynamically build VMs by reading IPs dynamically?

Mark Phillips

unread,
Apr 21, 2016, 12:56:00 PM4/21/16
to Ansible Project
Custom ISO, that's generic. Think something like iPXE. Boots, kickstart talks to a web service, web service provides tailored Kickstart file.

Jason Hiatt

unread,
Apr 21, 2016, 10:23:35 PM4/21/16
to ansible...@googlegroups.com
You will need to setup a few more things, I'm working on Dockerizing this entire setup, just haven't had time.
I'll add more examples to Github this weekend.

First you need to add something like this to the kernel line of your custom ISO

For RHEL6 for example
ks=http://kickstart.eample.com/kickstart/ks.php?osid=rhel_64Guest kssendmac ks.sendmac inst.ks.sendmac

That tells the ISO to get it's Kickstart config from a dynamic kickstart file (ks.php - web service) and to send the VM's MAC address.

Here is a snippet from the web service

<?php
foreach (getallheaders() as $sName => $sValue) {
        if ($sName == "X-RHN-Provisioning-MAC-0") {
                $aValue = explode(" ", $sValue);
                $sThisMAC = strtolower($aValue[1]);
                if ($sThisMAC != "") {
                       $sSQL = "select * from servers where LOWER(macaddress) = '" . $sThisMAC;
                       ##Generate dynamic kickstart
?>

Now that I can lookup the MAC address I can create a dynamic Kickstart for the VM.

I now also have the server in a database which allows me to create a dynamic Ansible inventory.
Ansible has helped our automation out tremendously, we can fully provision RHEL servers in about 10 minutes.

Our motto is "If your VM isn't ready in 15 minutes your next one is free!"

Thanks,
Jason


Dibyendu Paul

unread,
Apr 22, 2016, 12:24:57 AM4/22/16
to Ansible Project
Hi
How the kick start will pick individual ips of the vms. Where those ips to be defined?
The kick start will not have the up conf? How do you make it generalized?

Jason Hiatt

unread,
Apr 24, 2016, 11:07:30 PM4/24/16
to ansible...@googlegroups.com
We have a web UI that lets our admins input IP, VM name, number of CPUs, RAM and other attributes.
You can see a stripped down version of it here -> https://github.com/OneMainF/vmware-rhel-server-builder/blob/master/build/src/www/createVM.html

The web UI calls this web service when all inputs are entered -> https://github.com/OneMainF/vmware-rhel-server-builder/blob/master/build/src/www/ws/createvm.php

The web service adds the server to a database and creates an Ansible play and runs it.  The playbook creates the VM and collects the VM's MAC address and updates the DB.

Once the VM starts up the dynamic Kickstart file is called and the VM is built.
https://github.com/OneMainF/vmware-rhel-server-builder/blob/master/build/src/www/kickstart/ks.php


I'm getting closer to Dockeizing the application, hopefully I can get it done this week.

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Holm0CFBbLo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Dibyendu Paul

unread,
Apr 25, 2016, 12:32:28 AM4/25/16
to Ansible Project
Hi Jason
This is excellent!
In this setup is it possible to pick the RHEL OS from the Installation server? where the iso could be kept or local repository could be created?

Regards
Dibyendu Paul

Jason Hiatt

unread,
Apr 26, 2016, 6:49:26 PM4/26/16
to ansible...@googlegroups.com

Yes, you could specify the installation server in your custom ISO.
I think the correct option to use is "inst.repo="

We just use the installation source from the DVD.

Thanks,
Jason


Dibyendu Paul

unread,
Apr 26, 2016, 8:10:38 PM4/26/16
to Ansible Project
Hi Jason
Thanks.
Are you going to add a short description in github as in how to use the repository? I mean a set of instructions may be.

Dibyendu Paul

unread,
Apr 26, 2016, 8:10:39 PM4/26/16
to Ansible Project

Dibyendu Paul

unread,
Apr 28, 2016, 2:45:00 AM4/28/16
to Ansible Project
Also The current Web UI allows to create one  VM at a time. Is It possible to create Multiple VMs at a time?

Jason Hiatt

unread,
Apr 29, 2016, 8:42:20 AM4/29/16
to ansible...@googlegroups.com
Yes, I am going to update code and write up some instructions this weekend.  I have a big project at work I need to finish up before I can get to that though.

If you want to make multiple VMs I would write a script that calls the createVM.php web service.

All you would  have to do is call curl, for example.  curl "http://test.example.com/ws/createVM.php?vmname=${VMName}&ipaddress=${IPAddress}&cpus=2......."

Thanks,
Jason




Dibyendu Paul

unread,
Apr 29, 2016, 10:22:15 AM4/29/16
to Ansible Project
Thanks much Jason.
I will keep an eye on the github page.

Dibyendu Paul

unread,
May 5, 2016, 10:44:49 PM5/5/16
to Ansible Project
Hi Jason
Is there any instructions available yet?

Jason Hiatt

unread,
May 9, 2016, 9:47:56 PM5/9/16
to ansible...@googlegroups.com
Instructions are finally up, sorry it took so long, ran into some bugs while I was Dockerizing the app. Please try it out and let me know what problems you come across. 

Dibyendu Paul

unread,
May 10, 2016, 6:30:55 AM5/10/16
to Ansible Project
Thanks Great Jason.
But I have a silly question.
where exactly (Which file) do I insert the following line: kssendmac ks.sendmac inst.ks.sendmac ks=http://CONTAINERHOSTNAME/kickstart/ks.php?osid=rhel6_64Guest
The link you mentioned ( http://serverfault.com/questions/517908/how-to-create-a-custom-iso-image-in-centos) basically used the kickstart file and here I suppose the boot line needs to be added. where do I put the boot line in that case? Is it the isolinux.cfg file I need to modify?

Jason Hiatt

unread,
May 10, 2016, 6:01:58 PM5/10/16
to ansible...@googlegroups.com
Yes, the isolinux.cfg file, this link may explain better. 

Dibyendu Paul

unread,
May 11, 2016, 12:04:35 AM5/11/16
to Ansible Project
Thanks Jason.
Just to make sure that I am doing it right.
Could you please confirm if this is correct. I have changed the texts marked in BOLD.

default ks
#prompt 1
timeout 600

display boot.msg

menu background splash.jpg
menu title Welcome to Red Hat Enterprise Linux 6.5!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000

label linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img
label vesa
  menu label Install system with ^basic video driver
  kernel vmlinuz
  append initrd=initrd.img xdriver=vesa nomodeset
label rescue
  menu label ^Rescue installed system
  kernel vmlinuz
  append initrd=initrd.img rescue
label local
  menu label Boot from ^local drive
  localboot 0xffff
label memtest86
  menu label ^Memory test
  kernel memtest
  append -
label ks
  menu label ^Kickstart installation
  kernel kickstart
  append kssendmac ks.sendmac inst.ks.sendmac ks=http://CONTAINERHOSTNAME/kickstart/ks.php?osid=rhel7_64Guest

Jason Hiatt

unread,
May 11, 2016, 6:55:01 AM5/11/16
to ansible...@googlegroups.com
That looks correct, make sure CONTAINERHOSTNAME is changed to the hostname that is running your Docker container. 

Dibyendu Paul

unread,
May 23, 2016, 5:26:17 AM5/23/16
to Ansible Project
Hi Jason
Any idea about this error?
[root@controlserver vmware-rhel-server-builder]# /usr/bin/docker build -t hs .
Sending build context to Docker daemon 1.032 MB
Sending build context to Docker daemon
Step 0 : FROM centos
Pulling repository centos
[root@controlserver vmware-rhel-server-builder]#

Jason Hiatt

unread,
May 23, 2016, 10:59:48 PM5/23/16
to ansible...@googlegroups.com
Looks like Docker can't get out to the Internet to fetch the CentOS image. Make sure the box you are on has Internet access or if is behind a proxy has the proxy variables set. 

Dibyendu Paul

unread,
May 24, 2016, 4:45:42 AM5/24/16
to Ansible Project
Hi Jason
The machine has internet access I am able to use yum install. The proxy is set. But I am wondering why is it looking for centos. Also is it possible that it doesn't look for internet at all?

Jason Hiatt

unread,
May 24, 2016, 8:55:11 AM5/24/16
to ansible...@googlegroups.com
Here is how to setup Docker to use proxy settings. https://docs.docker.com/engine/admin/systemd/

The Docker container uses CentOS as its base image. If you don't want to use Docker I can make an Ansible playbook for you instead. I won't be able to get the playbook ready until next week, I'm leaving for vacation today.

> On May 24, 2016, at 03:45, Dibyendu Paul <dibyendu...@gmail.com> wrote:
>
> Hi Jason
> The machine has internet access I am able to use yum install. The proxy is set. But I am wondering why is it looking for centos. Also is it possible that it doesn't look for internet at all?
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Holm0CFBbLo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8b0e459c-b3dd-4401-b021-6bcf5adf097e%40googlegroups.com.

Dibyendu Paul

unread,
May 26, 2016, 11:56:12 AM5/26/16
to Ansible Project
Hi Jason
It would be great if you could create an ansible playbook for this. Because I might not able to use docker in the real lab. I'll wait untill you come back from vacation. :)
Thanks in advance. Have a wonderful time. :)

Jason Hiatt

unread,
Jun 2, 2016, 10:31:09 PM6/2/16
to ansible...@googlegroups.com
I've created a playbook that will work with RHEL7, try it out and let me know how it goes.
> --
> You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Holm0CFBbLo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1eb84ea4-3bb3-47e3-b879-280544f5a95b%40googlegroups.com.

Dibyendu Paul

unread,
Jun 2, 2016, 11:20:07 PM6/2/16
to Ansible Project
Thanks Jason. But I am using RHEL 6.7. Will it work there?

Dibyendu Paul

unread,
Jun 5, 2016, 11:21:44 PM6/5/16
to Ansible Project
Hi Jason
The github repository is not available any more. could you please share the new repo if you have created one?

Jason Hiatt

unread,
Jun 8, 2016, 7:59:11 AM6/8/16
to ansible...@googlegroups.com
New repo

I'll create a playbook that works on RHEL 6.7 sometime this week
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Holm0CFBbLo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Dibyendu Paul

unread,
Jun 20, 2016, 12:07:06 AM6/20/16
to Ansible Project
Hi Jason
I have tried the ansible playbook that you created.
Here are the issues I am facing at this time.

1. while creating running the playbook I got 
TASK [Open port 80 in the firewall] ********************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "Destination /etc/sysconfig/iptables does not exist !", "rc": 257}


to get rid of this error I added /etc/sysconfig/iptables manually, whereas in my server iptables service was disabled. Is it mandatory to have iptables settings in place?

2. Second error:

TASK [SELinux allow to connect to MySQL] ***************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "This module requires libselinux-python support"}

I installed the rpm in order to get rid of this error. This can be added to the instruction.

3. Third Error:

TASK [SELinux allow to connect to MySQL] ***************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "SELinux is disabled on this host."}

By default in my server SELINUX was disabled. Is it Mandatory to be the SELINUX to be enabled?
to get rid of this I enabled SELINUX.

After this The playbook ran successfully.
But I was unable to create a VM.

Error 1: "Invalid HD Side" I have HD side as 20/30/50
where as when I gave the value as 100 or 200 the error disappeared.

Error 2: when I rerty a VM creation, it says <Node Name> already exists in the DB, whereas the node was not created at all, Is the nodename getting saved in DB somewhere? If yes then how to clean that up?

Overall, I am not able to find out why the VM creation is not working.
Is there any way to check any logs to find out the errors? which log to check?

Thanks and regards
Dibyendu

Brian Coca

unread,
Jun 20, 2016, 9:16:25 AM6/20/16
to ansible...@googlegroups.com
Even if selinux is 'inactive' Ansible requires the  libselinux-python library to make sure contexts are preserved, otherwise you can get an unusable system if selinux is turned on later.


----------
Brian Coca

Jason Hiatt

unread,
Jun 20, 2016, 10:22:11 PM6/20/16
to ansible...@googlegroups.com
I left the SELinux rules in place because I assumed that they are enabled. If you have disabled them go ahead and comment out those lines from the playbook. 

To remove any severs from the table run the following commands.  

mysql -u root -d sysmgmt
delete from servers where serverid = 'your_server';

For more troubleshooting go to the /var/www/html/builds/ directory and cat out the yml file for your server so I take a look. 

Be sure the remove any sensitive information from the yml file. 

Dibyendu Paul

unread,
Jun 20, 2016, 11:20:12 PM6/20/16
to Ansible Project
Hi Jason
Thank you.
Is there any way that a log rotation could be introduced for this project.

Dibyendu Paul

unread,
Jun 21, 2016, 2:36:03 AM6/21/16
to Ansible Project
It is also not clear to me how do I map VMWare network and their Managed Object Reference (MoRef)
what are the information this should contain?
{
        "192.168.1.0": "dvportgroup-123",
        "192.168.2.0": "dvportgroup-456"
}
how do I map 

VirtualMachine-vm-*

HostSystem-host-*

Datastore-datastore-*


for example, I have a ESXI host, vCenter and 2 datastores.

Jason Hiatt

unread,
Jun 21, 2016, 9:31:48 PM6/21/16
to ansible...@googlegroups.com
Sure, which logs need rotated?
> --
> You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Holm0CFBbLo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6aa3fe02-9827-437a-9bd3-6461ee252687%40googlegroups.com.

Dibyendu Paul

unread,
Jun 21, 2016, 10:03:08 PM6/21/16
to Ansible Project
Mostly Ansible related logs.

It is also not clear to me how do I map VMWare network and their Managed Object Reference (MoRef)
what are the information this should contain?
{
        "192.168.1.0": "dvportgroup-123",
        "192.168.2.0": "dvportgroup-456"
}
how do I map 

VirtualMachine-vm-*

HostSystem-host-*

Datastore-datastore-*


for example, I have a ESXI host, vCenter and 2 datastores.

Basically I was not able to spin up a single VM yet. :(

Jason Hiatt

unread,
Jun 21, 2016, 11:04:19 PM6/21/16
to ansible...@googlegroups.com
Please email me the yml file in the /var/www/html/builds directory 

Jason Hiatt

unread,
Jun 21, 2016, 11:25:04 PM6/21/16
to ansible...@googlegroups.com
You only need the mapping for the distributed switches, this will not affect VM builds. There is a script that gets called at the end of the build process that changes the VMs network from the DHCP network to your desired network. If this step fails the VM will still get crested, it will just be on the wrong network. You will have to go into VCenter and manually change the VMs network. 

I'll write a script that gets the Morefs of your switches this week. 
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Holm0CFBbLo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Dibyendu Paul

unread,
Jun 22, 2016, 2:17:26 AM6/22/16
to Ansible Project
That is great!
I had another query. In case the web UI is not used is there any way the information could be fed to the ansible as an input file?

Dibyendu Paul

unread,
Jun 23, 2016, 12:15:02 PM6/23/16
to Ansible Project
Hi Jason
Were you able to analyze the yml files I emailed you? Is there any specific issues?
Reply all
Reply to author
Forward
0 new messages