SlideShare a Scribd company logo
1 of 55
Download to read offline
Spicing up VMware with
Ansible and InSpec
T-Systems Multimedia Solutions GmbH
Martin Schurz
Sebastian Gumprich
T-Systems MMS
T-Systems Multimedia Solutions GmbH
Ops: the old days (tm)
T-Systems Multimedia Solutions GmbH
Ops: the old days (tm)
T-Systems Multimedia Solutions GmbH
Ops: the old days (tm)
handcrafted and sometimes arcane con guration
clusters
parameters for Oracle
the "one" server someone installed
virtualization is just lift and shift
T-Systems Multimedia Solutions GmbH
Ops: slowly improving
reliance on enterprise tools
vSphere / vRealize / vCloud
T-Systems Multimedia Solutions GmbH
Ops: slowly improving
reliance on enterprise tools
vSphere / vRealize / vCloud
T-Systems Multimedia Solutions GmbH
VMware
T-Systems Multimedia Solutions GmbH
We have a lot of pets,
but we need more cattle
T-Systems Multimedia Solutions GmbH
Mantra:
manual work is a bug!
T-Systems Multimedia Solutions GmbH
T-Systems Multimedia Solutions GmbH
Why Ansible?
because we don't like Puppet
Ansible is simple, agent-less
easy to learn
straight-forward in task execution
Not written in Ruby (looking @ you, Puppet)
T-Systems Multimedia Solutions GmbH
Ansible - quick rundown
T-Systems Multimedia Solutions GmbH
Ansible modules - many of them
T-Systems Multimedia Solutions GmbH
... except Oracle
pet, not cattle.
T-Systems Multimedia Solutions GmbH
Jenkins incoming
already reliable application deployments
now reliable con guration of servers, too
T-Systems Multimedia Solutions GmbH
Automation is fun!
... or so they say ...
T-Systems Multimedia Solutions GmbH
Automation is fun!
... or so they say ...
due to "unfortunate circumstances" we lost half
our servers
“
“
T-Systems Multimedia Solutions GmbH
Automation is fun!
... or so they say ...
... and we did recover easily
due to "unfortunate circumstances" we lost half
our servers
“
“
T-Systems Multimedia Solutions GmbH
Automation is fun!
... or so they say ...
... and we did recover easily
due to "unfortunate circumstances" we lost half
our servers
“
“
T-Systems Multimedia Solutions GmbH
Managing ESX Hosts
Prebuild modules for all basic tasks:
Network
Storage
Cluster
vCenter
VM tasks
T-Systems Multimedia Solutions GmbH
Managing ESX Hosts (example)
I want to con gure all VLANs for my ESX Cluster
All Hosts should have correct VLAN con guration
All Hosts should be con gured from one source
Adding Hosts and VLANs should be easy
(like a distributed vSwitch)
T-Systems Multimedia Solutions GmbH
Managing ESX Hosts (example)
create a host group (e.g. esx-servers )
Add group_vars:
vlans:
customer1-vlan:
tag: 4006
vswitch: vSwitch0
customer2-vlan:
tag: 4007
vswitch: vSwitch0
...
T-Systems Multimedia Solutions GmbH
Managing ESX Hosts (example)
Add a playbook task:
- hosts: esx-servers
tasks:
- name: "Add VLANs"
local_action:
module: vmware_portgroup
hostname: '{{ ansible_hostname }}'
username: root
password: '{{ esxi_pass }}'
switch_name: "{{ item.value.vswitch }}"
portgroup_name: "{{ item.key }}"
vlan_id: "{{ item.value.tag }}"
validate_certs: false
with_dict: "{{ vlans }}"
T-Systems Multimedia Solutions GmbH
Managing ESX Hosts (example)
rst Ansible run
TASK [Add VLANs] *****************************************
ok: [esx_server] => (item={'value': 
{u'vswitch': u'vSwitch0', u'tag': 4006}, 
'key': u'customer1-vlan'})
changed: [esx_server] => (item={'value': 
{u'vswitch': u'vSwitch0', u'tag': 4007}, 
'key': u'customer2-vlan'})
PLAY RECAP ***********************************************
esx_server : ok=1 changed=1 unreachable=0 failed=0
T-Systems Multimedia Solutions GmbH
Managing ESX Hosts (example)
second Ansible run
TASK [Add VLANs] *****************************************
ok: [esx_server] => (item={'value': 
{u'vswitch': u'vSwitch0', u'tag': 4006}, 
'key': u'customer1-vlan'})
ok: [esx_server] => (item={'value': 
{u'vswitch': u'vSwitch0', u'tag': 4007}, 
'key': u'customer2-vlan'})
PLAY RECAP ***********************************************
esx_server : ok=1 changed=0 unreachable=0 failed=0
T-Systems Multimedia Solutions GmbH
Managing ESX Hosts (example)
I want to con gure all VLANs for my ESX Cluster
All Hosts should have correct VLAN con g
All Hosts should be con gured from one source
Adding Hosts and VLANs should be easy
(like a distributed vSwitch)
T-Systems Multimedia Solutions GmbH
Creating VMs - Host variables
vm_cpu: 8
vm_ram: 8
vm_storage: srv_live_vmdata1
vm_host: srv-live-vh07
vm_disksize: 80
default_gateway: 172.31.225.1
network_ether_interfaces:
- vm_net: srv-lgen-app
device: eth0
bootproto: static
address: 172.31.225.36
netmask: 255.255.255.128
onboot: "yes"
dns1: "{{ srv_dns1 }}"
dns2: "{{ srv_dns2 }}"
domain: "{{ srv_domain }}"
T-Systems Multimedia Solutions GmbH
Creating VMs - the Ansible task
- name: Create new VM
vmware_guest:
hostname: "{{ vcenter_host }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
datacenter: "{{ vcenter_dc }}"
name: "{{ item }}"
template: "{{ vm_template }}"
state: poweredon
wait_for_ip_address: yes
hardware:
memory_mb: "{{hostvars[item]['vm_ram']}}"
num_cpus: "{{hostvars[item]['vm_cpu']}}"
disk:
- size_gb: "{{hostvars[item]['vm_disksize']}}"
datastore: "{{hostvars[item]['vm_storage']}}"
T-Systems Multimedia Solutions GmbH
Adding Security to the mix
Telekom security guideline requires all servers to
be hardened
also VMware security guideline:
https://www.vmware.com/security/hardening-
guides.html (beware Excel!)
T-Systems Multimedia Solutions GmbH
Hardening an ESX host (example)
VMware Requirement:
Guideline ID: ESXi.disable-mob:
The managed object browser (MOB) provides a
way to explore the object model used by the
VMkernel to manage the host; it enables
con gurations to be changed as well. This
interface is meant to be used primarily for
debugging the vSphere SDK. In Sphere 6.0 this
is disabled by default
T-Systems Multimedia Solutions GmbH
Hardening an ESX host (example)
Ansible implementation:
# Guideline ID: ESXi.disable-mob
- name: get | disable MOB
shell: "vim-cmd hostsvc/advopt/view 
Config.HostAgent.plugins.solo.enableMob 
| grep value | cut -d ' ' -f 9"
register: mob_status
changed_when: mob_status.rc > 0
- name: set | disable MOB
shell: "vim-cmd hostsvc/advopt/update 
Config.HostAgent.plugins.solo.enableMob 
bool {{ mob }}"
when: mob not in mob_status.stdout
T-Systems Multimedia Solutions GmbH
Hardening VMs - nding them all!
- name: Find all .vmx files on local store
shell: |
find /vmfs/volumes/datastore/ -name *.vmx
register: found_vms
changed_when: False
T-Systems Multimedia Solutions GmbH
Hardening VMs - changing them
- name: Set VM parameters
lineinfile:
path: "{{ item[1] }}"
regexp: "{{ item[0].key }}"
backrefs: yes
line: "{{ item[0].key }} = "{{ item[0].value }}""
with_nested:
- "{{ parameters_add }}"
- "{{ found_vms }}"
parameters_add:
- { key: isolation.tools.copy.disable, value: TRUE }
- { key: isolation.tools.paste.disable, value: TRUE }
T-Systems Multimedia Solutions GmbH
Managing VMs - deleting them
- name: delete VM
vmware_guest:
vcenter_hostname: "{{ vcenter_host }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
validate_certs: false
guest: "{{ item }}"
force: true
state: absent # deletion!
with_items: "{{ vm_name }}"
T-Systems Multimedia Solutions GmbH
Managing VMs - making snapshots
- name: Create snapshot of {{vm_name}}
vmware_guest_snapshot:
folder: "/vm/"
name: "{{ vm_name }}"
state: present
snapshot_name: "snap_{{ '%Y-%m-%d-%M' | strftime }}"
T-Systems Multimedia Solutions GmbH
Not everything out of the box
moving VMs not implemented in Ansible :(
but Ansible is extensible with Python code
so just write your own module
VMware vSphere API Bindings for Python
(https://github.com/vmware/pyvmomi)
VMware API Docs
Python + API =
T-Systems Multimedia Solutions GmbH
Not everything out of the box
we started with Ansible code:
- name: Move VM to target host and DS
delegate_to: localhost
vm_move:
vc_host: "{{ vcenter_host }}"
vc_pass: "{{ vcenter_pass }}"
vc_user: "{{ vcenter_user }}"
vm_name: "{{ inventory_hostname }}"
ds_name: "{{ vm_storage }}"
esx_host: "{{ vm_host }}"
T-Systems Multimedia Solutions GmbH
Not everything out of the box
then think about implementation
what needs to be done:
Locate the VM we want to move
T-Systems Multimedia Solutions GmbH
Not everything out of the box
then think about implementation
what needs to be done:
Locate the VM we want to move
Locate the target ESX host / storage
T-Systems Multimedia Solutions GmbH
Not everything out of the box
then think about implementation
what needs to be done:
Locate the VM we want to move
Locate the target ESX host / storage
check what needs to be changed
T-Systems Multimedia Solutions GmbH
Not everything out of the box
then think about implementation
what needs to be done:
Locate the VM we want to move
Locate the target ESX host / storage
check what needs to be changed
move the VM
T-Systems Multimedia Solutions GmbH
Not everything out of the box
some boilerplate is needed:
def main():
module = AnsibleModule(
argument_spec=dict(
vc_host = dict(required=True, type='str'),
...
esx_host = dict(required=False, type='str'),
),
)
result = dict(
changed=False, original_message='', message=''
)
# do something
module.exit_json(**result)
T-Systems Multimedia Solutions GmbH
Not everything out of the box
vm = get_obj(content, [vim.VirtualMachine], vm_name)
vm_datastore = get_obj(content, [vim.Datastore], ds_name)
dest_host = get_obj(content, [vim.HostSystem], esx_host)
vm_relocate_spec = vim.vm.RelocateSpec()
T-Systems Multimedia Solutions GmbH
Not everything out of the box
vm = get_obj(content, [vim.VirtualMachine], vm_name)
vm_datastore = get_obj(content, [vim.Datastore], ds_name)
dest_host = get_obj(content, [vim.HostSystem], esx_host)
vm_relocate_spec = vim.vm.RelocateSpec()
if vm.datastore[0] != vm_datastore:
result['changed'] = True
vm_relocate_spec.datastore = vm_datastore
T-Systems Multimedia Solutions GmbH
Not everything out of the box
vm = get_obj(content, [vim.VirtualMachine], vm_name)
vm_datastore = get_obj(content, [vim.Datastore], ds_name)
dest_host = get_obj(content, [vim.HostSystem], esx_host)
vm_relocate_spec = vim.vm.RelocateSpec()
if vm.datastore[0] != vm_datastore:
result['changed'] = True
vm_relocate_spec.datastore = vm_datastore
if vm.runtime.host != dest_host:
result['changed'] = True
vm_relocate_spec.host = dest_host
T-Systems Multimedia Solutions GmbH
Not everything out of the box
vm = get_obj(content, [vim.VirtualMachine], vm_name)
vm_datastore = get_obj(content, [vim.Datastore], ds_name)
dest_host = get_obj(content, [vim.HostSystem], esx_host)
vm_relocate_spec = vim.vm.RelocateSpec()
if vm.datastore[0] != vm_datastore:
result['changed'] = True
vm_relocate_spec.datastore = vm_datastore
if vm.runtime.host != dest_host:
result['changed'] = True
vm_relocate_spec.host = dest_host
if result['changed']:
task = vm.Relocate(spec=vm_relocate_spec)
wait_for_task(module, task, si)
T-Systems Multimedia Solutions GmbH
Not everything out of the box
VMWare has a tool called govc
https://github.com/vmware/govmomi/tree/mast
er/govc
pretty easy to use from the command line
this can also be included in Ansible scripts
but do I really need to write all this python code?
I'm not a programmer!
“
“
T-Systems Multimedia Solutions GmbH
Testing
T-Systems Multimedia Solutions GmbH
Testing with inSpec
written by Chef guys
originally a fork of serverspec
diverged since then and has gotten many new
features
T-Systems Multimedia Solutions GmbH
Testing with inSpec - the test
control 'VM.disable-console-drag-n-drop' do
title 'Explicitly disable copy/paste operations'
vsphere.datacenters.each { |dc|
dc.vms.each { |vm|
describe vm_advancedsetting) do
its(['isolation.tools.dnd.disable']) 
{ should eq true }
end
}
}
end
T-Systems Multimedia Solutions GmbH
Testing with inSpec - results
VM.disable-console-drag-n-drop
isolation.tools.dnd.disable should eq true
Profile Summary: 136 successful controls, 0 failures
Test Summary: 136 successful, 0 failures, 0 skipped
T-Systems Multimedia Solutions GmbH
Bonus - ansible-cmdb
T-Systems Multimedia Solutions GmbH
The End
Now grab some food!
T-Systems Multimedia Solutions GmbH
Ansible logo from redbubble.com
VMWare logo from fujitsu
InSpec logo from sdtimes
Fry from ickr user liliana_von_k
success kid from instagram user laneymg
automate from ickr user Amber Case
Ansible works image from tutorialspoint.com
T-Systems Multimedia Solutions GmbH

More Related Content

What's hot

Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Etsuji Nakai
 
SUSE CaaSP: deploy OpenFaaS and Ethereum Blockchain on Kubernetes
SUSE CaaSP: deploy OpenFaaS and Ethereum Blockchain on KubernetesSUSE CaaSP: deploy OpenFaaS and Ethereum Blockchain on Kubernetes
SUSE CaaSP: deploy OpenFaaS and Ethereum Blockchain on KubernetesJuan Herrera Utande
 
Meetup 23 - 01 - The things I wish I would have known before doing OpenStack ...
Meetup 23 - 01 - The things I wish I would have known before doing OpenStack ...Meetup 23 - 01 - The things I wish I would have known before doing OpenStack ...
Meetup 23 - 01 - The things I wish I would have known before doing OpenStack ...Vietnam Open Infrastructure User Group
 
Tối ưu hiệu năng đáp ứng các yêu cầu của hệ thống 4G core
Tối ưu hiệu năng đáp ứng các yêu cầu của hệ thống 4G coreTối ưu hiệu năng đáp ứng các yêu cầu của hệ thống 4G core
Tối ưu hiệu năng đáp ứng các yêu cầu của hệ thống 4G coreVietnam Open Infrastructure User Group
 
Docker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup SlidesDocker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup SlidesDocker, Inc.
 
K8s best practices from the field!
K8s best practices from the field!K8s best practices from the field!
K8s best practices from the field!DoiT International
 
fabric8 ... and Docker, Kubernetes & OpenShift
fabric8 ... and Docker, Kubernetes & OpenShiftfabric8 ... and Docker, Kubernetes & OpenShift
fabric8 ... and Docker, Kubernetes & OpenShiftroland.huss
 
Kubernetes and Istio
Kubernetes and IstioKubernetes and Istio
Kubernetes and IstioKetan Gote
 
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...Uri Cohen
 
Docker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&ADocker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&ADocker, Inc.
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containersRed Hat Developers
 
Monitoring kubernetes with prometheus-operator
Monitoring kubernetes with prometheus-operatorMonitoring kubernetes with prometheus-operator
Monitoring kubernetes with prometheus-operatorLili Cosic
 
Running stateful services in containers - ContainerDays Boston 2016
Running stateful services in containers - ContainerDays Boston 2016Running stateful services in containers - ContainerDays Boston 2016
Running stateful services in containers - ContainerDays Boston 2016Jonas Rosland
 
OpenStack in Enterprise
OpenStack in EnterpriseOpenStack in Enterprise
OpenStack in EnterpriseNalee Jang
 
Load Balancing in the Cloud using Nginx & Kubernetes
Load Balancing in the Cloud using Nginx & KubernetesLoad Balancing in the Cloud using Nginx & Kubernetes
Load Balancing in the Cloud using Nginx & KubernetesLee Calcote
 
Docker for any type of workload and any IT Infrastructure
Docker for any type of workload and any IT InfrastructureDocker for any type of workload and any IT Infrastructure
Docker for any type of workload and any IT InfrastructureDocker, Inc.
 
Docker Orchestration at Production Scale
Docker Orchestration at Production Scale Docker Orchestration at Production Scale
Docker Orchestration at Production Scale Docker, Inc.
 

What's hot (20)

Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
 
SUSE CaaSP: deploy OpenFaaS and Ethereum Blockchain on Kubernetes
SUSE CaaSP: deploy OpenFaaS and Ethereum Blockchain on KubernetesSUSE CaaSP: deploy OpenFaaS and Ethereum Blockchain on Kubernetes
SUSE CaaSP: deploy OpenFaaS and Ethereum Blockchain on Kubernetes
 
Meetup 23 - 01 - The things I wish I would have known before doing OpenStack ...
Meetup 23 - 01 - The things I wish I would have known before doing OpenStack ...Meetup 23 - 01 - The things I wish I would have known before doing OpenStack ...
Meetup 23 - 01 - The things I wish I would have known before doing OpenStack ...
 
Tối ưu hiệu năng đáp ứng các yêu cầu của hệ thống 4G core
Tối ưu hiệu năng đáp ứng các yêu cầu của hệ thống 4G coreTối ưu hiệu năng đáp ứng các yêu cầu của hệ thống 4G core
Tối ưu hiệu năng đáp ứng các yêu cầu của hệ thống 4G core
 
OpenStack Icehouse Overview
OpenStack Icehouse OverviewOpenStack Icehouse Overview
OpenStack Icehouse Overview
 
Docker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup SlidesDocker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup Slides
 
K8s best practices from the field!
K8s best practices from the field!K8s best practices from the field!
K8s best practices from the field!
 
fabric8 ... and Docker, Kubernetes & OpenShift
fabric8 ... and Docker, Kubernetes & OpenShiftfabric8 ... and Docker, Kubernetes & OpenShift
fabric8 ... and Docker, Kubernetes & OpenShift
 
Building Containers: How Many Ways Are Too Many?
Building Containers: How Many Ways Are Too Many?Building Containers: How Many Ways Are Too Many?
Building Containers: How Many Ways Are Too Many?
 
Kubernetes and Istio
Kubernetes and IstioKubernetes and Istio
Kubernetes and Istio
 
Istio canaries and kubernetes
Istio  canaries and kubernetesIstio  canaries and kubernetes
Istio canaries and kubernetes
 
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...
 
Docker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&ADocker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&A
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containers
 
Monitoring kubernetes with prometheus-operator
Monitoring kubernetes with prometheus-operatorMonitoring kubernetes with prometheus-operator
Monitoring kubernetes with prometheus-operator
 
Running stateful services in containers - ContainerDays Boston 2016
Running stateful services in containers - ContainerDays Boston 2016Running stateful services in containers - ContainerDays Boston 2016
Running stateful services in containers - ContainerDays Boston 2016
 
OpenStack in Enterprise
OpenStack in EnterpriseOpenStack in Enterprise
OpenStack in Enterprise
 
Load Balancing in the Cloud using Nginx & Kubernetes
Load Balancing in the Cloud using Nginx & KubernetesLoad Balancing in the Cloud using Nginx & Kubernetes
Load Balancing in the Cloud using Nginx & Kubernetes
 
Docker for any type of workload and any IT Infrastructure
Docker for any type of workload and any IT InfrastructureDocker for any type of workload and any IT Infrastructure
Docker for any type of workload and any IT Infrastructure
 
Docker Orchestration at Production Scale
Docker Orchestration at Production Scale Docker Orchestration at Production Scale
Docker Orchestration at Production Scale
 

Similar to OSDC 2018 | Spicing up VMWare with Ansible and InSpec by Martin Schurz and Sebastian Gumprich

Salt Cloud vmware-orchestration
Salt Cloud vmware-orchestrationSalt Cloud vmware-orchestration
Salt Cloud vmware-orchestrationMo Rawi
 
Lessons On Hyper V
Lessons On Hyper VLessons On Hyper V
Lessons On Hyper VAidan Finn
 
Managing VMware with PowerShell - VMworld 2008
Managing VMware with PowerShell - VMworld 2008Managing VMware with PowerShell - VMworld 2008
Managing VMware with PowerShell - VMworld 2008Carter Shanklin
 
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...POSSCON
 
V Mwarev Storage Intregration
V Mwarev Storage IntregrationV Mwarev Storage Intregration
V Mwarev Storage Intregrationmikhail.mikheev
 
Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...Laurent Domb
 
VMware vCHS, Puppet, and Project Zombie - PuppetConf 2013
VMware vCHS, Puppet, and Project Zombie - PuppetConf 2013VMware vCHS, Puppet, and Project Zombie - PuppetConf 2013
VMware vCHS, Puppet, and Project Zombie - PuppetConf 2013Puppet
 
OpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudOpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudIsaac Christoffersen
 
VMworld 2013: vCloud Powered HPC is Better and Outperforming Physical
VMworld 2013: vCloud Powered HPC is Better and Outperforming PhysicalVMworld 2013: vCloud Powered HPC is Better and Outperforming Physical
VMworld 2013: vCloud Powered HPC is Better and Outperforming PhysicalVMworld
 
A 60-minute tour of AWS Compute (November 2016)
A 60-minute tour of AWS Compute (November 2016)A 60-minute tour of AWS Compute (November 2016)
A 60-minute tour of AWS Compute (November 2016)Julien SIMON
 
Introduction To Managing VMware With PowerShell
Introduction To Managing VMware With PowerShellIntroduction To Managing VMware With PowerShell
Introduction To Managing VMware With PowerShellHal Rottenberg
 
How to build a Citrix infrastructure on AWS
How to build a Citrix infrastructure on AWSHow to build a Citrix infrastructure on AWS
How to build a Citrix infrastructure on AWSDenis Gundarev
 
Node.js kubernetes-cloud all the buzzwords coming together with microsoft azure
Node.js kubernetes-cloud all the buzzwords coming together with microsoft azureNode.js kubernetes-cloud all the buzzwords coming together with microsoft azure
Node.js kubernetes-cloud all the buzzwords coming together with microsoft azurePatriek van Dorp
 
Virtualization and Cloud Computing with Elastic Server On Demand
Virtualization and Cloud Computing with Elastic Server On DemandVirtualization and Cloud Computing with Elastic Server On Demand
Virtualization and Cloud Computing with Elastic Server On DemandYan Pritzker
 
De 03 Introduction To V Cloud Api V1
De 03 Introduction To V Cloud Api V1De 03 Introduction To V Cloud Api V1
De 03 Introduction To V Cloud Api V1ikewu83
 
Ato2019 weave-services-istio
Ato2019 weave-services-istioAto2019 weave-services-istio
Ato2019 weave-services-istioLin Sun
 
Weave Your Microservices with Istio
Weave Your Microservices with IstioWeave Your Microservices with Istio
Weave Your Microservices with IstioAll Things Open
 
All Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istioAll Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istioLin Sun
 
VMworld 2013: The Story Behind Designing and Building a Distributed Automatio...
VMworld 2013: The Story Behind Designing and Building a Distributed Automatio...VMworld 2013: The Story Behind Designing and Building a Distributed Automatio...
VMworld 2013: The Story Behind Designing and Building a Distributed Automatio...VMworld
 

Similar to OSDC 2018 | Spicing up VMWare with Ansible and InSpec by Martin Schurz and Sebastian Gumprich (20)

Salt Cloud vmware-orchestration
Salt Cloud vmware-orchestrationSalt Cloud vmware-orchestration
Salt Cloud vmware-orchestration
 
Lessons On Hyper V
Lessons On Hyper VLessons On Hyper V
Lessons On Hyper V
 
Managing VMware with PowerShell - VMworld 2008
Managing VMware with PowerShell - VMworld 2008Managing VMware with PowerShell - VMworld 2008
Managing VMware with PowerShell - VMworld 2008
 
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
 
V Mwarev Storage Intregration
V Mwarev Storage IntregrationV Mwarev Storage Intregration
V Mwarev Storage Intregration
 
Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...
 
VMware vCHS, Puppet, and Project Zombie - PuppetConf 2013
VMware vCHS, Puppet, and Project Zombie - PuppetConf 2013VMware vCHS, Puppet, and Project Zombie - PuppetConf 2013
VMware vCHS, Puppet, and Project Zombie - PuppetConf 2013
 
OpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudOpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid Cloud
 
VMworld 2013: vCloud Powered HPC is Better and Outperforming Physical
VMworld 2013: vCloud Powered HPC is Better and Outperforming PhysicalVMworld 2013: vCloud Powered HPC is Better and Outperforming Physical
VMworld 2013: vCloud Powered HPC is Better and Outperforming Physical
 
A 60-minute tour of AWS Compute (November 2016)
A 60-minute tour of AWS Compute (November 2016)A 60-minute tour of AWS Compute (November 2016)
A 60-minute tour of AWS Compute (November 2016)
 
Introduction To Managing VMware With PowerShell
Introduction To Managing VMware With PowerShellIntroduction To Managing VMware With PowerShell
Introduction To Managing VMware With PowerShell
 
How to build a Citrix infrastructure on AWS
How to build a Citrix infrastructure on AWSHow to build a Citrix infrastructure on AWS
How to build a Citrix infrastructure on AWS
 
Node.js kubernetes-cloud all the buzzwords coming together with microsoft azure
Node.js kubernetes-cloud all the buzzwords coming together with microsoft azureNode.js kubernetes-cloud all the buzzwords coming together with microsoft azure
Node.js kubernetes-cloud all the buzzwords coming together with microsoft azure
 
Virtualization and Cloud Computing with Elastic Server On Demand
Virtualization and Cloud Computing with Elastic Server On DemandVirtualization and Cloud Computing with Elastic Server On Demand
Virtualization and Cloud Computing with Elastic Server On Demand
 
De 03 Introduction To V Cloud Api V1
De 03 Introduction To V Cloud Api V1De 03 Introduction To V Cloud Api V1
De 03 Introduction To V Cloud Api V1
 
Ato2019 weave-services-istio
Ato2019 weave-services-istioAto2019 weave-services-istio
Ato2019 weave-services-istio
 
Weave Your Microservices with Istio
Weave Your Microservices with IstioWeave Your Microservices with Istio
Weave Your Microservices with Istio
 
All Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istioAll Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istio
 
Handout2o
Handout2oHandout2o
Handout2o
 
VMworld 2013: The Story Behind Designing and Building a Distributed Automatio...
VMworld 2013: The Story Behind Designing and Building a Distributed Automatio...VMworld 2013: The Story Behind Designing and Building a Distributed Automatio...
VMworld 2013: The Story Behind Designing and Building a Distributed Automatio...
 

Recently uploaded

Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Recently uploaded (20)

Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

OSDC 2018 | Spicing up VMWare with Ansible and InSpec by Martin Schurz and Sebastian Gumprich

  • 1. Spicing up VMware with Ansible and InSpec T-Systems Multimedia Solutions GmbH
  • 2. Martin Schurz Sebastian Gumprich T-Systems MMS T-Systems Multimedia Solutions GmbH
  • 3. Ops: the old days (tm) T-Systems Multimedia Solutions GmbH
  • 4. Ops: the old days (tm) T-Systems Multimedia Solutions GmbH
  • 5. Ops: the old days (tm) handcrafted and sometimes arcane con guration clusters parameters for Oracle the "one" server someone installed virtualization is just lift and shift T-Systems Multimedia Solutions GmbH
  • 6. Ops: slowly improving reliance on enterprise tools vSphere / vRealize / vCloud T-Systems Multimedia Solutions GmbH
  • 7. Ops: slowly improving reliance on enterprise tools vSphere / vRealize / vCloud T-Systems Multimedia Solutions GmbH
  • 9. We have a lot of pets, but we need more cattle T-Systems Multimedia Solutions GmbH
  • 10. Mantra: manual work is a bug! T-Systems Multimedia Solutions GmbH
  • 12. Why Ansible? because we don't like Puppet Ansible is simple, agent-less easy to learn straight-forward in task execution Not written in Ruby (looking @ you, Puppet) T-Systems Multimedia Solutions GmbH
  • 13. Ansible - quick rundown T-Systems Multimedia Solutions GmbH
  • 14. Ansible modules - many of them T-Systems Multimedia Solutions GmbH
  • 15. ... except Oracle pet, not cattle. T-Systems Multimedia Solutions GmbH
  • 16. Jenkins incoming already reliable application deployments now reliable con guration of servers, too T-Systems Multimedia Solutions GmbH
  • 17. Automation is fun! ... or so they say ... T-Systems Multimedia Solutions GmbH
  • 18. Automation is fun! ... or so they say ... due to "unfortunate circumstances" we lost half our servers “ “ T-Systems Multimedia Solutions GmbH
  • 19. Automation is fun! ... or so they say ... ... and we did recover easily due to "unfortunate circumstances" we lost half our servers “ “ T-Systems Multimedia Solutions GmbH
  • 20. Automation is fun! ... or so they say ... ... and we did recover easily due to "unfortunate circumstances" we lost half our servers “ “ T-Systems Multimedia Solutions GmbH
  • 21. Managing ESX Hosts Prebuild modules for all basic tasks: Network Storage Cluster vCenter VM tasks T-Systems Multimedia Solutions GmbH
  • 22. Managing ESX Hosts (example) I want to con gure all VLANs for my ESX Cluster All Hosts should have correct VLAN con guration All Hosts should be con gured from one source Adding Hosts and VLANs should be easy (like a distributed vSwitch) T-Systems Multimedia Solutions GmbH
  • 23. Managing ESX Hosts (example) create a host group (e.g. esx-servers ) Add group_vars: vlans: customer1-vlan: tag: 4006 vswitch: vSwitch0 customer2-vlan: tag: 4007 vswitch: vSwitch0 ... T-Systems Multimedia Solutions GmbH
  • 24. Managing ESX Hosts (example) Add a playbook task: - hosts: esx-servers tasks: - name: "Add VLANs" local_action: module: vmware_portgroup hostname: '{{ ansible_hostname }}' username: root password: '{{ esxi_pass }}' switch_name: "{{ item.value.vswitch }}" portgroup_name: "{{ item.key }}" vlan_id: "{{ item.value.tag }}" validate_certs: false with_dict: "{{ vlans }}" T-Systems Multimedia Solutions GmbH
  • 25. Managing ESX Hosts (example) rst Ansible run TASK [Add VLANs] ***************************************** ok: [esx_server] => (item={'value': {u'vswitch': u'vSwitch0', u'tag': 4006}, 'key': u'customer1-vlan'}) changed: [esx_server] => (item={'value': {u'vswitch': u'vSwitch0', u'tag': 4007}, 'key': u'customer2-vlan'}) PLAY RECAP *********************************************** esx_server : ok=1 changed=1 unreachable=0 failed=0 T-Systems Multimedia Solutions GmbH
  • 26. Managing ESX Hosts (example) second Ansible run TASK [Add VLANs] ***************************************** ok: [esx_server] => (item={'value': {u'vswitch': u'vSwitch0', u'tag': 4006}, 'key': u'customer1-vlan'}) ok: [esx_server] => (item={'value': {u'vswitch': u'vSwitch0', u'tag': 4007}, 'key': u'customer2-vlan'}) PLAY RECAP *********************************************** esx_server : ok=1 changed=0 unreachable=0 failed=0 T-Systems Multimedia Solutions GmbH
  • 27. Managing ESX Hosts (example) I want to con gure all VLANs for my ESX Cluster All Hosts should have correct VLAN con g All Hosts should be con gured from one source Adding Hosts and VLANs should be easy (like a distributed vSwitch) T-Systems Multimedia Solutions GmbH
  • 28. Creating VMs - Host variables vm_cpu: 8 vm_ram: 8 vm_storage: srv_live_vmdata1 vm_host: srv-live-vh07 vm_disksize: 80 default_gateway: 172.31.225.1 network_ether_interfaces: - vm_net: srv-lgen-app device: eth0 bootproto: static address: 172.31.225.36 netmask: 255.255.255.128 onboot: "yes" dns1: "{{ srv_dns1 }}" dns2: "{{ srv_dns2 }}" domain: "{{ srv_domain }}" T-Systems Multimedia Solutions GmbH
  • 29. Creating VMs - the Ansible task - name: Create new VM vmware_guest: hostname: "{{ vcenter_host }}" username: "{{ vcenter_user }}" password: "{{ vcenter_pass }}" datacenter: "{{ vcenter_dc }}" name: "{{ item }}" template: "{{ vm_template }}" state: poweredon wait_for_ip_address: yes hardware: memory_mb: "{{hostvars[item]['vm_ram']}}" num_cpus: "{{hostvars[item]['vm_cpu']}}" disk: - size_gb: "{{hostvars[item]['vm_disksize']}}" datastore: "{{hostvars[item]['vm_storage']}}" T-Systems Multimedia Solutions GmbH
  • 30. Adding Security to the mix Telekom security guideline requires all servers to be hardened also VMware security guideline: https://www.vmware.com/security/hardening- guides.html (beware Excel!) T-Systems Multimedia Solutions GmbH
  • 31. Hardening an ESX host (example) VMware Requirement: Guideline ID: ESXi.disable-mob: The managed object browser (MOB) provides a way to explore the object model used by the VMkernel to manage the host; it enables con gurations to be changed as well. This interface is meant to be used primarily for debugging the vSphere SDK. In Sphere 6.0 this is disabled by default T-Systems Multimedia Solutions GmbH
  • 32. Hardening an ESX host (example) Ansible implementation: # Guideline ID: ESXi.disable-mob - name: get | disable MOB shell: "vim-cmd hostsvc/advopt/view Config.HostAgent.plugins.solo.enableMob | grep value | cut -d ' ' -f 9" register: mob_status changed_when: mob_status.rc > 0 - name: set | disable MOB shell: "vim-cmd hostsvc/advopt/update Config.HostAgent.plugins.solo.enableMob bool {{ mob }}" when: mob not in mob_status.stdout T-Systems Multimedia Solutions GmbH
  • 33. Hardening VMs - nding them all! - name: Find all .vmx files on local store shell: | find /vmfs/volumes/datastore/ -name *.vmx register: found_vms changed_when: False T-Systems Multimedia Solutions GmbH
  • 34. Hardening VMs - changing them - name: Set VM parameters lineinfile: path: "{{ item[1] }}" regexp: "{{ item[0].key }}" backrefs: yes line: "{{ item[0].key }} = "{{ item[0].value }}"" with_nested: - "{{ parameters_add }}" - "{{ found_vms }}" parameters_add: - { key: isolation.tools.copy.disable, value: TRUE } - { key: isolation.tools.paste.disable, value: TRUE } T-Systems Multimedia Solutions GmbH
  • 35. Managing VMs - deleting them - name: delete VM vmware_guest: vcenter_hostname: "{{ vcenter_host }}" username: "{{ vcenter_user }}" password: "{{ vcenter_pass }}" validate_certs: false guest: "{{ item }}" force: true state: absent # deletion! with_items: "{{ vm_name }}" T-Systems Multimedia Solutions GmbH
  • 36. Managing VMs - making snapshots - name: Create snapshot of {{vm_name}} vmware_guest_snapshot: folder: "/vm/" name: "{{ vm_name }}" state: present snapshot_name: "snap_{{ '%Y-%m-%d-%M' | strftime }}" T-Systems Multimedia Solutions GmbH
  • 37. Not everything out of the box moving VMs not implemented in Ansible :( but Ansible is extensible with Python code so just write your own module VMware vSphere API Bindings for Python (https://github.com/vmware/pyvmomi) VMware API Docs Python + API = T-Systems Multimedia Solutions GmbH
  • 38. Not everything out of the box we started with Ansible code: - name: Move VM to target host and DS delegate_to: localhost vm_move: vc_host: "{{ vcenter_host }}" vc_pass: "{{ vcenter_pass }}" vc_user: "{{ vcenter_user }}" vm_name: "{{ inventory_hostname }}" ds_name: "{{ vm_storage }}" esx_host: "{{ vm_host }}" T-Systems Multimedia Solutions GmbH
  • 39. Not everything out of the box then think about implementation what needs to be done: Locate the VM we want to move T-Systems Multimedia Solutions GmbH
  • 40. Not everything out of the box then think about implementation what needs to be done: Locate the VM we want to move Locate the target ESX host / storage T-Systems Multimedia Solutions GmbH
  • 41. Not everything out of the box then think about implementation what needs to be done: Locate the VM we want to move Locate the target ESX host / storage check what needs to be changed T-Systems Multimedia Solutions GmbH
  • 42. Not everything out of the box then think about implementation what needs to be done: Locate the VM we want to move Locate the target ESX host / storage check what needs to be changed move the VM T-Systems Multimedia Solutions GmbH
  • 43. Not everything out of the box some boilerplate is needed: def main(): module = AnsibleModule( argument_spec=dict( vc_host = dict(required=True, type='str'), ... esx_host = dict(required=False, type='str'), ), ) result = dict( changed=False, original_message='', message='' ) # do something module.exit_json(**result) T-Systems Multimedia Solutions GmbH
  • 44. Not everything out of the box vm = get_obj(content, [vim.VirtualMachine], vm_name) vm_datastore = get_obj(content, [vim.Datastore], ds_name) dest_host = get_obj(content, [vim.HostSystem], esx_host) vm_relocate_spec = vim.vm.RelocateSpec() T-Systems Multimedia Solutions GmbH
  • 45. Not everything out of the box vm = get_obj(content, [vim.VirtualMachine], vm_name) vm_datastore = get_obj(content, [vim.Datastore], ds_name) dest_host = get_obj(content, [vim.HostSystem], esx_host) vm_relocate_spec = vim.vm.RelocateSpec() if vm.datastore[0] != vm_datastore: result['changed'] = True vm_relocate_spec.datastore = vm_datastore T-Systems Multimedia Solutions GmbH
  • 46. Not everything out of the box vm = get_obj(content, [vim.VirtualMachine], vm_name) vm_datastore = get_obj(content, [vim.Datastore], ds_name) dest_host = get_obj(content, [vim.HostSystem], esx_host) vm_relocate_spec = vim.vm.RelocateSpec() if vm.datastore[0] != vm_datastore: result['changed'] = True vm_relocate_spec.datastore = vm_datastore if vm.runtime.host != dest_host: result['changed'] = True vm_relocate_spec.host = dest_host T-Systems Multimedia Solutions GmbH
  • 47. Not everything out of the box vm = get_obj(content, [vim.VirtualMachine], vm_name) vm_datastore = get_obj(content, [vim.Datastore], ds_name) dest_host = get_obj(content, [vim.HostSystem], esx_host) vm_relocate_spec = vim.vm.RelocateSpec() if vm.datastore[0] != vm_datastore: result['changed'] = True vm_relocate_spec.datastore = vm_datastore if vm.runtime.host != dest_host: result['changed'] = True vm_relocate_spec.host = dest_host if result['changed']: task = vm.Relocate(spec=vm_relocate_spec) wait_for_task(module, task, si) T-Systems Multimedia Solutions GmbH
  • 48. Not everything out of the box VMWare has a tool called govc https://github.com/vmware/govmomi/tree/mast er/govc pretty easy to use from the command line this can also be included in Ansible scripts but do I really need to write all this python code? I'm not a programmer! “ “ T-Systems Multimedia Solutions GmbH
  • 50. Testing with inSpec written by Chef guys originally a fork of serverspec diverged since then and has gotten many new features T-Systems Multimedia Solutions GmbH
  • 51. Testing with inSpec - the test control 'VM.disable-console-drag-n-drop' do title 'Explicitly disable copy/paste operations' vsphere.datacenters.each { |dc| dc.vms.each { |vm| describe vm_advancedsetting) do its(['isolation.tools.dnd.disable']) { should eq true } end } } end T-Systems Multimedia Solutions GmbH
  • 52. Testing with inSpec - results VM.disable-console-drag-n-drop isolation.tools.dnd.disable should eq true Profile Summary: 136 successful controls, 0 failures Test Summary: 136 successful, 0 failures, 0 skipped T-Systems Multimedia Solutions GmbH
  • 53. Bonus - ansible-cmdb T-Systems Multimedia Solutions GmbH
  • 54. The End Now grab some food! T-Systems Multimedia Solutions GmbH
  • 55. Ansible logo from redbubble.com VMWare logo from fujitsu InSpec logo from sdtimes Fry from ickr user liliana_von_k success kid from instagram user laneymg automate from ickr user Amber Case Ansible works image from tutorialspoint.com T-Systems Multimedia Solutions GmbH