DevOps KT

icon picker
Ansible

SO
Security Operations
Last edited 322 days ago by Ram Kumar

Ansible Setup

Install WinRm using Powershell
Using the script
Before running Ansible playbook to application server
Windows Installation
Verify PowerShell, .NET and set up WinRM
1. verify PowerShell version
Get-Host | Select-Object Version
2. verify .NET version
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse | Get-ItemProperty -Name version -EA 0 | Where { $_.PSChildName -Match '^(?!S)\p{L}'} | Select PSChildName, version

3. Verify WinRM not-configured
winrm get winrm/config/Service
4. Setup WinRM
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$url = "https://raw.githubusercontent.com/ansible/ansible-documentation/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
$file = "$env:temp\ConfigureRemotingForAnsible.ps1"
(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
powershell.exe -ExecutionPolicy ByPass -File $file
5. Verify WinRM configured
winrm get winrm/config/Service
6. WinRM Listener
The WinRM services listens for requests on one or more ports. Each of these ports must have a listener created and configured. To view the current listeners that are running on the WinRM service, run the following command:
winrm enumerate winrm/config/Listener

Inventory file - inventory.yml
[Sprint-ETT]
172.30.12.176

[Sprint-ETT:vars]
ansible_user=lakshan-a
ansible_password=xxxx
ansible_port=5986
ansible_connection=winrm
ansible_winrm_transport=ntlm
ansible_winrm_server_cert_validation=ignore
pasted image 0.png
After setup inventory to test with the server using Ansible playbook
pasted image 0.png
To run ansible playbook use this command
ansible-playbook -i inventory ping.yaml
IIS.yaml
Checking the Windows roles and features on the list
pasted image 0.png
Installing Windown roles and features using Ansible Playbook
pasted image 0.png
IISSites.yaml
Adding IIS sites using Ansible playbook
Installing IIS sties using Ansible Playbook
pasted image 0.png
Install Softwares using Ansible Playbook
playbooksoftware.yaml
pasted image 0.png
To configure Ansible with Deployment Server
Create a Folder Structure for the Ansible Server.
mkdir Ansible
cd Ansible
pwd
/home/ubuntu/Ansible
image.png

Then Go to the Ansible Folder
Create a folder ETT and its subfolder to create Sprint,Stage,UAT,SBX,Prod
mkdir ETT
cd ETT
mkdir Sprint, Stage, UAT, SBX, Prod
image.png
goto the Sprint folder and create inventory file
vi inventory
[ETT]
172.30.61.27
image.png

Then create ansible.cfg file in that folder
vi ansible.cfg
[defaults]
inventory = ./inventory
roles_path = ./roles

Then create group_vars folder then create ‘all’ file inside that folder
mkdir group_vars
cd group_vars
vi all
ansible_user: lakshan-a
ansible_password: a306&6A0pa9n
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_scheme: https
ansible_winrm_server_cert_validation: ignore
ansible_winrm_transport: ntlm

#Nexus
nexus_username: devopsnexus
nexus_password: Admin1234
base_dir: 'D:\ETT-Application'
backup: 'D:\ETT-ApplicationBackup'
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.