Login to the Gitlab-CE Server (Server 2) as a user |
- [ ] Add a new Vlan and advertise it in BGP
- [ ] Add SNMP to the Spine Switches
Write down the new branch name, 1-network-change |
A Merge request doesn’t make any changes, but don’t close the merge request |
git remote -v show origin
git pull origin master
kennorton@C02G71AFMD6P-knorton network-automation % git remote -v show origin (1) * remote origin Fetch URL: http://ccoe-netdev-02.presidio-demo.com/knorton/network-automation.git Push URL: http://ccoe-netdev-02.presidio-demo.com/knorton/network-automation.git HEAD branch: master Remote branches: 1-network-change new (next fetch will store in remotes/origin) master tracked Local ref configured for 'git push': master pushes to master (local out of date) (2) kennorton@C02G71AFMD6P-knorton network-automation % git pull origin master (3) remote: Enumerating objects: 21, done. remote: Counting objects: 100% (21/21), done. remote: Compressing objects: 100% (9/9), done. remote: Total 21 (delta 12), reused 21 (delta 12), pack-reused 0 Unpacking objects: 100% (21/21), 2.16 KiB | 116.00 KiB/s, done. From http://ccoe-netdev-02.presidio-demo.com/knorton/network-automation * branch master -> FETCH_HEAD fcc23a4..a0e0264 master -> origin/master Updating fcc23a4..a0e0264 Fast-forward .gitlab-ci.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .gitlab-ci.yml
1 | Check the remote repository |
2 | Notice the local repository is out of date |
3 | Pull down the changes from the remote repository |
git branch
git fetch
git branch 1-network-change
git checkout 1-network-change
kennorton@C02G71AFMD6P-knorton network-automation % git branch --all * master remotes/origin/master kennorton@C02G71AFMD6P-knorton network-automation % git fetch From http://ccoe-netdev-02.presidio-demo.com/knorton/network-automation * [new branch] 1-network-change -> origin/1-network-change kennorton@C02G71AFMD6P-knorton network-automation % git branch --all * master remotes/origin/1-network-change remotes/origin/master kennorton@C02G71AFMD6P-knorton network-automation % git branch * master kennorton@C02G71AFMD6P-knorton network-automation % git branch 1-network-change kennorton@C02G71AFMD6P-knorton network-automation % git branch 1-network-change * master kennorton@C02G71AFMD6P-knorton network-automation % git checkout 1-network-change Switched to branch '1-network-change'
all: children: leafs: hosts: clab-Arista-2s-3l-leaf3: spines: hosts: clab-Arista-2s-3l-spine1: clab-Arista-2s-3l-spine2:
This can be the one file completed by a help desk user in the future. Easy to read without having to understand the commands required to configure the switches |
--- configuration: vlans: vlan: 14 ip_addr: ip: "192.168.14.1" mask: 24
--- - name: MAKE CHANGE ON SPINE ARISTA SWITCHES hosts: spines (1) gather_facts: false connection: network_cli tasks: - name: CONFIGURE SNMP ON SPINES arista.eos.eos_snmp_server: config: communities: - name: "netdevops" acl_v4: "list3" view: "view1" contact: "admin" hosts: - host: "host02" version: "2c" user: "user1" traps: capacity: arista_hardware_utilization_alert: True bgp: enabled: True - name: MAKE CHANGE ON LEAF ARISTA SWITCHES hosts: leafs (2) gather_facts: false connection: network_cli tasks: - name: ADD VLAN {{ configuration.vlans.vlan }} eos_config: lines: - vlan {{ configuration.vlans.vlan }} - name: RECONFIGURE INTERFACE ETHERNET 3 eos_config: parents: interface ethernet 3 lines: - switchport access vlan {{ configuration.vlans.vlan }} - name: CONFIGURE INTERFACE VLAN {{ configuration.vlans.vlan }} eos_config: parents: interface vlan {{ configuration.vlans.vlan }} lines: - ip address virtual {{ configuration.ip_addr.ip }}/{{ configuration.ip_addr.mask }}
1 | We are only making the following SNMP changes to the spine switches defined in the host file |
2 | The following are the changes to the leaf switches to add a new vlan and vlan interface: |
---
workflow: (1)
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == 'master'
stages:
- build
- stage
- change (2)
- backup
network_change: (3)
stage: change
before_script:
- cd change
script:
- ansible-playbook change.yaml -v
dependencies:
- staging_switches
1 | Copy and paste the workflow section to the top of the .gitlab.ci file |
2 | Add the - change stage to the stages section between stage and backup |
3 | Copy and paste the network change stage in between the staging_switches stage and the backup_switches stage. |
Copy and paste this if you run into problems with your pipeline
---
workflow:
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == 'master'
stages:
- build
- stage
- change
- backup
build_switches:
stage: build
before_script:
- cd infra
script:
- sudo containerlab destroy -t ceos_2spine_3leaf.yaml || true
- sudo -E CLAB_LABDIR_BASE=/var/clab containerlab deploy -t ceos_2spine_3leaf.yaml || true
staging_switches:
stage: stage
before_script:
- cd build
script:
- sleep 60
- pip install ansible-pylibssh
- ansible-galaxy collection install arista.eos
- ansible-playbook build.yaml -v
network_change:
stage: change
before_script:
- cd change
script:
- ansible-playbook change.yaml -v
dependencies:
- staging_switches
backup_switches:
stage: backup
before_script:
- cd backup
script:
- ansible-playbook playbooks/git_backup.yaml -v
dependencies:
- staging_switches
git status
git add .gitlab-ci.yml
git commit -m "network change to add new vlan and update SNMP on Spine switches"
git push origin 1-network-change
kennorton@C02G71AFMD6P-knorton:~/network-automation$ git status On branch 1-network-change Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: .gitlab-ci.yml no changes added to commit (use "git add" and/or "git commit -a") kennorton@C02G71AFMD6P-knorton:~/network-automation$ git add .gitlab-ci.yml (1) kennorton@C02G71AFMD6P-knorton:~/network-automation$ git commit -m "network change to add new vlan and update SNMP on Spine switches" (2) [1-network-change 70478d8] network change to add new vlan and update SNMP on Spine switches 1 files changed, 18 insertions(+) kennorton@C02G71AFMD6P-knorton:~/network-automation$ git push origin 1-network-change (3) Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 12 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 510 KiB | 510 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0) remote: remote: To create a merge request for 1-network-change, visit: remote: http://ed26757f4b2c.mylabserver.com/knorton/network-automation/-/merge_requests/new?merge_request%5Bsource_branch%5D=1-network-change remote: To http://ed26757f4b2c.mylabserver.com/knorton/network-automation.git * [new branch] 1-network-change -> 1-network-change
1 | git add of the .gitlab-ci.yml file |
2 | git commit to add the change to local repository |
3 | git push to push the code to the server and kickoff the pipeline |
Click the ab406831 link to review the changes. The link ID will be different |
workflow:
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == 'master'