-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
92 lines (87 loc) · 2.91 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
---
variables:
environ: "staging"
stages:
- lint
- deploy
- verify
ansible lint:
stage: lint
image:
name: "cytopia/ansible-lint:5"
entrypoint: [""]
rules:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "stage"'
before_script:
- echo $ANSIBLE_VAULT_PASSWORD > .vault_pass
- export ANSIBLE_PERSISTENT_COMMAND_TIMEOUT=1000
- export ANSIBLE_PERSISTENT_CONNECT_TIMEOUT=1000
- export no_proxy="localhost,127.0.0.1,172.25.74.47"
- python3 -m pip install requests
- echo $ANSIBLE_VAULT_PASSWORD > .vault_pass
script:
- ansible-galaxy -vvv collection install -r collections/requirements.yml
- ansible-lint -p build.yml
- ansible-lint -p group_vars/all/overlay.yml
deploy_on_stage:
stage: deploy
image:
name: "cytopia/ansible"
entrypoint: [""]
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
before_script:
- echo $ANSIBLE_VAULT_PASSWORD > .vault_pass
- export ANSIBLE_PERSISTENT_COMMAND_TIMEOUT=1000
- export ANSIBLE_PERSISTENT_CONNECT_TIMEOUT=1000
- python3 -m pip install requests
script:
- ansible-playbook --version
- ansible-galaxy -vvv collection install -r collections/requirements.yml
- ansible-playbook -i hosts.stage.yml build.yml --vault-password-file .vault_pass
verify_on_stage:
stage: verify
image:
name: "cytopia/ansible"
entrypoint: [""]
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
before_script:
- echo $ANSIBLE_VAULT_PASSWORD > .vault_pass
- python3 -m pip install requests
script:
- sleep 10
- ansible-playbook --version
- ansible-galaxy -vvv collection install -r collections/requirements.yml
- ansible-playbook -i hosts.stage.yml verify.yml --vault-password-file .vault_pass
deploy_on_prod:
stage: deploy
image:
name: "cytopia/ansible"
entrypoint: [""]
rules:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"'
before_script:
- echo $ANSIBLE_VAULT_PASSWORD > .vault_pass
- export ANSIBLE_PERSISTENT_COMMAND_TIMEOUT=1000
- export ANSIBLE_PERSISTENT_CONNECT_TIMEOUT=1000
- python3 -m pip install requests
script:
- ansible-playbook --version
- ansible-galaxy -vvv collection install -r collections/requirements.yml
- ansible-playbook -i hosts.prod.yml build.yml --vault-password-file .vault_pass
verify_on_prod:
stage: verify
image:
name: "cytopia/ansible"
entrypoint: [""]
rules:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"'
before_script:
- echo $ANSIBLE_VAULT_PASSWORD > .vault_pass
- python3 -m pip install requests
script:
- sleep 10
- ansible-playbook --version
- ansible-galaxy -vvv collection install -r collections/requirements.yml
- ansible-playbook -i hosts.prod.yml verify.yml --vault-password-file .vault_pass