Collecting LOG Files from a Windows 10 Server using an Ansible Playbook on Ubuntu 20.04 (Local Control Node)
In this article, we will discuss how to collect LOG files from a Windows 10 server using an Ansible playbook on an Ubuntu 20.04 server, which will act as the local control node. We will cover the key concepts of Ansible, the Windows collection, and the win\_gather\_facts module. By the end of this article, you will have a good understanding of how to use Ansible to collect LOG files from a Windows 10 server.
What is Ansible?
Ansible is an open-source automation tool that is used to automate IT infrastructure tasks. It is an agentless tool, meaning that it does not require any software to be installed on the target servers. Ansible uses a simple and human-readable language called YAML to define the tasks that need to be executed. These tasks are defined in playbooks, which are just text files that can be edited using any text editor.
The Windows Collection
The Windows collection is a set of Ansible modules that are designed to work with Windows servers. These modules provide a way to manage Windows servers using Ansible. The Windows collection includes modules for managing Windows services, files, registry keys, and much more.
The win\_gather\_facts Module
The win\_gather\_facts module is a module that is used to gather facts about a Windows server. Facts are pieces of information about the server, such as the operating system version, the amount of memory, and the IP address. The win\_gather\_facts module can be used to gather facts about a Windows server and store them in a variable that can be used in a playbook. This module is part of the Windows collection.
Collecting LOG Files from a Windows 10 Server
To collect LOG files from a Windows 10 server using an Ansible playbook on an Ubuntu 20.04 server, we need to follow these steps:
- Install Ansible on the Ubuntu 20.04 server.
- Install the Windows collection on the Ubuntu 20.04 server.
- Create an inventory file that contains the IP address of the Windows 10 server.
- Create a playbook that uses the win\_gather\_facts module to gather facts about the Windows 10 server.
- Create a playbook that uses the win\_copy module to copy the LOG files from the Windows 10 server to the Ubuntu 20.04 server.
Step 1: Installing Ansible on the Ubuntu 20.04 Server
To install Ansible on the Ubuntu 20.04 server, we need to run the following command:
sudo apt-add-repository ppa:ansible/ansible
sudo apt update
sudo apt install ansible
Step 2: Installing the Windows Collection on the Ubuntu 20.04 Server
To install the Windows collection on the Ubuntu 20.04 server, we need to run the following command:
ansible-galaxy collection install ansible.windows
Step 3: Creating an Inventory File
To create an inventory file, we need to create a text file with the following content:
[windows]
192.168.1.100
Replace 192.168.1.100 with the IP address of the Windows 10 server.
Step 4: Creating a Playbook to Gather Facts
To create a playbook that uses the win\_gather\_facts module to gather facts about the Windows 10 server, we need to create a text file with the following content:
---
- name: Gather facts
hosts: windows
gather\_facts: yes
Step 5: Creating a Playbook to Copy LOG Files
To create a playbook that uses the win\_copy module to copy the LOG files from the Windows 10 server to the Ubuntu 20.04 server, we need to create a text file with the following content:
---
- name: Copy LOG files
hosts: windows
tasks:
- name: Copy LOG files
win\_copy:
src: C:\LOG\*.log
dest: /tmp/LOG/
In this article, we have discussed how to collect LOG files from a Windows 10 server using an Ansible playbook on an Ubuntu 20.04 server. We have covered the key concepts of Ansible, the Windows collection, and the win\_gather\_facts module. We have also discussed the steps that are required to collect LOG files from a Windows 10 server.