-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathprepare.yml
84 lines (74 loc) · 2.31 KB
/
prepare.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
---
- name: Prepare for Molecule Test
hosts: k8s
gather_facts: no
vars:
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
tasks:
- name: delete the kubeconfig if present
file:
path: '{{ kubeconfig }}'
state: absent
delegate_to: localhost
- name: Fetch the kubeconfig
fetch:
dest: '{{ kubeconfig }}'
flat: yes
src: /root/.kube/config
- name: Change the kubeconfig port to the proper value
replace:
regexp: '8443'
replace: "{{ lookup('env', 'KIND_PORT') }}"
path: '{{ kubeconfig }}'
delegate_to: localhost
- name: Wait for the Kubernetes API to become available (this could take a minute)
uri:
url: "http://localhost:10080/kubernetes-ready"
status_code: 200
validate_certs: no
register: result
until: (result.status|default(-1)) == 200
retries: 60
delay: 5
- name: Prepare operator resources for Molecule Test
hosts: localhost
connection: local
vars:
ansible_python_interpreter: '{{ ansible_playbook_python }}'
deploy_dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/deploy"
tasks:
- name: Create Custom Resource Definition
k8s:
definition: "{{ lookup('file', '/'.join([deploy_dir, 'crds/inventory.apps.fabianism.us_inventorys_crd.yaml'])) }}"
- name: Ensure specified namespace is present
k8s:
api_version: v1
kind: Namespace
name: '{{ namespace }}'
- name: Create RBAC resources
k8s:
definition: "{{ lookup('template', '/'.join([deploy_dir, item])) }}"
namespace: '{{ namespace }}'
with_items:
- role.yaml
- role_binding.yaml
- service_account.yaml
- name: Dump the dev image
command: docker save -o /tmp/dev-operator.tar quay.io/operator-framework/ansible-operator:dev
- name: Copy the image to the kind container
command: docker cp /tmp/dev-operator.tar kind-test-local:/dev-operator.tar
- name: Make dev operator image available for Molecule Test
hosts: k8s
gather_facts: no
tasks:
- name: Make dev operator available
command: docker load -i /dev-operator.tar
- name: Clean up for Molecule Test
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: remove dev-operator.tar
file:
path: /tmp/dev-operator.tar
state: absent