/vm-snmp-lab

Setup and configure SNMP

Primary LanguagePython

vm-snmp-lab

Setup and Configure SNMP

Getting Started

Create .env file

  1. Copy .env.example as .env
  2. Add/Update environment variables as needed
  3. source .env to load variables into the current session

Configure VMs

Update Vagrantfile.yml to configure the VMs that will be created.

Starting and Stopping the VM

# bring the VM up
vagrant up

# connect via ssh
vagrant ssh vagrant01

# stop the vm
vagrant halt

# delete the vm
vagrant destroy

Downloading dependencies

Download the role and collection dependencies:

cd roles
ansible-galaxy role install -r requirements.yml
ansible-galaxy collection install -r requirements.yml

# if you want to install locally
# ansible-galaxy role install --roles-path . -r requirements.yml

Testing inventory with ad-hoc commands

ansible vagrant -a "date"

Running the Ansible Playbook

To execute the playbook to configure the VM execute the following:

# run the playbook against a specific vm
ansible-playbook playbook.yml # --limit vagrant01

Sample directory layout

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

Resources