Manage windows machine from Ansible
Posted By : Vishnu Gaur | 29-Sep-2017
Overview of Ansible:
Ansible is open source and is easy to setup. Ansible can help you with configuration, task automate, application deployment. we can handle complex tasks with a tool which is simple to use.
Puppet or Chef use an agent on the remote host but ansible is agentless. Instead of agent, Ansible uses SSH which has to installed on all the systems you want to manage. The remote host also installed python because Ansible is written in Python. There is no server-client architecture require for Ansible.If we want to do something related with git then the remote host must be installed git. Ansible works on push mechanism.
Ansible is free but Ansible tower is paid.
Managing windows based instance is not easy for system admin and DevOps engineer.
Steps for managing Windows-based Instance:
1. Launch windows 7/8 OS or windows 2008 / 2012 / 2016 server
Requirement :
Administrator OR Admin power user
PowerShell 4 or later version
Firewall Off or allow tcp/udp port 5985
setup parameter
Setting parameter .
there are two types of method .
i) Kerberos based
ii) Plaintext based method
Note : Setting kerberos is not easy for everyone so we are using Open CMD and set two things given below.
winrm quickconfig
press y to start winrm
Nowt check on cmd some variables
winrm get winrm/config/service
# Note set windows Auth and allowunecrypted parameter
. winrm set winrm/config/service/Auth @{Basic="true"}
. winrm set winrm/config/service @{AllowUnencrypted="true"}
Note: Make allow rule in firewall for 5985 tcp/udp or turn firewall.
Finally, making inventory file for Windows:
[root@vishnu Desktop]# vim /etc/ansible/hosts
[windows]
192.168.10.222
[windows:vars]
ansible_ssh_user=vishnu
ansible_ssh_pass=123
ansible_ssh_port=5985
ansible_winrm_server_cert_validation=ignore
ansible_connection=winrm
To test use win_ping module
root@vishnu:~# ansible all -i /etc/ansible/windowsinventory -m win_ping
ok | SUCCESS => {
"changed": false,
"ping": "pong"
}
Installation of ansible in linux
Install some software properties
sudo apt-get update && sudo apt-get install software-properties-common.
Add repository for ubuntu
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
Installtion on redhat/centos
yum install ansible
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Vishnu Gaur
Vishnu Gaur Is DevOps Engineer in oodles technologies, He is a certified Engineer. His hobbies are reading Books and exploring New places