-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from devan555/develop
Develop
- Loading branch information
Showing
7 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Containerlab test case execution | ||
run-name: ${{ github.actor }} is running the Containerlab Action | ||
on: [push] | ||
jobs: | ||
containerlab-testcase-execution: | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# - run: echo "REPO_NAME=${{ github.event.repository.name }}" | ||
|
||
- name: Deploy devices in Containerlab and run the Playbook | ||
run: ansible-playbook containerlab_test/deploy_containerlab.yml -i containerlab_test/ansible-inventory.yml | ||
|
||
- name: Run the testcase1 on the Containerlab Devices | ||
run: ansible-playbook containerlab_test/test_case1.yml -i containerlab_test/ansible-inventory.yml | ||
|
||
- name: Destroy the Containerlab | ||
if: always() | ||
run: ansible-playbook containerlab_test/destroy_containerlab.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
all: | ||
children: | ||
ceos: | ||
vars: | ||
ansible_become: 'true' | ||
ansible_become_method: enable | ||
ansible_become_password: admin | ||
ansible_connection: ansible.netcommon.network_cli | ||
ansible_network_os: eos | ||
ansible_password: admin | ||
ansible_user: admin | ||
children: | ||
group01: | ||
hosts: | ||
ceos1: | ||
ansible_host: localhost | ||
ansible_port: 23001 | ||
ceos2: | ||
ansible_host: localhost | ||
ansible_port: 23002 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
- name: Run CLAB | ||
hosts: localhost | ||
become: yes | ||
become_method: sudo | ||
gather_facts: false | ||
vars: | ||
ansible_become_password: password | ||
topology_file: /home/user1/actions-runner/_work/ceos_config/ceos_config/containerlab_test/topology.clab.yaml --reconfigure | ||
tasks: | ||
|
||
- name: Execute deploy | ||
local_action: command sudo containerlab deploy --topo {{ topology_file }} | ||
become: yes | ||
register: deploy_out | ||
|
||
- debug: msg="{{ deploy_out.stdout_lines }}" | ||
|
||
- name: Wait for device01 to bootup | ||
ansible.builtin.wait_for: | ||
port: 23001 | ||
delay: 15 | ||
|
||
- name: Wait for device02 to bootup | ||
ansible.builtin.wait_for: | ||
port: 23002 | ||
delay: 15 | ||
|
||
- name: Import cEOS Playbook | ||
ansible.builtin.import_playbook: "/home/user1/actions-runner/_work/ceos_config/ceos_config/playbook.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
- name: Run CLAB | ||
hosts: localhost | ||
become: yes | ||
become_method: sudo | ||
gather_facts: false | ||
vars: | ||
ansible_become_password: password | ||
topology_file: /home/user1/actions-runner/_work/ceos_config/ceos_config/containerlab_test/topology.clab.yaml | ||
tasks: | ||
- name: Execute destroy | ||
local_action: command sudo containerlab destroy --topo {{ topology_file }} | ||
become: yes | ||
register: destroy_out | ||
ignore_errors: true | ||
|
||
- debug: msg="{{ destroy_out }}" | ||
- name: Wait for 5 sec | ||
wait_for: | ||
timeout: 5 | ||
|
||
- name: Delete container file | ||
local_action: command sudo rm -rf /home/user1/actions-runner/_work/ceos_config/ceos_config/containerlab_test/clab-ceos_simple/ | ||
become: yes | ||
ignore_errors: true | ||
register: delete_dir | ||
|
||
# - debug: msg="{{ delete_dir }}" | ||
|
||
# - name: Delete dir | ||
# file: | ||
# path: containerlab_test/clab-ceos_simple | ||
# state: absent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
- name: cEOS Config | ||
hosts: ceos | ||
gather_facts: no | ||
tasks: | ||
- name: Retrieve VLAN configuration | ||
eos_command: | ||
commands: show vlan | ||
register: vlan_output | ||
|
||
- name: Print output | ||
debug: msg="{{ vlan_output.stdout[0] }}" | ||
- name: Check if specific VLAN is present | ||
set_fact: | ||
vlan_present: "{{ 'VLAN0010' 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: ceos_simple | ||
topology: | ||
nodes: | ||
ceos1: | ||
kind: ceos | ||
image: ceos:4.30.5M | ||
ports: | ||
- 23001:22 | ||
ceos2: | ||
kind: ceos | ||
image: ceos:4.30.5M | ||
ports: | ||
- 23002:22 | ||
|
||
links: | ||
- endpoints: ["ceos1:eth1", "ceos2:eth1"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- name: cEOS Config | ||
hosts: ceos | ||
gather_facts: yes | ||
tasks: | ||
- name: Print Device Facts | ||
debug: | ||
msg: "{{ ansible_facts }}" | ||
|
||
- name: Configure VLAN 10 | ||
arista.eos.eos_vlans: | ||
config: | ||
- vlan_id: 10 | ||
state: active | ||
register: vlan_conf | ||
|
||
- name: Print VLAN Conf output | ||
ansible.builtin.debug: | ||
msg: "{{ vlan_conf }}" | ||
|
||
- name: Gather VLAN config | ||
arista.eos.eos_vlans: | ||
state: gathered | ||
register: gathered_vlan | ||
|
||
- name: Print Gathered VLAN | ||
ansible.builtin.debug: | ||
msg: "{{ gathered_vlan }}" |