A repository for Ansible playbook that gathers Windows facts using the Ansible setup module. Creates the following output using the facts:
- RAW JSON
- RAW YAML
- Formatted CSV (select fields)
- Formated Markdown (select fields)
- Interactive HTML Mind Map (select fields)
Copywrite John Capobianco July 25,2020
Both Windows and Linux require jmespath - please pip install this first
pip install jmespath
These playbooks have been developed and tested under Ansble 2.9.1 on CentOS 7.8.2003
You will require Git, Ansible, Node.js 12, Mark Map, WinRM, and Kerberos on your Linux / Ansible host.
Your Windows host targets need to have WinRM installed.
The playbook uses WinRM over HTTP and authenticates using Kerberos (domain credentials).
Windows Hosts Requirements for Ansible - https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html#host-requirements
Windows Remote Management - https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html
Using Ansible and Windows - https://docs.ansible.com/ansible/latest/user_guide/windows_usage.html
Ansible Setup - Gather Facts - https://docs.ansible.com/ansible/latest/modules/setup_module.html
This playbook assumes the Windows target has WinRM installed and listening on 5985 and that the Ansible host is configured correctly and can reach the target Windows host via this HTTP port.
It is very important when prompted for your username that you use [email protected]. This whole string is case sensitive and the domain portion must be in upper case.
- Update yum
$ sudo yum -y update
- Install Ansible
$ sudo yum install epel-release $ sudo yum install ansible
- Install node.js 12
$ curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash - $ sudo yum install -y gcc-c++ make $ sudo yum install -y nodejs
- Install Mark Map
$ npm install markmap-lib -g
- Install WinRM
pip install "pywinrm>=0.3.0"
- Install Kerberos
yum -y install python-devel krb5-devel krb5-libs krb5-workstation
- Install the Python WinRM Kerberos wrapper
pip install pywinrm[kerberos]
- Update Ubuntu - this step will take some time.
$ sudo apt update $ sudo apt-get upgrade -y
- Make sure Python is installed.
$ sudo apt-get install python -y
- Install Ansible.
$ sudo apt-add-repository ppa:ansible/ansible $ sudo apt-get update $ sudo apt-get install ansible -y
- Install node.js
$ sudo apt install npm
- Install Mark Map
$ npm install markmap-lib -g
- Install WinRM
apt-get install -y python3-winrm
- Install Kerberos
sudo apt-get install python-dev libkrb5-dev krb5-user
- Install the Python WinRM Kerberos wrapper
pip install pywinrm[kerberos]
These playbooks require the Windows Subsystems for Linux and the Ubuntu OS from the Microsoft Store. Aside from this requirement, the Linux prequisites similarly apply to Windows 10.
- Right-click the Windows Start icon - select Apps and Features.
- In the Apps and Features window - click Programs and Features under Related Settings on the right side of Apps and Features.
- Click Turn Windows Features On or Off in the left (with the shield icon) side of the Programs and Features window.
- Scroll to bottom of the Features window and put a check mark beside Windows Subsytem for Linux; Click Ok and close the open windows.
- Launch the Microsoft Store.
- Search for Ubuntu - click the first result.
- Click Install.
-
Wait for Ubuntu to install.
-
Press Windows Key and start typing Ubuntu - click and launch Ubuntu.
-
The first time Ubuntu launches it has to setup - give this some time.
-
Enter your username and password for Ubuntu.
-
Update Ubuntu - this step will take some time.
$ sudo apt update
$ sudo apt-get upgrade -y
- Make sure Python is installed.
$ sudo apt-get install python -y
- Install Ansible.
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible -y
- Install node.js.
$ sudo apt install npm
- Install Mark Map.
$ sudo npm install markmap-lib -g
- Install WinRM
apt-get install -y python3-winrm
- Install Kerberos
sudo apt-get install python-dev libkrb5-dev krb5-user
- Install the Python WinRM Kerberos wrapper
pip install pywinrm[kerberos]
-
git clone https://github.com/automateyournetwork/WindowsFacts.git
-
Modify the permissions
chmod -R 755 /home/"username"/WindowsFacts
- Ubuntu Bug fix
To work around a bug that prevents the Ansible playbook from running on certain versions of Ubuntu please run the following:
sudo mv /usr/bin/sleep /usr/bin/sleep.dist sudo ln -s /bin/true /usr/bin/sleep
- Update your hosts file and include the Windows hostname under [WINDOWS]. If FQDN is required for the Ansible Linux host please use the FQDN.
[WINDOWS]
yourhost.your.domain.com
- cd WindowsFacts/playbooks
ansible-playbook WindowsFacts.yml
Provide your domain [email protected]
EXTREMELY_IMPORTANT_NOTE
The username above is case sensitive and must include the @YOUR.DOMAIN.COM or the kerberos token will be invalid and the playbook will fail.
Provide your domain password.
The playbook will run.
Provide a Git Commit Message.
Provide your Git repository username.
Provide your Git repository password.
ansible-playbook WindowsFacts.yml --limit
Provide your domain [email protected]
EXTREMELY_IMPORTANT_NOTE
The username above is case sensitive and must include the @YOUR.DOMAIN.COM or the kerberos token will be invalid and the playbook will fail.
Provide your domain password.
The playbook will run.
Provide a Git Commit Message.
Provide your Git repository username.
Provide your Git repository password.
The Reports are stored in documentation/servers/WINDOWS/.
/csv
Contains comma separated format. Fully searchable / sortable / filterable.
/json
Contains the RAW JSON from the Ansible Facts.
/markdown
Contains mark down format.
/mindmaps
Contains HTML mind maps best viewed in Google Chrome.
/yaml
Contains the RAW YAML from the Ansible Facts.