forked from model-driven-devops/mdd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
116 lines (105 loc) · 2.87 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
stages:
- clean
- build-cml
- build-nso
- init-nso
- save-rollback
- validate
- update
- check
- load-rollback
image: ghcr.io/model-driven-devops/mdd:latest
variables:
ANSIBLE_CONFIG: "./ansible.cfg"
CML_VERIFY_CERT: "false"
NSO_INSTALL: "true"
clean:
stage: clean
script:
- ansible-playbook cisco.cml.clean
resource_group: mdd
rules:
- if: $CLEAN == "true"
build-cml:
stage: build-cml
script:
- ansible-playbook cisco.cml.build -e startup='host' -e wait='yes' -e retries=100
resource_group: mdd
rules:
- if: $CLEAN == "true"
build-nso:
stage: build-nso
script:
- ansible-playbook ciscops.mdd.nso_install
- ansible-playbook ciscops.mdd.nso_update_packages
- ansible-playbook ciscops.mdd.nso_init
- ansible-playbook ciscops.mdd.nso_update_devices
resource_group: mdd
rules:
- if: $CLEAN == "true" && $NSO_INSTALL == "true"
init-nso:
stage: init-nso
script:
- ansible-playbook ciscops.mdd.nso_init
- ansible-playbook ciscops.mdd.nso_delete_devices
- ansible-playbook ciscops.mdd.nso_update_devices
- ansible-playbook ciscops.mdd.update -e dry_run=no
resource_group: mdd
rules:
- if: $NSO_INIT == "true"
save-rollback:
stage: save-rollback
script:
- ansible-playbook ciscops.mdd.nso_save_rollback
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 ciscops.mdd.validate
resource_group: mdd
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
- if: $CI_PIPELINE_SOURCE == "api"
update:
stage: update
script:
# update devices in case DHCP address changed
# - ansible-playbook ciscops.mdd.nso_update_devices
- ansible-playbook ciscops.mdd.update -e dry_run=no
resource_group: mdd
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
- if: $CI_PIPELINE_SOURCE == "api"
check:
stage: check
script:
# allow network to converge before running checks
- sleep 60
- ansible-playbook ciscops.mdd.check
resource_group: mdd
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
- if: $CI_PIPELINE_SOURCE == "api"
load-rollback:
stage: load-rollback
script:
# update devices in case DHCP address changed
# - ansible-playbook ciscops.mdd.nso_update_devices
- ansible-playbook ciscops.mdd.nso_load_rollback
resource_group: mdd
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: always