-
Notifications
You must be signed in to change notification settings - Fork 48
/
.gitlab-ci.yml
52 lines (47 loc) · 1.21 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
image: gitlab.infraly.ch:4567/francois/docker-ansible:master
stages:
- syntax
- test
- staging
syntax:
stage: syntax
script:
- ansible-playbook --version
- ansible-playbook --syntax-check site.yaml
lint:
stage: syntax
script:
- ansible-lint site.yaml
allow_failure: true
test:
stage: test
variables:
NAME: k8s-gitlab-ci-$CI_BUILD_ID
KEY: gitlab-ci-$CI_BUILD_ID
script:
- mkdir -p ~/.ssh
- ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
- cat ~/.ssh/id_rsa
- openstack keypair create --public-key ~/.ssh/id_rsa.pub gitlab-ci-$CI_BUILD_ID
- ansible-playbook site.yaml
after_script:
- STATE=absent ansible-playbook site.yaml || true
- openstack keypair delete gitlab-ci-$CI_BUILD_ID || true
staging:
stage: staging
variables:
NAME: k8s-staging
KEY: k8s-staging
script:
- mkdir -p ~/.ssh
- echo $STAGING_SSH_PRIVATE_KEY | base64 -d > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo $STAGING_SSH_PUBLIC_KEY | base64 -d > ~/.ssh/id_rsa.pub
- openstack keypair delete $KEY || true
- openstack keypair create --public-key ~/.ssh/id_rsa.pub $KEY
- ansible-playbook site.yaml
only:
- master
artifacts:
paths:
- admin.conf