Ansible playbooks to manage VMs
Prerequisites
- VM should already have OS installed (RHEL or Debian)
- The root user on the vm should already have your authorized_key added
- Update the inventory file to account for any local IP address changes
Usage
- Checkout git repo:
git clone $url
- Move into repo:
cd vm-management/
- Install requirements:
ansible-galaxy install -r requirements.yaml
- Move into ansible folder
cd ansible/
- Prepare an ansible playbook command based on the selected hosts and tags
Tag | Description |
---|---|
backup | Stop the LGSM server, perform a backup, and start the LGSM server |
packages | Install all package dependencies and install all available package updates. The server may be rebooted if required. |
reboot | Stop the LGSM server, reboot the host, and start the LGSM server |
restart | Stop and start the LGSM server |
start | Start the LGSM server |
stop | Stop the LGSM server |
update | Update the LGSM server |
target_hosts | extra var |
---|---|
minecraft | -e "target_hosts=minecraft" |
ark | -e "target_hosts=ark |
minecraft and ark | -e "{'target_hosts': ['ark', 'minecraft']}" |
E.g. To install an LGSM minecraft server, run the following:
ansible-playbook playbooks/playbook.yaml -e "target_hosts=minecraft" --tags "install"