This project demonstrates how to use Vagrant and Ansible to provision virtual machines and automate the installation of Nginx and Docker on the target machines.
Before getting started, ensure that the following software is installed on your system:
- Vagrant: Download and install Vagrant.
- VirtualBox: Download and install VirtualBox.
- Ansible: Installation instructions for Ansible.
-
Clone this repository to your local machine.
-
Navigate to the project directory.
-
Customize the
Vagrantfile
:- Update the number of machines or adjust their configuration (e.g., memory, CPU).
- Modify the base box if needed.
- Add or remove any additional configuration options as required.
-
Customize the
playbook.yml
:- Add or modify tasks to install or configure additional software.
- Include any other desired configuration steps.
-
Customize the
inventory.ini
:- Define the hosts or groups that the playbook should target.
- Update the hostnames and IP addresses as necessary.
-
Open a terminal or command prompt and navigate to the project directory.
-
Run the following command to provision the machines and execute the playbook:
vagrant up # used to up the machine
vagrant status # check status
vagrant halt # stop machine
vagrant destroy # remove all machines
vagrant provision # provision these machines
// used to work with ansible
machine.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
ansible.limit = "web-servers#{i}"
end