Manually I have created the VM’s but we can also create them from Terraform/ARM templates/Azure Biceps/PowerShell CLI
So, as part of ansible installation python needs to be installed before installing ansible on Ansible Control Node (ACN) and should also be present on all the nodes where we’ll connect and install the applications
Remember, we only need to install Ansible on Ansible Control Node (ACN)
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible -y
Confirm if the ansible is installed on ubuntu
Now, let’s try to connect the windows server from our local machine
Now, we are connected to windows-VM let’s start the elevated powershell and run few commands
Here’s the link to download/install script to enable WinRM on Windows-VM
Next, check the screenshots for further steps on powershell
Now, we also need to verify if python is pre-installed on Windows-VM
So, as we can see that python is not installed on Windows-VM, so we need to install chocolatey and then we need to install python using chocolatey
Get-ExecutionPolicy
is not Restricted in order to execute external commands. RemoteSigned
or AllSigned
are quite a bit more enhanced security
Get-ExecutionPolicy
restricted
, then we can change it to RemoteSigned
or AllSigned
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
If you don’t see any errors, you are ready to use Chocolatey! Type choco
or choco -?
Next step is to restart the windows server to get the installations effects
choco install python --pre
python --version
[win]
<Windows-Server Public/Private IP-Address> or <Public/Private IP DNS name>
#ip-172-31-44-2.eu-west-2.compute.internal
[win:vars]
ansible_user=Administrator
ansible_password="<Windows Server Password to login"
ansible_port=5986
ansible_connection=winrm
ansible_winrm_scheme=https
ansible_winrm_server_cert_validation=ignore
/#ansible_become_method=yes
ansible -i hosts.ini win -m win_ping
Okay, since everything seems promising, so let’s try to run some sample scripts and also these sample scripts will be available in GitHub for your future references
ansible-playbook -i hosts.ini win_ssh.yaml
ansible-playbook -i hosts.ini windows.yaml
foo.txt.j2
which was copied from ubuntu to Windows-VM has something to say