Return to your VSCode application window. It is now time to setup and initialize your Git repo.
Ensure you are at the top level directory for your project folder:
Set your Git global settings:
Initialize your local project directory as git repo:
Add the remote pointer to your Git repo:
In Git repos, it is very common to have a hidden file called .gitignore
. This is a reserved filename and it is used to
ignore specific file extensions and/or directories from being added to the Git repo. An example of a specific file you do not want added to your
Git repo is your .python-version
hidden file that specifies your pyenv environment.
As you previously stepped through building out your infrastructure as code with Ansible, there were host specific variables created for your staging spine switch and leaf switches. Again, host specific in this case is switch specific. The Ansible roles you created are agnostic to the fabric they are run against. So, you need to simply create the host specific variable files for the prod fabric switches. Since the staging fabric is a development fabric and thus a mirror image of your prod fabric, you simply need to copy the each host specific file for staging to its prod counterpart.
As discussed in the previous step, the Ansible host file needs to be created for prod as you did for staging.
And finally, the pyATS testbed YAML file needs to be created for your prod fabric so that the tests can run against your prod fabric.
After initializing your Git repo and creating the files specific to your prod fabric, it is time to add these files with Git in preparation for commiting them to the repo.
You perform the action of adding files with git add
. You will add your ansible-nxos
and tests
directories. Again, the Ansible playbooks and
pyATS tests are not specific to either fabric and are designed to work on either fabric. Lastly, you'll add your .gitignore
file. You may notice the removal of the hidden
Travis YAML files. Ansible Galaxy creates these by default for Travis CI which is another option as a CI/CD platform. Since we're using GitLab for this lab, we're simply going to remove them.
After adding what you are wanting to commit to your git repo, check the status with git status
.
On branch main No commits yet Changes to be committed: (use "git rm --cached..." to unstage) new file: .gitignore new file: ansible-nxos/ansible.cfg new file: ansible-nxos/group_vars/leafs.yml new file: ansible-nxos/group_vars/nxos.yml new file: ansible-nxos/group_vars/spines.yml new file: ansible-nxos/host_vars/10.15.1.11.yml new file: ansible-nxos/host_vars/10.15.1.12.yml new file: ansible-nxos/host_vars/10.15.1.13.yml new file: ansible-nxos/host_vars/10.15.1.14.yml new file: ansible-nxos/host_vars/10.15.1.15.yml new file: ansible-nxos/host_vars/10.15.1.16.yml new file: ansible-nxos/prod.yml new file: ansible-nxos/roles/common/README.md new file: ansible-nxos/roles/common/defaults/main.yml new file: ansible-nxos/roles/common/handlers/main.yml new file: ansible-nxos/roles/common/meta/main.yml new file: ansible-nxos/roles/common/tasks/main.yml new file: ansible-nxos/roles/common/tests/inventory new file: ansible-nxos/roles/common/tests/test.yml new file: ansible-nxos/roles/common/vars/main.yml new file: ansible-nxos/roles/overlay/README.md new file: ansible-nxos/roles/overlay/defaults/main.yml new file: ansible-nxos/roles/overlay/handlers/main.yml new file: ansible-nxos/roles/overlay/meta/main.yml new file: ansible-nxos/roles/overlay/tasks/main.yml new file: ansible-nxos/roles/overlay/tests/inventory new file: ansible-nxos/roles/overlay/tests/test.yml new file: ansible-nxos/roles/overlay/vars/main.yml new file: ansible-nxos/roles/underlay/README.md new file: ansible-nxos/roles/underlay/defaults/main.yml new file: ansible-nxos/roles/underlay/handlers/main.yml new file: ansible-nxos/roles/underlay/meta/main.yml new file: ansible-nxos/roles/underlay/tasks/main.yml new file: ansible-nxos/roles/underlay/tests/inventory new file: ansible-nxos/roles/underlay/tests/test.yml new file: ansible-nxos/roles/underlay/vars/main.yml new file: ansible-nxos/staging.yml new file: ansible-nxos/vxlan.yml new file: tests/prod-testbed.yaml new file: tests/pyats.robot new file: tests/pyats_aetest.py new file: tests/pyats_easypy.py new file: tests/results/.keep new file: tests/staging-testbed.yaml
With your directories and files added, you can now commit them to your Git repo with git commit
.
The -m
option is for a comment/message for the comment.
[main (root-commit) e7f8557] Initial commit 44 files changed, 1184 insertions(+) create mode 100644 .gitignore create mode 100644 ansible-nxos/ansible.cfg create mode 100644 ansible-nxos/group_vars/leafs.yml create mode 100644 ansible-nxos/group_vars/nxos.yml create mode 100644 ansible-nxos/group_vars/spines.yml create mode 100644 ansible-nxos/host_vars/10.15.1.11.yml create mode 100644 ansible-nxos/host_vars/10.15.1.12.yml create mode 100644 ansible-nxos/host_vars/10.15.1.13.yml create mode 100644 ansible-nxos/host_vars/10.15.1.14.yml create mode 100644 ansible-nxos/host_vars/10.15.1.15.yml create mode 100644 ansible-nxos/host_vars/10.15.1.16.yml create mode 100644 ansible-nxos/prod.yml create mode 100644 ansible-nxos/roles/common/README.md create mode 100644 ansible-nxos/roles/common/defaults/main.yml create mode 100644 ansible-nxos/roles/common/handlers/main.yml create mode 100644 ansible-nxos/roles/common/meta/main.yml create mode 100644 ansible-nxos/roles/common/tasks/main.yml create mode 100644 ansible-nxos/roles/common/tests/inventory create mode 100644 ansible-nxos/roles/common/tests/test.yml create mode 100644 ansible-nxos/roles/common/vars/main.yml create mode 100644 ansible-nxos/roles/overlay/README.md create mode 100644 ansible-nxos/roles/overlay/defaults/main.yml create mode 100644 ansible-nxos/roles/overlay/handlers/main.yml create mode 100644 ansible-nxos/roles/overlay/meta/main.yml create mode 100644 ansible-nxos/roles/overlay/tasks/main.yml create mode 100644 ansible-nxos/roles/overlay/tests/inventory create mode 100644 ansible-nxos/roles/overlay/tests/test.yml create mode 100644 ansible-nxos/roles/overlay/vars/main.yml create mode 100644 ansible-nxos/roles/underlay/README.md create mode 100644 ansible-nxos/roles/underlay/defaults/main.yml create mode 100644 ansible-nxos/roles/underlay/handlers/main.yml create mode 100644 ansible-nxos/roles/underlay/meta/main.yml create mode 100644 ansible-nxos/roles/underlay/tasks/main.yml create mode 100644 ansible-nxos/roles/underlay/tests/inventory create mode 100644 ansible-nxos/roles/underlay/tests/test.yml create mode 100644 ansible-nxos/roles/underlay/vars/main.yml create mode 100644 ansible-nxos/staging.yml create mode 100644 ansible-nxos/vxlan.yml create mode 100644 tests/prod-testbed.yaml create mode 100644 tests/pyats.robot create mode 100644 tests/pyats_aetest.py create mode 100644 tests/pyats_easypy.py create mode 100644 tests/results/.keep create mode 100644 tests/staging-testbed.yaml
Finally, with your project directory initialized as a Git repo, your files added and committed, you can push everything to your Git repo on the GitLab instance.
Enumerating objects: 65, done. Counting objects: 100% (65/65), done. Delta compression using up to 8 threads Compressing objects: 100% (40/40), done. Writing objects: 100% (65/65), 11.00 KiB | 751.00 KiB/s, done. Total 65 (delta 8), reused 0 (delta 0), pack-reused 0 To 10.15.0.159:Pod01_2025_01/LTRDCN-3903.git * [new branch] main -> main Branch 'main' set up to track remote branch 'main' from 'origin'.
Return to GitLab. Your may have to refresh the browswer window. Your GitLab repo should now looks similar to the screenshot below with the directories and files you just pushed now stored in source control:
Continue to the next section to setup your GitLab CI file for the CI/CD pipeline.