A repo to get up and running with Ansible.
- Copy
.env.example
as.env
- Add/Update environment variables as needed
source .env
to load variables into the current session
Update Vagrantfile.yml to configure the VMs that will be created.
# bring the VM up
vagrant up
# connect via ssh
vagrant ssh vagrant01
# stop the vm
vagrant halt
# delete the vm
vagrant destroy
Download the role and collection dependencies:
cd roles
ansible-galaxy install --roles-path . -r requirements.yml
ansible-galaxy collection install -r requirements.yml
ansible test -a "date"
To execute the playbook to configure the VM execute the following:
# run the playbook against a specific vm
ansible-playbook playbook.yml --limit vagrant01
production # inventory file for production servers
staging # inventory file for staging environment
group_vars/
group1.yml # here we assign variables to particular groups
group2.yml
host_vars/
hostname1.yml # here we assign variables to particular systems
hostname2.yml
library/ # if any custom modules, put them here (optional)
module_utils/ # if any custom module_utils to support modules, put them here (optional)
filter_plugins/ # if any custom filter plugins, put them here (optional)
site.yml # main playbook
webservers.yml # playbook for webserver tier
dbservers.yml # playbook for dbserver tier
tasks/ # task files included from playbooks
webservers-extra.yml # <-- avoids confusing playbook with task files