|
100 | 100 | suffix: .testkustomize
|
101 | 101 | register: _tmp_dir_kustomize
|
102 | 102 |
|
103 |
| - # - name: Create a base directory |
104 |
| - # ansible.builtin.file: |
105 |
| - # path: "{{ _tmp_dir_kustomize.path }}/base" |
106 |
| - # state: directory |
107 |
| - # mode: '0755' |
108 |
| - |
109 | 103 | - name: Download helloWorld example
|
110 | 104 | ansible.builtin.get_url:
|
111 |
| - url: "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/examples/helloWorld/{{ item }}.yaml" |
| 105 | + url: "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/refs/heads/master/examples/loadHttp/kustomization.yaml" |
112 | 106 | dest: "{{ _tmp_dir_kustomize.path }}"
|
113 |
| - with_items: |
114 |
| - - configMap |
115 |
| - - deployment |
116 |
| - - kustomization |
117 |
| - - service |
118 | 107 |
|
119 |
| - - name: Replace label in kustomization.yaml |
| 108 | + - name: Run tinyproxy in docker |
120 | 109 | # Replace the 'app: hello' with 'app: ${TEST_APP}'
|
121 |
| - ansible.builtin.replace: |
122 |
| - path: "{{ _tmp_dir_kustomize.path }}/kustomization.yaml" |
123 |
| - regexp: 'app: hello' |
124 |
| - replace: 'app: ${TEST_APP}' |
| 110 | + ansible.builtin.command: "docker run --rm -d -p {{ proxy_port }}:8888 --name=tinyproxy dannydirect/tinyproxy" |
125 | 111 |
|
126 | 112 | - name: Test kustomize lookup plugin with environment variables in the string format
|
127 | 113 | set_fact:
|
128 |
| - resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment='TEST_APP=testpassed VAR2=Flase') }}" |
| 114 | + resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment='HTTPS_PROXY=http://localhost:8888 VAR2=Flase') }}" |
129 | 115 |
|
130 | 116 | - ansible.builtin.debug:
|
131 | 117 | var: resource_kustomize
|
132 | 118 |
|
133 |
| - - name: Assest that TEST_APP is replaced with testpassed |
134 |
| - assert: |
135 |
| - that: "'app: testpassed' in resource_kustomize.string" |
136 |
| - fail_msg: "kustomize lookup plugin with environment variables in the string format failed" |
137 |
| - |
138 | 119 | - name: Test kustomize lookup plugin with environment variables in the list format
|
139 | 120 | set_fact:
|
140 |
| - resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment={TEST_APP=testpassed, VAR2=Flase}) }}" |
| 121 | + resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment={HTTPS_PROXY=http://localhost:8888, VAR2=Flase}) }}" |
141 | 122 |
|
142 | 123 | - ansible.builtin.debug:
|
143 | 124 | var: resource_kustomize
|
144 | 125 |
|
145 |
| - - name: Assest that TEST_APP is replaced with testpassed |
146 |
| - assert: |
147 |
| - that: "'app: testpassed' in resource_kustomize.string" |
148 |
| - fail_msg: "kustomize lookup plugin with environment variables in the list format failed" |
| 126 | + - name: Stop tinyproxy |
| 127 | + ansible.builtin.command: "docker stop tinyproxy" |
149 | 128 |
|
| 129 | + - name: Ensure kustomize lookup plugin fail with proxy down |
| 130 | + set_fact: |
| 131 | + resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment='HTTPS_PROXY=http://localhost:{{ proxy_port }} VAR2=Flase') }}" |
| 132 | + ignore_errors: true |
| 133 | + register: result |
| 134 | + |
| 135 | + - ansible.builtin.debug: |
| 136 | + var: result |
| 137 | + |
| 138 | + - name: Ensure kustomize lookup plugin fail with proxy down |
| 139 | + set_fact: |
| 140 | + resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment={HTTPS_PROXY=http://localhost:{{ proxy_port }}, VAR2=Flase}) }}" |
| 141 | + ignore_errors: true |
| 142 | + register: result |
| 143 | + |
| 144 | + - ansible.builtin.debug: |
| 145 | + var: result |
150 | 146 |
|
151 | 147 | always:
|
152 | 148 | - name: Delete namespace
|
|
163 | 159 | with_items:
|
164 | 160 | - "{{ tmp_dir_path }}"
|
165 | 161 | - "{{ _tmp_dir_kustomize.path }}"
|
| 162 | + |
| 163 | + - name: Stop tinyproxy |
| 164 | + ansible.builtin.command: "docker stop tinyproxy" |
0 commit comments