This project intends to run certain tests on iosxr routers and check if the conditions meet. Subsequent to which it classifies the test as pass or fail. Broad steps involved to achieve the same are:
- Retrieve the output using iosxr commands
- Process the output using genie generic parsers or by creating a custom parser
- Check for the condition
- show media
- show platform
- show hardware module
- show filesystem
- show controllers fabric plane all
- show environment power
- show context
- show led
- show version
- show install active summary
- show install commit summary
- Pre-requisites
- Ansible
- Jmespath (
pip install jmespath
) - pyats (
pip install pyats
) - genie-parser (
pip install genie-parser
)
- Steps to Reproduce
- Populate hosts file
- Excute mainplaybook.yml using
ansible-playbook -i hosts main_playbook.yml
- Result
- The above steps run a recap, showing output as "Passed" or "Failed" after each command test
- It produces a combined "Passed"/"Failed" status in the end (by displaying the content of
./roles/file/output.txt
)
- Getting to Know the Files
./roles/ShowXyz/tasks/main.yml
contains the playbook to retrieve cli output, parse and check for the condition./roles/file/genie_generic_show_xyzcommand.yml
contains the schema for the expected structured output and an index value specifying the index for primary key- for a detailed documentation refer to Generic Tabular Parsing
main_playbook.yml
contains the combined roleshosts
contains the details of the hosts (eg: HOSTNAME ansible_host=xx.xx.xx.xx ansible_network_os=iosxr ansible_user=xyz ansible_ssh_pass=abc)./roles/Summary/tasks/main.yml
contains a playbook to clear theoutput.txt
content after each test run, and push in new outputs after a successful run./roles/file/output.txt
contains the summary that needs to be printed towards the end, this file gets populated as the playbooks run, and is wiped out after its contents are displayed
-
Pre-requisites
-
To be able to use the custom parsers defined in the forked repository, virtual environment has to be activated.
- Create a virtual environment.
python3 -m venv .venv
- Activate the virtual environment.
source .venv/bin/activate
- Create a virtual environment.
-
Some packages and libraries are needed to be installed and updated to work with the custom genie parsers. If pyats, genie, and clay584.parse_genie are already installed, then skip to third line.
$ pip install pyats genie $ ansible-galaxy install clay584.parse_genie $ apt update $ pip install make $ pip install pyats.contrib
- Then a forked repository genieparser has to be cloned which has the custom parsers. Create/Choose and enter a directory to keep the cloned repository before running the
git clone https://github.com/deepB123/genieparser.git
command.
$ cd genieparser $ make develop $ make json
To verify, run
pip list
and check ifgenie.libs.parser
has the location of the cloned genieparser.To be used in same virtual environment as shared in the pre-requisites section under Leveraging custom genie parser based command check.
-
- Pre-requisites
- Ansible
- Jmespath (
pip install jmespath
) - pyats (
pip install pyats
) - genie-parser (
pip install genie-parser
)
- Steps to Reproduce
- Populate hosts file
- Excute mainplaybook.yml using
ansible-playbook -i hosts main_playbook.yml
- Result
- The above steps run a recap, showing output as "Passed" or "Failed" after each command test
- It produces a combined "Passed"/"Failed" status in the end (by displaying the content of
./roles/file/output.txt
)
- Getting to Know the Files
./roles/ShowXyz/tasks/main.yml
contains the playbook to retrieve cli output, parse and check for the conditionmain_playbook.yml
contains the combined roleshosts
contains the details of the hosts (eg: HOSTNAME ansible_host=xx.xx.xx.xx ansible_network_os=iosxr ansible_user=xyz ansible_ssh_pass=abc)./roles/Summary/tasks/main.yml
contains a playbook to clear theoutput.txt
content after each test run, and push in new outputs after a successful run./roles/file/output.txt
contains the summary that needs to be printed towards the end, this file gets populated as the playbooks run, and is wiped out after its contents are displayed
- Pre-requisites
- Ansible
- pyats (
pip install pyats
) - genie-parser (
pip install genie-parser
)
- Steps to Reproduce
- Populate hosts file
- Populate
./roles/file/golden_output_active.txt
with the expected set of packages, in order to executeshow install active summary
- Populate
./roles/file/golden_output_commit.txt
with the expected set of packages, in order to executeshow install commit summary
- Excute mainplaybook.yml using
ansible-playbook -i hosts main_playbook.yml
- Result
- The above steps run a recap, showing output as "Passed" or "Failed" after each command test
- It produces a combined "Passed"/"Failed" status in the end (by displaying the content of
./roles/file/output.txt
)
- Getting to Know the Files
./roles/file/golden_output_active.txt
contains hyphen (-) separated golden output for show install active summary which we need to check against./roles/file/golden_output_commit.txt
contains hyphen (-) separated golden output for show install commit summary which we need to check against./roles/ShowInstallActive/tasks/main.yml
contains the playbook which compares the installed packages with the expected packages (defined under./roles/file/golden_output_active.txt
), if the installs are consistent with the expected set of packages the the test passes, else fails./roles/ShowInstallCommit/tasks/main.yml
contains the playbook which compares the installed packages with the expected packages (defined under./roles/file/golden_output_commit.txt
), if the installs are consistent with the expected set of packages the the test passes, else failsmain_playbook.yml
contains the combined roleshosts
contains the details of the hosts (eg: HOSTNAME ansible_host=xx.xx.xx.xx ansible_network_os=iosxr ansible_user=xyz ansible_ssh_pass=abc)./roles/Summary/tasks/main.yml
contains a playbook to clear theoutput.txt
content after each test run, and push in new outputs after a successful run./roles/file/output.txt
contains the summary that needs to be printed towards the end, this file gets populated as the playbooks run, and is wiped out after its contents are displayed