-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
148 lines (133 loc) · 3.63 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
stages:
- clean
- build-cml
- build-prod
- build-nso
- init-nso
- save-rollback
- validate
- update-test
- check-test
- update-prod
- check-prod
- load-rollback
image: ghcr.io/model-driven-devops/mdd:latest
# variables:
# ANSIBLE_CONFIG: "./ansible.cfg"
# CML_VERIFY_CERT: "false"
clean:
stage: clean
script:
- ansible-playbook -i inventory_test cisco.cml.clean
resource_group: mdd
rules:
- if: $CLEAN == "true"
build-cml:
stage: build-cml
script:
- ansible-playbook -i inventory_test cisco.cml.build -e startup='host' -e wait='yes' -e retries=100
resource_group: mdd
rules:
- if: $CLEAN == "true"
build-prod:
stage: build-prod
script:
- ansible-playbook -i inventory_prod cisco.cml.build -e startup='host' -e wait='yes' -e retries=100
resource_group: mdd
variables:
CML_LAB: $PROD_CML_LAB
rules:
- if: $BUILD_PROD == "true"
build-nso:
stage: build-nso
script:
- ansible-playbook -i inventory_test ciscops.mdd.nso_install
- ansible-playbook -i inventory_test ciscops.mdd.nso_update_packages
- ansible-playbook -i inventory_test ciscops.mdd.nso_init
- ansible-playbook -i inventory_test ciscops.mdd.nso_update_devices
resource_group: mdd
rules:
- if: $CLEAN == "true" && $NSO_INSTALL == "true"
init-nso:
stage: init-nso
script:
- ansible-playbook -i inventory_test ciscops.mdd.nso_init
- ansible-playbook -i inventory_test ciscops.mdd.nso_delete_devices
- ansible-playbook -i inventory_test ciscops.mdd.nso_update_devices
# - ansible-playbook -i inventory_test ciscops.mdd.update -e dry_run=no
resource_group: mdd
rules:
- if: $NSO_INIT == "true"
save-rollback:
stage: save-rollback
script:
- ansible-playbook -i inventory_test ciscops.mdd.nso_save_rollback
variables:
CML_LAB: $TEST_CML_LAB
resource_group: mdd
artifacts:
paths:
- rollback.yaml
expire_in: 1 hour
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
validate:
stage: validate
script:
- yamllint mdd-data
- ansible-playbook -i inventory_prod ciscops.mdd.validate
resource_group: mdd
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
update-test:
stage: update-test
script:
- ansible-playbook -i inventory_test ciscops.mdd.update -e dry_run=no
variables:
CML_LAB: $TEST_CML_LAB
resource_group: mdd
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
check-test:
stage: check-test
script:
# allow network to converge before running checks
- sleep 60
- ansible-playbook -i inventory_test ciscops.mdd.check
variables:
CML_LAB: $TEST_CML_LAB
resource_group: mdd
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
update-prod:
stage: update-prod
script:
# update devices in case DHCP address changed
- ansible-playbook -i inventory_prod ciscops.mdd.update -e dry_run=no
variables:
CML_LAB: $PROD_CML_LAB
resource_group: mdd
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
check-prod:
stage: check-prod
script:
# allow network to converge before running checks
- sleep 60
- ansible-playbook -i inventory_prod ciscops.mdd.check
variables:
CML_LAB: $PROD_CML_LAB
resource_group: mdd
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
load-rollback:
stage: load-rollback
script:
- ansible-playbook -i inventory_test ciscops.mdd.nso_load_rollback
variables:
CML_LAB: $TEST_CML_LAB
resource_group: mdd
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: always