-
Notifications
You must be signed in to change notification settings - Fork 0
6.1 Automation and Ansible
Set up ansible
After the initial setup of all the boxes was complete, install ansible with the following command on controller:
sudo apt install ansible sshpass python3-parmiko-
ansible --version- check the version of anisble you are running
Create file /etc/sudoers.d/sys265 on all linux systems, add the following content:

Generate a Key Pair:
-
ssh-keygen -t rsa -b 4096- create a passphrase when doing this
Copy the public key to the deployer accounts in the ansible boxes with this command:
ssh-copy-id -i ~/.ssh/id_rsa.pub deployer@ansible01-elizabethssh-copy-id -i ~/.ssh/id_rsa.pub deployer@ansible02-elizabeth
Make it so you only have to type your password every 4 hours:
-
ssh-add -t 14400- and enter your passphrase
Source: https://linovox.com/ssh-copy-id-command/
Create a document called inventory.txt in the ansible folder. Add the hostnames of the ansible boxes, if you want some to be in a group add "[groupname]" above the hostnames you wan in that group
Run a command on all the boxes in the inventory.txt file:
ansible all -a [command] -i inventory.txt
Ansible galaxy comes installed with ansible and allows you to grab a role or tool from the ansible galaxy website, kinda like github. Can be found here
Create a playbook that looks like this (will differ for different programs, this is one for webmin):

Install a role like this (again, example is for semuadmin.webmin, which is now unsupported)
-
ansiible-galaxy install semuadmin.webmin -p roles/- the -p bit indicates where the role will be installed
Run the playbook from the ansible directory with the following command:
ansible-playbook -i inventory.txt roles/webmin.yml
Other roles from ansible galaxy can be installed similarly.
I used Matt's config and yaml files for ansible galaxy since I was having trouble getting anything else working. This way I can ask for troubleshooting help directly. These can be found here:
All of the files I used can be found in the Code section of this github
We ran into some significant problems with this portion of the lab, but found that in order to install openssh, you need to do the following:
- In services, find the "Windows Update" Service, and turn it to "Automatic"
- Restart mgmt
- Run
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
From there, do the following:
Start-Service sshdSet-Service -Name sshd -StartupType 'Automatic'
Set-ItemProperty "HKLM:\Software\Microsoft\Powershell\1\ShellIds" -Name ConsolePrompting -Value $trueNew-ItemProperty -Path HKLM:\SOFTWARE\OpenSSH -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force