Search code examples
network-programmingautomationgitlabcicd

How can I create one Gitlab CICD pipeline for three different purposes


I am a student, and I have a research project about adopting the CICD pipeline for network automation using Gitlab CICD pipeline, Ansible, and NAPALM for network configuration automation. I have to do many 3 study cases like the following: study case 1: deploy candidate configurations or deploy new network services to the network devices; I have done the following pipeline:

stages:

  • validate

TEST environment

  • deploy_to_test
  • deploy_to_test_verification

PRODUCTION environment

  • deploy_to_prod
  • deploy_to_prod_verification

Study case 2: I did some playbooks to remove L2 interfaces for maintenance purposes. Study case 3: I did a playbook to replace the whole network device configuration using Ansible and NAPALM; this is also for maintenance purposes.

I did a ".gitlab-ci.yml" file for case study 1 because I am still a student, I do not have work experience in this field. I see it is not reasonable to do all study cases in one ".gitlab-ci.yml" file because they are for different purposes; I am right or not, I do not know.

My question: Can I do all the study cases in a ".gitlab-ci.yml" file or create a repository "new CICD pipeline ".gitlab-ci.yml" file" for each study case? e.g., one ".gitlab-ci.yml" file for interfaces maintenance, one for deploying new or change configuration, and one for replacing the whole configuration.

If I can do them in one file, how can I run only the study case I want and ignore the other two? If not, what is the solution? Thank you so much


Solution

  • you can specify gitlab-jobs to run only in certain scenarios by referencing the only: and except: keywords to create a scope for the job.

    OR you can use the much more powerful rules: which allows you to distinguish even better when which job should run.

    https://docs.gitlab.com/ee/ci/jobs/job_control.html

    both basically allow for multiple pipelines (or rather job-sequences) inside the single pipeline config file.