Discussion:
[ansible-project] Build automation using ESXi, Ansible, Pysphere
Patel Parimal
2015-01-06 09:07:53 UTC
Permalink
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
--
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-project+***@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.
Earl Robinson
2015-01-07 16:28:29 UTC
Permalink
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
Post by Patel Parimal
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
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/da56aeef-01f0-41f6-8dc9-3cd1bdd138d5%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/da56aeef-01f0-41f6-8dc9-3cd1bdd138d5%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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-project+***@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/CABGf5APRF_HeN%3Dgyvh0UGdBP%2BV8AeLsaXZZR1SYX833C17wrkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Michael DeHaan
2015-01-07 17:10:32 UTC
Permalink
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.
Post by Earl Robinson
Parimal,
To use kickstart you first need to present a boot media which is
configured to pull the kickstart file
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
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
Post by Patel Parimal
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
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/da56aeef-01f0-41f6-8dc9-3cd1bdd138d5%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/da56aeef-01f0-41f6-8dc9-3cd1bdd138d5%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CABGf5APRF_HeN%3Dgyvh0UGdBP%2BV8AeLsaXZZR1SYX833C17wrkQ%40mail.gmail.com
<https://groups.google.com/d/msgid/ansible-project/CABGf5APRF_HeN%3Dgyvh0UGdBP%2BV8AeLsaXZZR1SYX833C17wrkQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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-project+***@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/CA%2BnsWgz-ioBDvJAZeRWeS7Mu1hCMvn%2BrbEk8ALpn_KKk5Bwthw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Mark Phillips
2015-01-07 17:49:39 UTC
Permalink
This post might be inappropriate. Click to display it.
Stephen Granger
2015-01-07 19:25:37 UTC
Permalink
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!
Post by Mark Phillips
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
https://gist.github.com/phips/2777a564e10d53824df8
Post by Patel Parimal
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
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4af2ebed-cecb-4ba1-964a-bd76c0e128ed%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/4af2ebed-cecb-4ba1-964a-bd76c0e128ed%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Steve
--
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-project+***@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/CA%2BemtqvrF1DeL1aLYSHPfRbj-Pj2WfYTZ2BYm6vrO8_tHzgxrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Jason Hiatt
2015-05-09 22:51:20 UTC
Permalink
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
Post by Stephen Granger
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!
Post by Mark Phillips
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
https://gist.github.com/phips/2777a564e10d53824df8
Post by Patel Parimal
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
--
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
<javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4af2ebed-cecb-4ba1-964a-bd76c0e128ed%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/4af2ebed-cecb-4ba1-964a-bd76c0e128ed%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Steve
--
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-project+***@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/32b052b6-2378-42bf-a30f-df5dd70d44b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Larry Smith
2015-05-12 22:22:06 UTC
Permalink
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.

https://github.com/mrlesmithjr/Ansible

Hope this helps. Let me know if you have any questions.
Post by Patel Parimal
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
--
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-project+***@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/5f224c84-9850-426b-9ae8-6422756a3d15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Larry Smith
2015-05-12 23:59:24 UTC
Permalink
I recently just went through a similar process. I ended up deploying a TFTP
server using Ansible which included the Ubuntu Netboot PXE boot image to
provision new VMs. Using this method along with some shell scripts to help
along the way has worked out great for me. I will also be uploading more of
the playbooks that go along with this solution. Below is a link to my
github which is where I will be placing the playbooks. Right now the shell
scripts are there if you want to take a look.

https://github.com/mrlesmithjr/Ansible
<https://github.com/mrlesmithjr/Ansible>
Post by Patel Parimal
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
--
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-project+***@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/7020a10f-d729-4e3d-ad04-e8f0c3f19067%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...