From bfab6d58c9430146f6adc583819610b17fd515a7 Mon Sep 17 00:00:00 2001 From: devan555 <38153142+devan555@users.noreply.github.com> Date: Wed, 22 May 2024 19:39:23 +0530 Subject: [PATCH] added test case --- .github/workflows/containerlab-actions.yml | 11 ++++++----- containerlab_test/test_case1.yml | 23 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 containerlab_test/test_case1.yml diff --git a/.github/workflows/containerlab-actions.yml b/.github/workflows/containerlab-actions.yml index 483b5a5..d7e1deb 100644 --- a/.github/workflows/containerlab-actions.yml +++ b/.github/workflows/containerlab-actions.yml @@ -6,12 +6,13 @@ jobs: runs-on: self-hosted steps: - uses: actions/checkout@v4 - - run: ls - - run: pwd - - run: echo "REPO_NAME=${{ github.event.repository.name }}" - - run: whoami + # - run: ls + # - run: pwd + # - run: echo "REPO_NAME=${{ github.event.repository.name }}" + # - run: whoami - run: ansible-playbook ~/clab_files/ansible_files/01_run_clab.yml -i containerlab_test/ansible-inventory.yml - + - run: ansible-playbook containerlab_test/testcase1.yml -i containerlab_test/ansible-inventory.yml + - name: Destroy the Containerlab if: always() run: ansible-playbook ~/clab_files/ansible_files/02_destroy_clab.yml \ No newline at end of file diff --git a/containerlab_test/test_case1.yml b/containerlab_test/test_case1.yml new file mode 100644 index 0000000..f15c185 --- /dev/null +++ b/containerlab_test/test_case1.yml @@ -0,0 +1,23 @@ +--- +- name: cEOS Config + hosts: ceos + gather_facts: yes + tasks: + - name: Retrieve VLAN configuration + eos_command: + commands: show vlan + register: vlan_output + + - name: Check if specific VLAN is present + set_fact: + vlan_present: "{{ 'VLAN 100' in vlan_output.stdout[0] }}" + + - name: Fail if VLAN is not present + fail: + msg: "VLAN 10 is not present on the switch." + when: not vlan_present + + - name: Debug message if VLAN is present + debug: + msg: "VLAN 10 is present on the switch." + when: vlan_present \ No newline at end of file