This repository was archived by the owner on Nov 18, 2020. It is now read-only.
Commit dde0c6c 1 parent 47e5d45 commit dde0c6c Copy full SHA for dde0c6c
File tree 9 files changed +106
-55
lines changed
ansible/memcached-operator
9 files changed +106
-55
lines changed Original file line number Diff line number Diff line change 2
2
services : docker
3
3
language : python
4
4
install :
5
- - pip3 install docker molecule openshift jmespath
5
+ - pip3 install docker molecule ansible-lint yamllint flake8 openshift jmespath
6
6
script :
7
7
- molecule test -s test-local
Original file line number Diff line number Diff line change 1
- FROM quay.io/operator-framework/ansible-operator:v0.16 .0
1
+ FROM quay.io/operator-framework/ansible-operator:v0.17 .0
2
2
3
3
COPY requirements.yml ${HOME}/requirements.yml
4
4
RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \
Original file line number Diff line number Diff line change
1
+ ---
2
+ - name : Converge
3
+ hosts : localhost
4
+ connection : local
5
+ gather_facts : no
6
+ collections :
7
+ - community.kubernetes
8
+
9
+ tasks :
10
+ - name : Ensure operator image is set
11
+ fail :
12
+ msg : |
13
+ You must specify the OPERATOR_IMAGE environment variable in order to run the
14
+ 'cluster' scenario
15
+ when : not operator_image
16
+
17
+ - name : Create the Operator Deployment
18
+ k8s :
19
+ namespace : ' {{ namespace }}'
20
+ definition : " {{ lookup('template', '/'.join([template_dir, 'operator.yaml.j2'])) }}"
21
+ wait : yes
22
+ vars :
23
+ image : ' {{ operator_image }}'
24
+ pull_policy : ' {{ operator_pull_policy }}'
Original file line number Diff line number Diff line change @@ -3,24 +3,22 @@ dependency:
3
3
name : galaxy
4
4
driver :
5
5
name : delegated
6
- lint :
7
- name : yamllint
8
- options :
9
- config-data :
10
- line-length :
11
- max : 120
6
+ lint : |
7
+ set -e
8
+ yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" .
12
9
platforms :
13
10
- name : cluster
14
11
groups :
15
12
- k8s
16
13
provisioner :
17
14
name : ansible
18
- lint :
19
- name : ansible-lint
15
+ lint : |
16
+ set -e
17
+ ansible-lint
20
18
inventory :
21
19
group_vars :
22
20
all :
23
- namespace : ${TEST_NAMESPACE :-osdk-test}
21
+ namespace : ${TEST_OPERATOR_NAMESPACE :-osdk-test}
24
22
host_vars :
25
23
localhost :
26
24
ansible_python_interpreter : ' {{ ansible_playbook_python }}'
@@ -32,5 +30,6 @@ provisioner:
32
30
K8S_AUTH_KUBECONFIG : ${KUBECONFIG:-"~/.kube/config"}
33
31
verifier :
34
32
name : ansible
35
- lint :
36
- name : ansible-lint
33
+ lint : |
34
+ set -e
35
+ ansible-lint
Original file line number Diff line number Diff line change
1
+ ---
2
+ - name : Converge
3
+ hosts : localhost
4
+ connection : local
5
+ roles :
6
+ - memcached
Original file line number Diff line number Diff line change @@ -3,19 +3,14 @@ dependency:
3
3
name : galaxy
4
4
driver :
5
5
name : docker
6
- lint :
7
- name : yamllint
8
- enabled : False
9
- options :
10
- config-data :
11
- line-length :
12
- max : 120
13
-
6
+ lint : |
7
+ set -e
8
+ yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" .
14
9
platforms :
15
10
- name : kind-default
16
11
groups :
17
12
- k8s
18
- image : bsycorp/kind:latest-${KUBE_VERSION:-1.16 }
13
+ image : bsycorp/kind:latest-${KUBE_VERSION:-1.17 }
19
14
privileged : True
20
15
override_command : no
21
16
exposed_ports :
@@ -27,13 +22,13 @@ platforms:
27
22
provisioner :
28
23
name : ansible
29
24
log : True
30
- lint :
31
- name : ansible-lint
32
- enabled : False
25
+ lint : |
26
+ set -e
27
+ ansible-lint
33
28
inventory :
34
29
group_vars :
35
30
all :
36
- namespace : ${TEST_NAMESPACE :-osdk-test}
31
+ namespace : ${TEST_OPERATOR_NAMESPACE :-osdk-test}
37
32
kubeconfig_file : ${MOLECULE_EPHEMERAL_DIRECTORY}/kubeconfig
38
33
host_vars :
39
34
localhost :
@@ -43,9 +38,8 @@ provisioner:
43
38
KUBECONFIG : ${MOLECULE_EPHEMERAL_DIRECTORY}/kubeconfig
44
39
ANSIBLE_ROLES_PATH : ${MOLECULE_PROJECT_DIRECTORY}/roles
45
40
KIND_PORT : ' ${TEST_CLUSTER_PORT:-9443}'
46
- scenario :
47
- name : default
48
41
verifier :
49
- name : testinfra
50
- lint :
51
- name : flake8
42
+ name : ansible
43
+ lint : |
44
+ set -e
45
+ ansible-lint
Original file line number Diff line number Diff line change 2
2
- name : Prepare
3
3
hosts : k8s
4
4
gather_facts : no
5
- vars :
6
- kubeconfig : " {{ lookup('env', 'KUBECONFIG') }}"
7
5
tasks :
8
- - name : delete the kubeconfig if present
9
- file :
10
- path : ' {{ kubeconfig }}'
11
- state : absent
12
- delegate_to : localhost
13
-
14
6
- name : Fetch the kubeconfig
15
7
fetch :
16
- dest : ' {{ kubeconfig }}'
8
+ dest : ' {{ kubeconfig_file }}'
17
9
flat : yes
18
10
src : /root/.kube/config
19
11
20
12
- name : Change the kubeconfig port to the proper value
21
13
replace :
22
14
regexp : ' 8443'
23
15
replace : " {{ lookup('env', 'KIND_PORT') }}"
24
- path : ' {{ kubeconfig }}'
16
+ path : ' {{ kubeconfig_file }}'
25
17
delegate_to : localhost
26
18
27
19
- name : Wait for the Kubernetes API to become available (this could take a minute)
Original file line number Diff line number Diff line change
1
+ ---
2
+ - name : Build Operator in Kubernetes docker container
3
+ hosts : k8s
4
+ collections :
5
+ - community.kubernetes
6
+
7
+ vars :
8
+ image : cache.example.com/memcached-operator:testing
9
+
10
+ tasks :
11
+ # using command so we don't need to install any dependencies
12
+ - name : Get existing image hash
13
+ command : docker images -q {{ image }}
14
+ register : prev_hash_raw
15
+ changed_when : false
16
+
17
+ - name : Build Operator Image
18
+ command : docker build -f /build/build/Dockerfile -t {{ image }} /build
19
+ register : build_cmd
20
+ changed_when : not hash or (hash and hash not in cmd_out)
21
+ vars :
22
+ hash : ' {{ prev_hash_raw.stdout }}'
23
+ cmd_out : ' {{ "".join(build_cmd.stdout_lines[-2:]) }}'
24
+
25
+ - name : Converge
26
+ hosts : localhost
27
+ connection : local
28
+ collections :
29
+ - community.kubernetes
30
+
31
+ vars :
32
+ image : cache.example.com/memcached-operator:testing
33
+ operator_template : " {{ '/'.join([template_dir, 'operator.yaml.j2']) }}"
34
+
35
+ tasks :
36
+ - name : Create the Operator Deployment
37
+ k8s :
38
+ namespace : ' {{ namespace }}'
39
+ definition : " {{ lookup('template', operator_template) }}"
40
+ wait : yes
41
+ vars :
42
+ pull_policy : Never
Original file line number Diff line number Diff line change @@ -3,19 +3,14 @@ dependency:
3
3
name : galaxy
4
4
driver :
5
5
name : docker
6
- lint :
7
- name : yamllint
8
- enabled : False
9
- options :
10
- config-data :
11
- line-length :
12
- max : 120
13
-
6
+ lint : |
7
+ set -e
8
+ yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" .
14
9
platforms :
15
10
- name : kind-test-local
16
11
groups :
17
12
- k8s
18
- image : bsycorp/kind:latest-${KUBE_VERSION:-1.16 }
13
+ image : bsycorp/kind:latest-${KUBE_VERSION:-1.17 }
19
14
privileged : true
20
15
override_command : false
21
16
exposed_ports :
@@ -28,14 +23,13 @@ platforms:
28
23
- ${MOLECULE_PROJECT_DIRECTORY}:/build:Z
29
24
provisioner :
30
25
name : ansible
31
- log : True
26
+ log : true
32
27
lint :
33
28
name : ansible-lint
34
- enabled : False
35
29
inventory :
36
30
group_vars :
37
31
all :
38
- namespace : ${TEST_NAMESPACE :-osdk-test}
32
+ namespace : ${TEST_OPERATOR_NAMESPACE :-osdk-test}
39
33
kubeconfig_file : ${MOLECULE_EPHEMERAL_DIRECTORY}/kubeconfig
40
34
host_vars :
41
35
localhost :
@@ -61,6 +55,6 @@ scenario:
61
55
- verify
62
56
- destroy
63
57
verifier :
64
- name : testinfra
58
+ name : ansible
65
59
lint :
66
- name : flake8
60
+ name : ansible-lint
You can’t perform that action at this time.
0 commit comments