This guide will help you install Ansible, configure your inventory file, and run the playbook to set up your environment.
- A VM with SSH access.
- Ansible installed locally.
- SSH private key to access the VM.
First, ensure that Ansible is installed on your local machine. If it's not already installed, you can install it using:
# On Ubuntu or Debian
sudo apt update && sudo apt install ansible -y
# On CentOS or RHEL
sudo yum install epel-release -y
sudo yum install ansible -y
# On macOS using Homebrew
brew install ansible
Create an inventory file to define the target VM for Ansible:
echo '[my_vm]
VM_ADDRESS ansible_user=VM_USER ansible_ssh_private_key_file=~/.ssh/path/to/cert' > inventory
- Replace
VM_ADDRESS
with the IP address or hostname of your VM. - Replace
VM_USER
with the SSH username. - Replace
~/.ssh/path/to/cert
with the path to your SSH private key.
Once Ansible is installed and your inventory file is set up, run the playbook to configure your environment:
ansible-playbook -i inventory setup.yml
This will execute the playbook on the specified VM, installing and configuring the necessary components.
- Ensure that your VM allows SSH connections and that your firewall is configured accordingly.
- The playbook is designed to handle typical setup tasks, including Docker installation and user permissions configuration.