|
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" |
| 111 | + |
| 112 | + - nane: Ensure that tinyproxy is running |
| 113 | + ansible.builtin.uri: |
| 114 | + host: http://tinyproxy.stats/ |
| 115 | + use_proxy: true |
| 116 | + status_code: 200 |
| 117 | + environment: |
| 118 | + HTTPS_PROXY: http://localhost:8888 |
| 119 | + register: result |
| 120 | + retries: 3 |
| 121 | + delay: 10 |
| 122 | + until: result.status == 200 |
125 | 123 |
|
126 | 124 | - name: Test kustomize lookup plugin with environment variables in the string format
|
127 | 125 | set_fact:
|
128 |
| - resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment='TEST_APP=testpassed VAR2=Flase') }}" |
| 126 | + resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment='HTTPS_PROXY=http://localhost:8888 VAR2=Flase') }}" |
| 127 | + ignore_errors: true |
129 | 128 |
|
130 | 129 | - ansible.builtin.debug:
|
131 | 130 | var: resource_kustomize
|
132 | 131 |
|
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 | 132 | - name: Test kustomize lookup plugin with environment variables in the list format
|
139 | 133 | set_fact:
|
140 |
| - resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment={TEST_APP=testpassed, VAR2=Flase}) }}" |
| 134 | + resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment={HTTPS_PROXY=http://localhost:8888, VAR2=Flase}) }}" |
| 135 | + ignore_errors: true |
141 | 136 |
|
142 | 137 | - ansible.builtin.debug:
|
143 | 138 | var: resource_kustomize
|
144 | 139 |
|
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" |
| 140 | + - name: Stop tinyproxy |
| 141 | + ansible.builtin.command: "docker stop tinyproxy" |
| 142 | + |
| 143 | + - name: Ensure kustomize lookup plugin fail with proxy down |
| 144 | + set_fact: |
| 145 | + resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment='HTTPS_PROXY=http://localhost:{{ proxy_port }} VAR2=Flase') }}" |
| 146 | + ignore_errors: true |
| 147 | + register: result |
| 148 | + |
| 149 | + - ansible.builtin.debug: |
| 150 | + var: result |
149 | 151 |
|
| 152 | + - name: Ensure kustomize lookup plugin fail with proxy down |
| 153 | + set_fact: |
| 154 | + resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment={HTTPS_PROXY=http://localhost:{{ proxy_port }}, VAR2=Flase}) }}" |
| 155 | + ignore_errors: true |
| 156 | + register: result |
| 157 | + |
| 158 | + - ansible.builtin.debug: |
| 159 | + var: result |
150 | 160 |
|
151 | 161 | always:
|
152 | 162 | - name: Delete namespace
|
|
163 | 173 | with_items:
|
164 | 174 | - "{{ tmp_dir_path }}"
|
165 | 175 | - "{{ _tmp_dir_kustomize.path }}"
|
| 176 | + |
| 177 | + - name: Stop tinyproxy |
| 178 | + ansible.builtin.command: "docker stop tinyproxy" |
| 179 | + ignore_errors: true |
0 commit comments