DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Related

  • Install Arch Linux on Windows 10 Hyper-V
  • KubeVirt: Can VM Management With Kubernetes Work?
  • Ansible and the Pre-Container Arts
  • Introduction to KVM, SR-IOV, and Exploring the Advantages of SR-IOV in KVM Environments

Trending

  • Zero-Latency Architecture: Database Triggers + Serverless Functions for Modern Reactive Architectures
  • RAG vs. CAG: A Deep Dive into Context-Aware AI Generation Techniques
  • 8 Steps to Proactively Handle PostgreSQL Database Disaster Recovery
  • Evaluating Similariy Digests: A Study of TLSH, ssdeep, and sdhash Against Common File Modifications
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Running Ansible From Windows Using Virtualization

Running Ansible From Windows Using Virtualization

In this article, the reader will learn how to run Ansible playbooks virtually from Linux using the native Windows 10 Hypervisor.

By 
Jan-Rudolph Bührmann user avatar
Jan-Rudolph Bührmann
·
Sep. 06, 23 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
5.9K Views

Join the DZone community and get the full member experience.

Join For Free

Recently, I had to use Ansible to implement infrastructure as code. Initially, I used Windows Subsystem for Linux (WSL) to run the Ansible playbooks. The advantage of WSL is that it gives one a Linux shell on a Windows machine without any further ado. However, I found that WSL has this tendency to go haywire and use system resources such as CPU and RAM to the max. Although it did not lead to performance degradation in other running processes or applications, it did cause my notebook with 40GB of RAM to become very hot and use excessive electricity. Once WSL reaches this state, all new requests for a WSL prompt hang. Since the virtual memory processes used to enable WSL are protected and cannot be killed or restarted, the only recourse is a good old Windows reboot.  

I considered installing Linux on an old notebook and running the Ansible playbooks from there. Unfortunately, the target servers are behind a VPN, so the Linux machine would have to receive special software to allow it to join the VPN. In order to sidestep corporate hassle, I went with running Linux virtually on Hyper-V, the native Windows 10 Hypervisor. The steps I followed will be documented next.

How To Break Free

I started by opening Hyper-V:

I started by opening Hyper-V

Right click on your machine name (S2C-MASTER for me) -> New -> Virtual Machine:

Right click on your machine name (S2C-MASTER for me) -> New -> Virtual Machine

Give the new virtual machine a name:

Give the new virtual machine a name

I selected "Generation 1":

I selected "Generation 1"

I gave it 8000MB:

I gave it 8000MB

I selected the "Default Switch". This NAT-based switch allows the virtual machine to share the host machine's networking. The benefit of this is access to any VPN or other virtual machines the host adaptor can access. However, it comes with a slight performance penalty. Should your PC have a spare ethernet adaptor and VPN access is not required, it is also possible to configure a dedicated adaptor for the new virtual machine's exclusive use. This can be done from the "Virtual Switch" menu on the right panel of the Hyper-V GUI.

I selected the "Default Switch"

After selecting the default op to create a virtual hard disk, one has to specify the ISO Linux image to boot up. You can use your favorite distro, but it is advisable to use a server edition that ships without a front-end manager. Why use a GUI when a shell and vi will do?

one has to specify the ISO Linux image to boot up

Click finish. Although the virtual machine will be created at this point, it is advisable to add more processors to it:

Click finish

Although the virtual machine will be created at this point, it is advisable to add more processors to it

The virtual machine is ready for first-time boot. Right-click on the machine and then click on Connect:

Right-click on the machine and then click on Connect

Click start, and you can configure your new Linux box that runs inside Windows:

Click start, and you can configure your new Linux box that runs inside Windows

All that remains is to install Ansible using your distro's package manager:

sudo apt install ansible

The Ansible-playbook command should now be available:

ansible-playbook install_private_k8s_cloud.yml

Conclusion

It works like a dream. I am free from using secondary machines, can access the corporate VPN, and can finally put my notebook's unused RAM to more efficient use far away from Windows. It is, after all, always more fun to Bash way instead of using clunky PowerShell or emaciated DOS. 

In a follow-up posting, I will explain how this approach can be used to boot Kubernetes on one's own infrastructure.

Hyper-V Ansible (software) Linux (operating system) Virtual Machine Virtualization

Opinions expressed by DZone contributors are their own.

Related

  • Install Arch Linux on Windows 10 Hyper-V
  • KubeVirt: Can VM Management With Kubernetes Work?
  • Ansible and the Pre-Container Arts
  • Introduction to KVM, SR-IOV, and Exploring the Advantages of SR-IOV in KVM Environments

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: