Skip to content

Instantly share code, notes, and snippets.

View Akasurde's full-sized avatar
🌏
To the infinity and beyond

Abhijeet Kasurde Akasurde

🌏
To the infinity and beyond
View GitHub Profile
@Akasurde
Akasurde / vcenter_connect.py
Created July 22, 2019 07:06
Vmware test code
from pyVim.connect import SmartConnect, Disconnect
import ssl
import atexit
from pyVmomi import vim, vmodl
def connect(hostname, username, password):
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_NONE
si = SmartConnect(host=hostname,
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2020, Abhijeet Kasurde <[email protected]>
# Copyright: (c) 2020, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {
for i in `cat user.txt`
do
user=`echo $i | awk -F ":" '{print $1}'`
password=`echo $i | awk -F ":" '{print $2}'`
echo "Changing password for ${user}"
echo "${password}" | passwd --stdin ${user}
if [ $? -eq 0 ]; then
echo "Password changed for ${user}"
else
echo "Failed to change password for ${user}"
@Akasurde
Akasurde / ansible_migrate.py
Created April 2, 2020 10:48
Python script to help with migrating issues and PRs from ansible/ansible to a target collection. Original Script - https://gist.github.com/jborean93/1a060f4c7c17bbecd94cc1597e580b54
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# PYTHON_ARGCOMPLETE_OK
# Copyright: (c) 2020, Jordan Borean (@jborean93) <[email protected]>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
"""
Script that can be used to copy issues and PRs from the Ansible GitHub repo to it's target collection repo. Current
limitations are;
@Akasurde
Akasurde / main.yml
Created April 29, 2020 12:21
Reuse tag manager
---
- hosts: localhost
tasks:
- include_tasks: vmware_tag_manager.yml
vars:
vcenter_hostname: 'vc1.test.com'
vcenter_password: 'password'
vcenter_username: '[email protected]'
object_name: 'Cluster1'
object_type: ClusterComputeResource
@Akasurde
Akasurde / vcsa-kvm.yml
Created July 20, 2020 08:21 — forked from infernix/vcsa-kvm.yml
Create a VMware VCSA appliance under KVM with libvirt and ansible
---
- name: Generate a KVM enabled VMWare VCSA VM under libvirt
hosts: 127.0.0.1
connection: local
vars:
- reqpkgs_apt:
- bsdtar
- libguestfs-tools
- qemu-utils
- virtinst
@Akasurde
Akasurde / main.yml
Created October 6, 2020 05:45
Automate CentOS 7 installation using Kickstart and vmware_guest module
---
- hosts: localhost
gather_facts: no
vars_files:
- vcenter_vars.yml
vars:
hostname: kickstart_vm
tasks:
- name: Boot VM with CentOS 7 installation iso in CDROM
vmware_guest:
@Akasurde
Akasurde / enable_ssh_service.yml
Created October 6, 2020 06:28
Enable SSH service on the given ESXi host system
- name: Start SSH service setting for an ESXi Host in given Cluster
vmware_host_service_manager:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
esxi_hostname: esxi_name
service_name: TSM-SSH
state: present
@Akasurde
Akasurde / gist.xml
Created October 13, 2020 10:29
First Logon commands in Autounattended.xml
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<CommandLine>powershell -ExecutionPolicy ByPass Invoke-Expression (Invoke-WebRequest -Uri http://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1)</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>2</Order>
<CommandLine>powerShell "Invoke-WebRequest -Uri http://packages.vmware.com/tools/esx/6.7u2/windows/x64/VMware-tools-10.3.5-10430147-x86_64.exe -OutFile C:\Windows\temp\VMware-tools-10.3.5-10430147-x86_64.exe"</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
@Akasurde
Akasurde / main.yml
Last active October 24, 2021 18:31
A playbook to create a Windows VM in vCenter environment
---
- hosts: localhost
vars_files:
- vcenter_vars.yml
tasks:
- name: Create a Windows VM
vmware_guest:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'