Ansible - tmansfield42/Tech-Journal GitHub Wiki
In this lab journal, we document the process of setting up Ansible for automation tasks, preparing Linux and Windows hosts for automation, and managing Ansible-specific configuration files and playbooks. In here are commands used to install Ansible on the controller, configure hosts, and necessary files for automation.
Ubuntu -
adduser <user>
usermod -aG sudo <user>
CentOS 7 & Rocky -
useradd <user>
usermod -aG wheel <user>
Create users 'deployer' on all systems with the same password, I used 'ansible' for the password.
refer to my 00-installer-config.yaml file for Ubuntu setup, CentOS & Rocky just uses nmtui for network setup.
On controller-yourname type:
sudo apt install ansible sshpass python3-paramiko
-
ssh-keygen -t rsa -C "sys265"
- Generates an RSA keypair. Make sure to include a passphrase for this lab. Do this on controller-firstname -
ssh-copy-id [email protected]
- Copies the public key over to ansible1 and ansible2 machines -
eval $(ssh-agent)
- Tests to see if ssh-agent is running, and if not, it will run it. -
ssh-add -t 14400
- Adds a lifetime of 14400 seconds to not have to use RSA passphrase
-
If windows' chocolatey doesn't exist on your system (i.e. cannot find choco.exe) you can manually download it on each Windows system by typing:
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'))
-
Set-ItemProperty "HKLM:\Software\Microsoft\Powershell\1\ShellIds" -Name ConsolePrompting -Value $true
-
New-ItemProperty -Path HKLM:\SOFTWARE\OpenSSH -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force
- Ensure Windows Update Service is enabled and running, then proceed to download OpenSSH Server through Apps & features > Manage optional features > Add a feature > OpenSSH Server