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 are you handling the data revolution? We want your take on what's real, what's hype, and what's next in the world of data engineering.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

SBOMs are essential to circumventing software supply chain attacks, and they provide visibility into various software components.

Related

  • Streamlining Event Data in Event-Driven Ansible
  • Clean Up Event Data in Ansible Event-Driven Automation
  • Monitoring journald Logs With Event-Driven Ansible
  • Simulating Events in Ansible EDA: A Practical Use Case of ansible.eda.generic

Trending

  • Distributed Rate Limiting in Java: A Deep Dive into Bucket4j + PostgreSQL
  • When Agile Teams Fake Progress: The Hidden Danger of Status Over Substance
  • Advanced Argo Rollouts With Datadog Metrics for Progressive Delivery
  • Java Stream API: 3 Things Every Developer Should Know About
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Ansible Galaxy: Ping Windows Servers

Ansible Galaxy: Ping Windows Servers

In this quick tutorial, we learn how to ping a Windows server, in order to check if the host is reachable and we are indeed connected.

By 
Manoj Kumar user avatar
Manoj Kumar
·
Apr. 08, 17 · Tutorial
Likes (0)
Comment
Save
Tweet
Share
8.3K Views

Join the DZone community and get the full member experience.

Join For Free

This article shows how you can ping Windows Servers (2008 and 2012) using Ansible Galaxy. You may hook up any plays or windows modules which I will demonstrate in future articles.

Prerequisites:

- Ansible installed Linux Controller (I am using Ubuntu 16).

- Windows Server 2008 (180-day trial virtual machine using  VMWare Player).

- Windows Server 2012 (180-day trial virtual machine using  VMWare Player).

Step 1. In our Ansible controller create a directory named "winservers."

Image title

Step 2. Open the Terminal window and browse to the newly created folder "winservers."

Step 3. Create an inventory file (hosts) under  /winservers/ with server the following information:

[winservers]
192.168.152.132
192.168.152.133

[winservers:vars]
ansible_ssh_user=administrator
ansible_ssh_pass=P@ssword1234
ansible_ssh_port=5985
ansible_connection=winrm

Here:

[winservers] is our group of Windows Servers.

[winservers-vars] contains the ssh access information for both the servers. Both the servers have been configured to have a user named 'Administrator' and the same password.

We are using winrm to connect to the servers.

Step 4. The Configuration file.

Since we are not using the default hosts file (/etc/ansible/hosts), we need to instruct Ansible to use the new hosts file that we created in step3.

Create a new file named ansible.cfg and use the following as it's content:

[defaults]
inventory = /home/mbalotia/AnsiblePrac/winservers/hosts

Step 5. We will create a galaxy named "ping."

Command: ansible-galaxy init ping  

 mbalotia@mbalotia-controller:~/AnsiblePrac/winservers$ ansible-galaxy init ping

- ping was created successfully

This command creates our galaxy under  /winservers/ping with the following structure:

Image title

Please note ping is our new role, we will now create a task to ping our Windows Servers.

Step 6. Edit /ping/tasks/main.yml and replace its content with the following:

---
# This uses the win_ping module to test connectivity to Windows hosts
- name: Ping All windows servers 
   win_ping:

We are going to use the win_ping module for this.

Step 7. Create a playbook named pingservers.yml under /winservers/ with the following content:

---
- hosts: all
   roles:
   - { role: "ping" }

Quick explanation of the above code:

Hosts: all (targets all the servers in our inventory).

Roles: lists all the roles that we want to execute, in our case there is only one role named "ping."

Our final directory structure for /winservers looks like:

Image title


Step 8. Finally, run the playbook by typing:

 ansible-playbook pingservers.yml 
Image title

Congratulations! You are now able to ping your windows servers using Ansible Galaxy!

Ansible (software) Galaxy (computational biology)

Opinions expressed by DZone contributors are their own.

Related

  • Streamlining Event Data in Event-Driven Ansible
  • Clean Up Event Data in Ansible Event-Driven Automation
  • Monitoring journald Logs With Event-Driven Ansible
  • Simulating Events in Ansible EDA: A Practical Use Case of ansible.eda.generic

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: