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
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
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

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Install Arch Linux on Windows 10 Hyper-V
  • CPU Optimization in Virtual Environment
  • Java and Low Latency
  • Getting Started With Windows Containers

Trending

  • Leveraging FastAPI for Building Secure and High-Performance Banking APIs
  • Top 7 Best Practices DevSecOps Team Must Implement in the CI/CD Process
  • Creating a Deep vs. Shallow Copy of an Object in Java
  • Software Verification and Validation With Simple Examples
  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.

Jan-Rudolph Bührmann user avatar by
Jan-Rudolph Bührmann
·
Sep. 06, 23 · Tutorial
Like (1)
Save
Tweet
Share
3.41K 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
  • CPU Optimization in Virtual Environment
  • Java and Low Latency
  • Getting Started With Windows Containers

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: