GitLab Setup
CI/CD

Setting Up GitLab

Return to your VSCode application window. It is now time to setup and initialize your GitLab repo.


Step 1 - Change Directory Back to Project Top Level

Ensure you are at the top level directory for your project folder:


cd ~/workspace/ndfclab/ansible


Step 2 - Set Git User Global Settings

Set your Git global settings:


git config --global user.name "POD-01"
git config --global user.email "pod01@ciscolive.com"
git config --global init.defaultBranch main


Step 3 - Initialize Local Directory as Git Repo

Initialize your local project directory as git repo:


git init


Step 4 - Add Remote Pointer to Git Repo

Add pointer to your GitLab remote repository.


git remote add origin git@10.0.208.215:CL-POD01/LTRDCN-3439.git


Step 5 - Create .gitignore File

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.

  
touch ~/workspace/ndfclab/ansible/.gitignore
cat << EOF > ~/workspace/ndfclab/ansible/.gitignore
/collections
*.env
scripts/
ansible.cfg

# VScode 
.vscode/*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# pyenv
.python-version
EOF


Step 6 - Add Files for Committing to GitLab Repo

Add your current files to your staging area for committing to your GitLab repo.


git add .


Step 7 - Double Check Files Staged For Commit

Check your git status of your working directory and staging area.


git status .


The following files are staged for commit. Make sure your list matches the output below!

    On branch main

    No commits yet
    
    Changes to be committed:
      (use "git rm --cached ..." to unstage)
            new file:   .gitignore
            new file:   build_fabric.yml
            new file:   group_vars/all/overlay.yml
            new file:   group_vars/stage/fabric.yml
            new file:   group_vars/stage/interfaces.yml
            new file:   group_vars/stage/overlay.yml
            new file:   group_vars/stage/vrf_lite.yml
            new file:   hosts.stage.yml
            new file:   reset_fabric.yml
            new file:   roles/add_inventory/tasks/add_fabric_devices.yml
            new file:   roles/add_inventory/tasks/add_fabric_devices_poap.yml
            new file:   roles/add_inventory/tasks/add_fabric_external_devices.yml
            new file:   roles/add_inventory/tasks/main.yml
            new file:   roles/create_fabric/tasks/main.yml
            new file:   roles/create_fabric/tasks/manage_external_fabric.yml
            new file:   roles/create_fabric/tasks/manage_fabric.yml
            new file:   roles/deploy/tasks/main.yml
            new file:   roles/manage_interfaces/tasks/host_interfaces.yml
            new file:   roles/manage_interfaces/tasks/loopback_interfaces.yml
            new file:   roles/manage_interfaces/tasks/main.yml
            new file:   roles/manage_interfaces/tasks/vpc_interfaces.yml
            new file:   roles/manage_overlay/files/attach_nets.yml
            new file:   roles/manage_overlay/files/attach_vrfs.yml
            new file:   roles/manage_overlay/files/vrf_lite_attach_vrfs.yml
            new file:   roles/manage_overlay/tasks/add_policies.yml
            new file:   roles/manage_overlay/tasks/add_vrf_lite_vrfs.yml
            new file:   roles/manage_overlay/tasks/add_vrfs_networks.yml
            new file:   roles/manage_overlay/tasks/main.yml
            new file:   roles/manage_overlay/tasks/resync_fabric.yml
            new file:   roles/manage_overlay/templates/attach_networks.j2
            new file:   roles/manage_overlay/templates/attach_vrfs.j2
            new file:   roles/manage_overlay/templates/vrf_lite_attach_vrfs.j2
            new file:   roles/setup_vpc/tasks/main.yml
            new file:   roles/setup_vpc/tasks/setup_vpc_peer.yml

Step 8 - Commit Files to the GitLab Repo

Issue a git commit which is like a save point of your current local repo.


git commit -m "Initial Commit"


Step 9 - Push Files to the GitLab Repo

With your local repo added and committed to staging, push your content to your remote GitLab repo.


git push -u origin main