Skip to content

ddichev-hub/mars

Repository files navigation

mars

The project includes different tools to help with lab automation.

  • backup - backup/restore device configuration to/from remote server or locally on device. Filename consist of <device_name>_<file_suffix> . This allows to take backup/restore in different stages of configuration.

  • banner - create/read/update/delete banner

To setup your environment:

git clone https://github.com/ddichev-hub/mars.git
cd mars
apt-get install python3-venv (optional)
python3 -m venv venv  (optional)
source venv/bin/activate  (optional if you prefer to use virtual environment)
pip install wheel
pip install -r requirements.txt

Executing playbook

All functionality is orgnized in roles under the folder roles To execute :

ansible-playbook -i inventory/TEST_LAB.yml playbook_file.yaml -e

Modify inventory file with IPs, Login credentials for your environment

Backup role

There are few variables and tags that change the behavior of the playbooks:

  • crud : variable, it can be "apply" , "create" or "delete" .

    • "apply" - apply config file from remote server or local. Device will be reloaded
    • "create" - create config file and upload to remote server or keep it local. Device will not reboot
    • "delete" - delete config file from local device memory. Device will not reboot
  • file_suffix : variable, string that will be added at the end of the backup file name. Used during backup and restore

  • remote: tag, specifies that backup file will be uploaded/downloaded to/from remote server

  • local: tag, specifies that backup file will be stored on the device

  • delete-local: tag, it will execute task to delete backup file from device

  • debug: tag, enables debug prints

Example to execute backup role

Create backup with file_suffix test123 on remote/local and do not delete the local config

ansible-playbook -i inventory/<inventory_file>.yml backup.yaml -e "crud=create file_suffix=test123" -t [remote|local] --skip-tags delete-local,debug
ansible-playbook -i inventory/<inventory_file>.yml backup.yaml -e "crud=create file_suffix=test123" -t remote --skip-tags debug

Delete backup file from device

ansible-playbook -i inventory/<inventory_file>.yml backup.yaml -e "crud=delete file_suffix=test123" -t local --skip-tags debug

Apply config file with file_suffix "test123"

ansible-playbook -i inventory/inventory_file backup.yaml -e "crud=apply, file_suffix=test123"  -t [local|remote] --skip-tags debug
ansible-playbook -i inventory/<inventory_file>.yml backup.yaml -e "crud=apply file_suffix=test123" -t remote

Banner role

There are few variables and tags that change the behavior of the playbook:

  • crud : variable, it can be "create", "delete" or "get"

    • "create" - create banner
    • "delete" - delete banner
    • "get" - get current banner
  • debug: tag, enables debug prints

Example to execute banner role

ansible-playbook -i inventory/<inventory_file>.yml banner.yaml -e "crud=create" --skip-tags debug
ansible-playbook -i inventory/<inventory_file>.yml banner.yaml -e "crud=delete" --skip-tags debug
ansible-playbook -i inventory/<inventory_file>.yml banner.yaml -e "crud=get"  --skip-tags debug

About

lab automation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published