From 4094c309c45c998deb94208ba68fa2f5e2b8abba Mon Sep 17 00:00:00 2001 From: aubin Date: Wed, 14 Apr 2021 16:27:41 +0200 Subject: [PATCH 01/48] add option proxy_headers for k8s modules --- .../50-add-support-for-proxy_headers-on-authentication | 3 +++ plugins/doc_fragments/k8s_auth_options.py | 5 +++++ plugins/module_utils/args_common.py | 5 +++++ plugins/module_utils/common.py | 4 +++- 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/50-add-support-for-proxy_headers-on-authentication diff --git a/changelogs/fragments/50-add-support-for-proxy_headers-on-authentication b/changelogs/fragments/50-add-support-for-proxy_headers-on-authentication new file mode 100644 index 0000000000..0a60d4a81e --- /dev/null +++ b/changelogs/fragments/50-add-support-for-proxy_headers-on-authentication @@ -0,0 +1,3 @@ +--- +minor_changes: + - add ``proxy_headers`` option for authentication on k8s_xxx modules (https://github.com/ansible-collections/kubernetes.core/pull/50). \ No newline at end of file diff --git a/plugins/doc_fragments/k8s_auth_options.py b/plugins/doc_fragments/k8s_auth_options.py index 540f833d54..ee809f1d27 100644 --- a/plugins/doc_fragments/k8s_auth_options.py +++ b/plugins/doc_fragments/k8s_auth_options.py @@ -75,6 +75,11 @@ class ModuleDocFragment(object): - The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable. - Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY). type: str + proxy_headers: + description: + - The login for the HTTP proxy. Can also be specified via K8S_AUTH_PROXY_HEADERS environment variable. + type: str + version_added: 2.0.0 persist_config: description: - Whether or not to save the kube config refresh tokens. diff --git a/plugins/module_utils/args_common.py b/plugins/module_utils/args_common.py index fadaf44e66..7278363432 100644 --- a/plugins/module_utils/args_common.py +++ b/plugins/module_utils/args_common.py @@ -43,6 +43,10 @@ def list_dict_str(value): 'proxy': { 'type': 'str', }, + 'proxy_headers': { + 'type': 'str', + 'no_log': True + }, 'persist_config': { 'type': 'bool', }, @@ -76,6 +80,7 @@ def list_dict_str(value): 'cert_file': 'client_cert', 'key_file': 'client_key', 'proxy': 'proxy', + 'proxy_headers': 'proxy_headers', 'persist_config': 'persist_config', } diff --git a/plugins/module_utils/common.py b/plugins/module_utils/common.py index b4630afe68..b61880c8bc 100644 --- a/plugins/module_utils/common.py +++ b/plugins/module_utils/common.py @@ -34,7 +34,6 @@ from ansible.module_utils.common.dict_transformations import dict_merge from ansible.module_utils.parsing.convert_bool import boolean - K8S_IMP_ERR = None try: import kubernetes @@ -173,6 +172,9 @@ def auth_set(*names): if key in AUTH_ARG_MAP.keys() and value is not None: if key == 'api_key': setattr(configuration, key, {'authorization': "Bearer {0}".format(value)}) + elif key == 'proxy_headers': + headers = urllib3.make_headers(proxy_basic_auth=value) + setattr(configuration, key, headers) else: setattr(configuration, key, value) From 9e065f5182bc79881e0d0ee423b9ba93cf290c81 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Wed, 14 Apr 2021 16:46:36 +0200 Subject: [PATCH 02/48] Update and rename 50-add-support-for-proxy_headers-on-authentication to 58-add-support-for-proxy_headers-on-authentication.yaml --- ... => 58-add-support-for-proxy_headers-on-authentication.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename changelogs/fragments/{50-add-support-for-proxy_headers-on-authentication => 58-add-support-for-proxy_headers-on-authentication.yaml} (94%) diff --git a/changelogs/fragments/50-add-support-for-proxy_headers-on-authentication b/changelogs/fragments/58-add-support-for-proxy_headers-on-authentication.yaml similarity index 94% rename from changelogs/fragments/50-add-support-for-proxy_headers-on-authentication rename to changelogs/fragments/58-add-support-for-proxy_headers-on-authentication.yaml index 0a60d4a81e..a887cb1d47 100644 --- a/changelogs/fragments/50-add-support-for-proxy_headers-on-authentication +++ b/changelogs/fragments/58-add-support-for-proxy_headers-on-authentication.yaml @@ -1,3 +1,3 @@ --- minor_changes: - - add ``proxy_headers`` option for authentication on k8s_xxx modules (https://github.com/ansible-collections/kubernetes.core/pull/50). \ No newline at end of file + - add ``proxy_headers`` option for authentication on k8s_xxx modules (https://github.com/ansible-collections/kubernetes.core/pull/58). From 4063e5185b86c435da9bd92aa942e02c9cb7cc2f Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 19 Apr 2021 17:26:44 +0200 Subject: [PATCH 03/48] update proxy_headers details --- .gitignore | 1 + molecule/default/molecule.yml | 10 ++++++++++ plugins/doc_fragments/k8s_auth_options.py | 21 +++++++++++++++++++-- plugins/module_utils/args_common.py | 10 ++++++++-- plugins/module_utils/common.py | 15 +++++++++++++-- 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index f97b78751b..01b4466ae0 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ changelogs/.plugin-cache.yaml # Temporary test files. tests/output tests/integration/cloud-config-* +.cache diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 15895965ca..f10f75b523 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -12,6 +12,16 @@ lint: | flake8 platforms: - name: instance-kind + image: sameersbn/squid:3.5.27-2 + exposed_ports: + - 3128/tcp + published_ports: + - 0.0.0.0:3128:3128/tcp + volumes: + - squid.passwd:/etc/squid/passwd + - squid.conf:/etc/squid/squid.conf + privileged: true + provisioner: name: ansible log: true diff --git a/plugins/doc_fragments/k8s_auth_options.py b/plugins/doc_fragments/k8s_auth_options.py index ee809f1d27..1962ba94f3 100644 --- a/plugins/doc_fragments/k8s_auth_options.py +++ b/plugins/doc_fragments/k8s_auth_options.py @@ -77,9 +77,26 @@ class ModuleDocFragment(object): type: str proxy_headers: description: - - The login for the HTTP proxy. Can also be specified via K8S_AUTH_PROXY_HEADERS environment variable. - type: str + - The login for the HTTP proxy. + - Documentation can be found here 'https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers' + type: dict version_added: 2.0.0 + suboptions: + proxy_basic_auth: + type: str + description: + - Colon-separated username:password string for ‘proxy-authorization: basic …’ auth header. + - Can also be specified via K8S_AUTH_PROXY_HEADERS_PROXY_BASIC_AUTH environment. + basic_auth: + type: str + description: + - Colon-separated username:password string for ‘authorization: basic …’ auth header. + - Can also be specified via K8S_AUTH_PROXY_HEADERS_BASIC_AUTH environment. + user_agent: + type: str + description: + - String representing the user-agent you want, such as “foo/1.0”. + - Can also be specified via K8S_AUTH_PROXY_HEADERS_USER_AGENT environment. persist_config: description: - Whether or not to save the kube config refresh tokens. diff --git a/plugins/module_utils/args_common.py b/plugins/module_utils/args_common.py index 7278363432..67c183db74 100644 --- a/plugins/module_utils/args_common.py +++ b/plugins/module_utils/args_common.py @@ -11,6 +11,12 @@ def list_dict_str(value): raise TypeError +AUTH_PROXY_HEADERS_SPEC = dict( + proxy_basic_auth=dict(type='str', no_log=True), + basic_auth=dict(type='str', no_log=True), + user_agent=dict(type='str') +) + AUTH_ARG_SPEC = { 'kubeconfig': { 'type': 'path', @@ -44,8 +50,8 @@ def list_dict_str(value): 'type': 'str', }, 'proxy_headers': { - 'type': 'str', - 'no_log': True + 'type': 'dict', + 'options': AUTH_PROXY_HEADERS_SPEC }, 'persist_config': { 'type': 'bool', diff --git a/plugins/module_utils/common.py b/plugins/module_utils/common.py index b61880c8bc..54369b20f3 100644 --- a/plugins/module_utils/common.py +++ b/plugins/module_utils/common.py @@ -26,7 +26,7 @@ from datetime import datetime from distutils.version import LooseVersion -from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (AUTH_ARG_MAP, AUTH_ARG_SPEC) +from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (AUTH_ARG_MAP, AUTH_ARG_SPEC, AUTH_PROXY_HEADERS_SPEC) from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.six import iteritems, string_types @@ -132,6 +132,17 @@ def _raise_or_fail(exc, msg): auth[true_name] = module.params.get(arg_name) elif arg_name in kwargs and kwargs.get(arg_name) is not None: auth[true_name] = kwargs.get(arg_name) + elif arg_name == "proxy_headers": + # specific case for 'proxy_headers' which is a dictionary + proxy_headers = {} + for key in AUTH_PROXY_HEADERS_SPEC.keys(): + env_value = os.getenv('K8S_AUTH_PROXY_HEADERS_{0}'.format(key.upper()), None) + if env_value is not None: + if AUTH_PROXY_HEADERS_SPEC[key].get('type') == 'bool': + env_value = env_value.lower() not in ['0', 'false', 'no'] + proxy_headers[key] = env_value + if proxy_headers is not {}: + auth[true_name] = proxy_headers else: env_value = os.getenv('K8S_AUTH_{0}'.format(arg_name.upper()), None) or os.getenv('K8S_AUTH_{0}'.format(true_name.upper()), None) if env_value is not None: @@ -173,7 +184,7 @@ def auth_set(*names): if key == 'api_key': setattr(configuration, key, {'authorization': "Bearer {0}".format(value)}) elif key == 'proxy_headers': - headers = urllib3.make_headers(proxy_basic_auth=value) + headers = urllib3.make_headers(**value) setattr(configuration, key, headers) else: setattr(configuration, key, value) From 312470dd8d53845e7ce01e08d78a47663330e7be Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 19 Apr 2021 18:00:34 +0200 Subject: [PATCH 04/48] sanity test --- plugins/doc_fragments/k8s_auth_options.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/doc_fragments/k8s_auth_options.py b/plugins/doc_fragments/k8s_auth_options.py index 1962ba94f3..355436a5a3 100644 --- a/plugins/doc_fragments/k8s_auth_options.py +++ b/plugins/doc_fragments/k8s_auth_options.py @@ -85,17 +85,17 @@ class ModuleDocFragment(object): proxy_basic_auth: type: str description: - - Colon-separated username:password string for ‘proxy-authorization: basic …’ auth header. + - Colon-separated username:password for proxy basic authentication header. - Can also be specified via K8S_AUTH_PROXY_HEADERS_PROXY_BASIC_AUTH environment. basic_auth: type: str description: - - Colon-separated username:password string for ‘authorization: basic …’ auth header. + - Colon-separated username:password for basic authentication header. - Can also be specified via K8S_AUTH_PROXY_HEADERS_BASIC_AUTH environment. user_agent: type: str description: - - String representing the user-agent you want, such as “foo/1.0”. + - String representing the user-agent you want, such as foo/1.0. - Can also be specified via K8S_AUTH_PROXY_HEADERS_USER_AGENT environment. persist_config: description: From 2b8fef64920d5adf178af3ea0861028242991558 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 10:07:05 +0200 Subject: [PATCH 05/48] Update .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 01b4466ae0..f97b78751b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,3 @@ changelogs/.plugin-cache.yaml # Temporary test files. tests/output tests/integration/cloud-config-* -.cache From 1b7bb569dc76f2aec4d1231201ae0323de596890 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 10:07:53 +0200 Subject: [PATCH 06/48] Update molecule.yml --- molecule/default/molecule.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index f10f75b523..15895965ca 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -12,16 +12,6 @@ lint: | flake8 platforms: - name: instance-kind - image: sameersbn/squid:3.5.27-2 - exposed_ports: - - 3128/tcp - published_ports: - - 0.0.0.0:3128:3128/tcp - volumes: - - squid.passwd:/etc/squid/passwd - - squid.conf:/etc/squid/squid.conf - privileged: true - provisioner: name: ansible log: true From d66f84a89e2b8a0c53859c816c1c0c4fec5d3131 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 10:08:05 +0200 Subject: [PATCH 07/48] Update plugins/doc_fragments/k8s_auth_options.py Co-authored-by: Abhijeet Kasurde --- plugins/doc_fragments/k8s_auth_options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/doc_fragments/k8s_auth_options.py b/plugins/doc_fragments/k8s_auth_options.py index 355436a5a3..b895d8e90e 100644 --- a/plugins/doc_fragments/k8s_auth_options.py +++ b/plugins/doc_fragments/k8s_auth_options.py @@ -77,7 +77,7 @@ class ModuleDocFragment(object): type: str proxy_headers: description: - - The login for the HTTP proxy. + - The Header used for the HTTP proxy. - Documentation can be found here 'https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers' type: dict version_added: 2.0.0 From c6b0b9e57823a5ed3ebd10e02008c760d83cf2b3 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 10:08:14 +0200 Subject: [PATCH 08/48] Update plugins/doc_fragments/k8s_auth_options.py Co-authored-by: Abhijeet Kasurde --- plugins/doc_fragments/k8s_auth_options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/doc_fragments/k8s_auth_options.py b/plugins/doc_fragments/k8s_auth_options.py index b895d8e90e..0b04f61546 100644 --- a/plugins/doc_fragments/k8s_auth_options.py +++ b/plugins/doc_fragments/k8s_auth_options.py @@ -78,7 +78,7 @@ class ModuleDocFragment(object): proxy_headers: description: - The Header used for the HTTP proxy. - - Documentation can be found here 'https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers' + - Documentation can be found here U(https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers). type: dict version_added: 2.0.0 suboptions: From 2c496129724ae7a3e9d89868161813167f091791 Mon Sep 17 00:00:00 2001 From: aubin Date: Tue, 20 Apr 2021 10:26:10 +0200 Subject: [PATCH 09/48] deploy proxy on ci workflow --- .github/workflows/ci.yml | 9 +++++++++ molecule/default/files/squid.conf | 10 ++++++++++ molecule/default/files/squid.passwd | 1 + 3 files changed, 20 insertions(+) create mode 100644 molecule/default/files/squid.conf create mode 100644 molecule/default/files/squid.passwd diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c05f7321c..65a8e834bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,7 @@ jobs: strategy: matrix: python_version: ['3.7'] + proxy_port: 3128 steps: - name: Check out code uses: actions/checkout@v2 @@ -84,6 +85,14 @@ jobs: with: python-version: ${{ matrix.python_version }} + # deploy a proxy for authentication with username=ansible and password=test + - name: Build the container image + run: | + set -eux + docker run --name squid -d --restart=always --publish ${{ proxy_port }}:3128 -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + docker logs squid + curl -x http://127.0.0.1:${{ proxy_port }} --proxy-user ansible:test -I https://github.com + # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 - name: Install molecule and openshift dependencies diff --git a/molecule/default/files/squid.conf b/molecule/default/files/squid.conf new file mode 100644 index 0000000000..1a542a586a --- /dev/null +++ b/molecule/default/files/squid.conf @@ -0,0 +1,10 @@ +http_port 3128 +acl SSL_ports port 443 +acl CONNECT method CONNECT + +auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd +auth_param basic children 5 +auth_param basic realm Squid Basic Authentication +auth_param basic credentialsttl 2 hours +acl auth_users proxy_auth REQUIRED +http_access allow auth_users diff --git a/molecule/default/files/squid.passwd b/molecule/default/files/squid.passwd new file mode 100644 index 0000000000..ee8917cc8f --- /dev/null +++ b/molecule/default/files/squid.passwd @@ -0,0 +1 @@ +ansible:$apr1$SNezRr1E$5iTPBCbVCrJun1DsMLjM0. From de5163de8ac6501b173520d2d2704d0797c92f42 Mon Sep 17 00:00:00 2001 From: aubin Date: Tue, 20 Apr 2021 10:52:06 +0200 Subject: [PATCH 10/48] proxy testing --- .github/workflows/ci.yml | 2 +- molecule/default/converge.yml | 1 + molecule/default/tasks/proxy.yml | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 molecule/default/tasks/proxy.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65a8e834bb..c8e67cb6bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,7 +86,7 @@ jobs: python-version: ${{ matrix.python_version }} # deploy a proxy for authentication with username=ansible and password=test - - name: Build the container image + - name: Set up a squid proxy run: | set -eux docker run --name squid -d --restart=always --publish ${{ proxy_port }}:3128 -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 076cbc165d..4874e33c18 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -31,6 +31,7 @@ - include_tasks: tasks/access_review.yml - include_tasks: tasks/rollback.yml - include_tasks: tasks/gc.yml + - include_tasks: tasks/proxy.yml roles: - helm diff --git a/molecule/default/tasks/proxy.yml b/molecule/default/tasks/proxy.yml new file mode 100644 index 0000000000..51c74ffbdc --- /dev/null +++ b/molecule/default/tasks/proxy.yml @@ -0,0 +1,29 @@ +--- +- name: cluster info + k8s_cluster_info: + proxy: http://127.0.0.1:3128 + proxy_headers: + proxy_basic_auth: ansible:test + +- name: bad credentials + k8s_cluster_info: + proxy: http://127.0.0.1:3128 + proxy_headers: + proxy_basic_auth: ansible:uuuu + ignore_errors: true + register: bad_cred + +- name: ensure connection failed + assert: + that: + - bad_cred is failed + +- name: create namespace + k8s: + definition: + kind: namespace + metadata: + name: squid + proxy: http://127.0.0.1:3128 + proxy_headers: + proxy_basic_auth: ansible:test \ No newline at end of file From fe431dc559ca5960bfeeac9dd6636658d3e961c8 Mon Sep 17 00:00:00 2001 From: aubin Date: Tue, 20 Apr 2021 12:59:24 +0200 Subject: [PATCH 11/48] linting --- molecule/default/tasks/proxy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule/default/tasks/proxy.yml b/molecule/default/tasks/proxy.yml index 51c74ffbdc..04bbcc1c35 100644 --- a/molecule/default/tasks/proxy.yml +++ b/molecule/default/tasks/proxy.yml @@ -26,4 +26,4 @@ name: squid proxy: http://127.0.0.1:3128 proxy_headers: - proxy_basic_auth: ansible:test \ No newline at end of file + proxy_basic_auth: ansible:test From 0732eb47f7a7c73823382a0a5e15f7ff4ae5435a Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 13:00:58 +0200 Subject: [PATCH 12/48] Update ci.yml --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8e67cb6bc..0628c52383 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,7 +70,6 @@ jobs: strategy: matrix: python_version: ['3.7'] - proxy_port: 3128 steps: - name: Check out code uses: actions/checkout@v2 @@ -89,9 +88,9 @@ jobs: - name: Set up a squid proxy run: | set -eux - docker run --name squid -d --restart=always --publish ${{ proxy_port }}:3128 -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + docker run --name squid -d --restart=always --publish 3128:3128 -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 docker logs squid - curl -x http://127.0.0.1:${{ proxy_port }} --proxy-user ansible:test -I https://github.com + curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From 419ce8bc5b6935835cb98d31d42c34922ddb9318 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 14:42:41 +0200 Subject: [PATCH 13/48] Update ci.yml --- .github/workflows/ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0628c52383..0c05f7321c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,14 +84,6 @@ jobs: with: python-version: ${{ matrix.python_version }} - # deploy a proxy for authentication with username=ansible and password=test - - name: Set up a squid proxy - run: | - set -eux - docker run --name squid -d --restart=always --publish 3128:3128 -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 - docker logs squid - curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com - # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 - name: Install molecule and openshift dependencies From a40a659f27fa3186a8ffead8b28e3d9d749385dc Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 14:51:30 +0200 Subject: [PATCH 14/48] Update ci.yml --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c05f7321c..924e1518d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,14 @@ jobs: uses: actions/setup-python@v1 with: python-version: ${{ matrix.python_version }} + + # deploy a proxy for authentication with username=ansible and password=test + - name: Set up a squid proxy + run: | + set -eux + docker run --name squid -d --restart=always --publish 3128:3128 -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + docker logs squid + curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From ac782f2461621b47ae2ab71ddd3793238de5fc9b Mon Sep 17 00:00:00 2001 From: aubin Date: Tue, 20 Apr 2021 15:05:40 +0200 Subject: [PATCH 15/48] add checks --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 924e1518d3..37ff334ce5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,9 +88,14 @@ jobs: - name: Set up a squid proxy run: | set -eux - docker run --name squid -d --restart=always --publish 3128:3128 -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + stat ${GITHUB_WORKSPACE}/${squid_config} + stat ${GITHUB_WORKSPACE}/${squid_pwd} + docker run --name squid -d --restart=always --publish 3128:3128 -v ${GITHUB_WORKSPACE}/${squid_pwd}:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/${squid_config}:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 docker logs squid curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com + with: + squid_config: molecule/default/files/squid.conf + squid_pwd: molecule/default/files/squid.passwd # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From ffbb0b55574a1d059247d1dddc598210c8127402 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 15:37:02 +0200 Subject: [PATCH 16/48] Update ci.yml --- .github/workflows/ci.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37ff334ce5..57ce701089 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,19 +84,6 @@ jobs: with: python-version: ${{ matrix.python_version }} - # deploy a proxy for authentication with username=ansible and password=test - - name: Set up a squid proxy - run: | - set -eux - stat ${GITHUB_WORKSPACE}/${squid_config} - stat ${GITHUB_WORKSPACE}/${squid_pwd} - docker run --name squid -d --restart=always --publish 3128:3128 -v ${GITHUB_WORKSPACE}/${squid_pwd}:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/${squid_config}:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 - docker logs squid - curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com - with: - squid_config: molecule/default/files/squid.conf - squid_pwd: molecule/default/files/squid.passwd - # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 - name: Install molecule and openshift dependencies From 2286fab90879dea295cebaeb02dc6b1678d1b6c2 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 15:37:38 +0200 Subject: [PATCH 17/48] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57ce701089..0c05f7321c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,7 +83,7 @@ jobs: uses: actions/setup-python@v1 with: python-version: ${{ matrix.python_version }} - + # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 - name: Install molecule and openshift dependencies From 7880c5ceabc70b436c24ea59f314d7af0a4ac297 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 15:47:04 +0200 Subject: [PATCH 18/48] Update ci.yml --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c05f7321c..07fd9ccfbb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,12 @@ jobs: uses: actions/setup-python@v1 with: python-version: ${{ matrix.python_version }} + + - name: Set up squid proxy via docker + run: | + set -eux + stat ${GITHUB_WORKSPACE}/molecule/default/files/squid.conf + stat ${GITHUB_WORKSPACE}/molecule/default/files/squid.passwd # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From 7e06935859fe2bd83641b1c0bea1d893702dfce4 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 16:29:03 +0200 Subject: [PATCH 19/48] Update ci.yml --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07fd9ccfbb..a3d1f1f305 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,8 +87,10 @@ jobs: - name: Set up squid proxy via docker run: | set -eux - stat ${GITHUB_WORKSPACE}/molecule/default/files/squid.conf - stat ${GITHUB_WORKSPACE}/molecule/default/files/squid.passwd + stat ${main_dir}/molecule/default/files/squid.conf + stat ${main_dir}/molecule/default/files/squid.passwd + with: + main_dir: /home/runner/ansible_collections/kubernetes/core # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From 62113c25dce135403a05835c93a29d593f78aa0b Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 16:29:45 +0200 Subject: [PATCH 20/48] Update ci.yml --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3d1f1f305..77b383259e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,10 +87,8 @@ jobs: - name: Set up squid proxy via docker run: | set -eux - stat ${main_dir}/molecule/default/files/squid.conf - stat ${main_dir}/molecule/default/files/squid.passwd - with: - main_dir: /home/runner/ansible_collections/kubernetes/core + stat /home/runner/ansible_collections/kubernetes/core/molecule/default/files/squid.conf + stat /home/runner/ansible_collections/kubernetes/core/molecule/default/files/squid.passwd # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From 56f59d09af4e7226948e32b3da8a64bee3a1d12f Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 16:36:25 +0200 Subject: [PATCH 21/48] Update ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77b383259e..ab2df01a3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,6 +87,7 @@ jobs: - name: Set up squid proxy via docker run: | set -eux + find /home/runner -name 'squid.conf' stat /home/runner/ansible_collections/kubernetes/core/molecule/default/files/squid.conf stat /home/runner/ansible_collections/kubernetes/core/molecule/default/files/squid.passwd From 9b098f207d35ca6791d15f80441ca82d54c9d086 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 16:48:51 +0200 Subject: [PATCH 22/48] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab2df01a3d..67e1a02dc7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,8 +88,8 @@ jobs: run: | set -eux find /home/runner -name 'squid.conf' - stat /home/runner/ansible_collections/kubernetes/core/molecule/default/files/squid.conf - stat /home/runner/ansible_collections/kubernetes/core/molecule/default/files/squid.passwd + stat /home/runner/work/kubernetes/kubernetes/core/molecule/default/files/squid.conf + stat /home/runner/work/kubernetes/kubernetes/core/molecule/default/files/squid.passwd # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From 4d710dd57bd565f68667147f7d243a7e76d02250 Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 16:57:04 +0200 Subject: [PATCH 23/48] Update ci.yml --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67e1a02dc7..e73d168daf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,8 +88,11 @@ jobs: run: | set -eux find /home/runner -name 'squid.conf' - stat /home/runner/work/kubernetes/kubernetes/core/molecule/default/files/squid.conf - stat /home/runner/work/kubernetes/kubernetes/core/molecule/default/files/squid.passwd + stat ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.conf + stat ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.passwd + docker run --name squid -d --restart=always --publish 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + docker logs squid + curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From bbc22868e85e5e5ea95892223b8f11c339a0643e Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Tue, 20 Apr 2021 17:03:09 +0200 Subject: [PATCH 24/48] Update ci.yml --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e73d168daf..3575538115 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,12 +87,8 @@ jobs: - name: Set up squid proxy via docker run: | set -eux - find /home/runner -name 'squid.conf' - stat ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.conf - stat ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.passwd docker run --name squid -d --restart=always --publish 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 docker logs squid - curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From e5c1cc498c1ad9acc60ec54540d6a21904d9e94a Mon Sep 17 00:00:00 2001 From: aubin Date: Tue, 20 Apr 2021 17:13:13 +0200 Subject: [PATCH 25/48] lint --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3575538115..eb5d4a3fd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,7 +83,7 @@ jobs: uses: actions/setup-python@v1 with: python-version: ${{ matrix.python_version }} - + - name: Set up squid proxy via docker run: | set -eux From 85bf728ad7e2e9d7c4628b5f135b45de9977baa4 Mon Sep 17 00:00:00 2001 From: aubin Date: Wed, 21 Apr 2021 17:16:09 +0200 Subject: [PATCH 26/48] test docker port --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb5d4a3fd1..9ef7b84021 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,7 +88,8 @@ jobs: run: | set -eux docker run --name squid -d --restart=always --publish 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 - docker logs squid + docker ps + docker port squid # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From 12afaa43617d76a88ae7d13992c825972a93fc20 Mon Sep 17 00:00:00 2001 From: aubin Date: Wed, 21 Apr 2021 17:25:18 +0200 Subject: [PATCH 27/48] bind local port --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ef7b84021..142f7e2a6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,9 +87,9 @@ jobs: - name: Set up squid proxy via docker run: | set -eux - docker run --name squid -d --restart=always --publish 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 - docker ps + docker run --name squid -d --restart=always -p 127.0.0.1:3128:3128/tcp -p 127.0.0.1:3128:3128/udp -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 docker port squid + curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From e6a5743a6cda1f61ab73ba772482212adcade804 Mon Sep 17 00:00:00 2001 From: aubin Date: Fri, 23 Apr 2021 17:44:33 +0200 Subject: [PATCH 28/48] molecule for proxy --- .github/workflows/ci.yml | 47 ++++++++++++++++--- Makefile | 3 ++ molecule/default/tasks/proxy.yml | 29 ------------ molecule/proxy/converge.yml | 47 +++++++++++++++++++ molecule/{default => proxy}/files/squid.conf | 0 .../{default => proxy}/files/squid.passwd | 0 molecule/proxy/molecule.yml | 38 +++++++++++++++ 7 files changed, 128 insertions(+), 36 deletions(-) delete mode 100644 molecule/default/tasks/proxy.yml create mode 100644 molecule/proxy/converge.yml rename molecule/{default => proxy}/files/squid.conf (100%) rename molecule/{default => proxy}/files/squid.passwd (100%) create mode 100644 molecule/proxy/molecule.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 142f7e2a6a..ffa8bc1756 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,13 +84,6 @@ jobs: with: python-version: ${{ matrix.python_version }} - - name: Set up squid proxy via docker - run: | - set -eux - docker run --name squid -d --restart=always -p 127.0.0.1:3128:3128/tcp -p 127.0.0.1:3128:3128/udp -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/default/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 - docker port squid - curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com - # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 - name: Install molecule and openshift dependencies @@ -119,6 +112,46 @@ jobs: run: make test-molecule working-directory: ./ansible_collections/kubernetes/core + proxy: + runs-on: ubuntu-latest + strategy: + matrix: + python_version: ['3.7'] + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + path: ansible_collections/kubernetes/core + + - name: Set up KinD cluster + uses: engineerd/setup-kind@v0.5.0 + + - name: Set up Python ${{ matrix.python_version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python_version }} + + - name: Set up squid proxy via docker + run: | + set -eux + docker run --name squid -d --restart=always -p 127.0.0.1:3128:3128/tcp -p 127.0.0.1:3128:3128/udp -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + docker port squid + curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com + + # The 3.3.0 release of molecule introduced a breaking change. See + # https://github.com/ansible-community/molecule/issues/3083 + - name: Install molecule and openshift dependencies + run: pip install ansible "molecule<3.3.0" yamllint openshift flake8 + + - name: Create default collection path symlink + run: | + mkdir -p /home/runner/.ansible + ln -s /home/runner/work/kubernetes/kubernetes /home/runner/.ansible/collections + + - name: Run molecule default test scenario + run: make test-molecule-proxy + working-directory: ./ansible_collections/kubernetes/core + unit: runs-on: ubuntu-latest strategy: diff --git a/Makefile b/Makefile index 5bd6613e76..15a23daa3f 100644 --- a/Makefile +++ b/Makefile @@ -27,5 +27,8 @@ test-integration: test-molecule: molecule test +test-molecule-proxy: + molecule test -s proxy + test-unit: ansible-test units --docker -v --color --python $(PYTHON_VERSION) $(?TEST_ARGS) diff --git a/molecule/default/tasks/proxy.yml b/molecule/default/tasks/proxy.yml deleted file mode 100644 index 04bbcc1c35..0000000000 --- a/molecule/default/tasks/proxy.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -- name: cluster info - k8s_cluster_info: - proxy: http://127.0.0.1:3128 - proxy_headers: - proxy_basic_auth: ansible:test - -- name: bad credentials - k8s_cluster_info: - proxy: http://127.0.0.1:3128 - proxy_headers: - proxy_basic_auth: ansible:uuuu - ignore_errors: true - register: bad_cred - -- name: ensure connection failed - assert: - that: - - bad_cred is failed - -- name: create namespace - k8s: - definition: - kind: namespace - metadata: - name: squid - proxy: http://127.0.0.1:3128 - proxy_headers: - proxy_basic_auth: ansible:test diff --git a/molecule/proxy/converge.yml b/molecule/proxy/converge.yml new file mode 100644 index 0000000000..e91b969cad --- /dev/null +++ b/molecule/proxy/converge.yml @@ -0,0 +1,47 @@ +--- +- name: Converge + hosts: localhost + connection: local + + collections: + - kubernetes.core + + tasks: + - name: Verify cluster is working. + k8s_info: + namespace: kube-system + kind: Pod + register: pod_list + + - name: Verify cluster has more than 5 pods running. + assert: + that: (pod_list.resources | count) > 5 + + - name: cluster info + k8s_cluster_info: + proxy: http://127.0.0.1:3128 + proxy_headers: + proxy_basic_auth: ansible:test + + - name: bad credentials + k8s_cluster_info: + proxy: http://127.0.0.1:3128 + proxy_headers: + proxy_basic_auth: ansible:uuuu + ignore_errors: true + register: bad_cred + + - name: ensure connection failed + assert: + that: + - bad_cred is failed + + - name: create namespace + k8s: + definition: + kind: namespace + metadata: + name: squid + proxy: http://127.0.0.1:3128 + proxy_headers: + proxy_basic_auth: ansible:test diff --git a/molecule/default/files/squid.conf b/molecule/proxy/files/squid.conf similarity index 100% rename from molecule/default/files/squid.conf rename to molecule/proxy/files/squid.conf diff --git a/molecule/default/files/squid.passwd b/molecule/proxy/files/squid.passwd similarity index 100% rename from molecule/default/files/squid.passwd rename to molecule/proxy/files/squid.passwd diff --git a/molecule/proxy/molecule.yml b/molecule/proxy/molecule.yml new file mode 100644 index 0000000000..4c5171a644 --- /dev/null +++ b/molecule/proxy/molecule.yml @@ -0,0 +1,38 @@ +--- +driver: + name: delegated + options: + managed: false + login_cmd_template: 'docker exec -ti {instance} bash' + ansible_connection_options: + ansible_connection: docker +lint: | + set -e + yamllint . + flake8 +platforms: + - name: instance-kind +provisioner: + name: ansible + log: true + config_options: + inventory: + enable_plugins: kubernetes.core.k8s + lint: {} + inventory: + hosts: + plugin: kubernetes.core.k8s + host_vars: + localhost: + ansible_python_interpreter: '{{ ansible_playbook_python }}' + env: + ANSIBLE_FORCE_COLOR: 'true' + options: + vvv: True +scenario: + name: proxy + test_sequence: + - lint + - syntax + - converge + - verify From 1518896e60655b71d8eae48d019dd20d5a87cc1f Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 10:33:09 +0200 Subject: [PATCH 29/48] test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffa8bc1756..21825030d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,7 +134,7 @@ jobs: - name: Set up squid proxy via docker run: | set -eux - docker run --name squid -d --restart=always -p 127.0.0.1:3128:3128/tcp -p 127.0.0.1:3128:3128/udp -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + docker run --name squid -d -p 127.0.0.1:3128:3128/tcp -p 127.0.0.1:3128:3128/udp -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 docker port squid curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com From 1c9f78d663245fc1a909b90cf5e6d7780af8ac7c Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 10:46:58 +0200 Subject: [PATCH 30/48] remove curl validation --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21825030d5..81e21eb32d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,7 +136,6 @@ jobs: set -eux docker run --name squid -d -p 127.0.0.1:3128:3128/tcp -p 127.0.0.1:3128:3128/udp -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 docker port squid - curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From 5893d007e866999982d9c2e22264f66ebddab122 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 11:04:36 +0200 Subject: [PATCH 31/48] remove curl validation --- molecule/proxy/converge.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/molecule/proxy/converge.yml b/molecule/proxy/converge.yml index e91b969cad..9d1ee4260b 100644 --- a/molecule/proxy/converge.yml +++ b/molecule/proxy/converge.yml @@ -17,6 +17,9 @@ assert: that: (pod_list.resources | count) > 5 + - name: test curl using command + command: curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com + - name: cluster info k8s_cluster_info: proxy: http://127.0.0.1:3128 From 1f06e726374fc10dbd0fbd100b914240d6ac5905 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 11:09:39 +0200 Subject: [PATCH 32/48] remove curl validation --- molecule/proxy/converge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule/proxy/converge.yml b/molecule/proxy/converge.yml index 9d1ee4260b..b73c85fb4c 100644 --- a/molecule/proxy/converge.yml +++ b/molecule/proxy/converge.yml @@ -19,7 +19,7 @@ - name: test curl using command command: curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com - + - name: cluster info k8s_cluster_info: proxy: http://127.0.0.1:3128 From 346607a4a655cf8dfe6781e8c8b15df438944505 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 11:32:05 +0200 Subject: [PATCH 33/48] remove curl validation --- .github/workflows/ci.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81e21eb32d..1afad76ef8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,6 +114,14 @@ jobs: proxy: runs-on: ubuntu-latest + services: + squid: + image: sameersbn/squid:3.5.27-2 + volumes: + - ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd + - ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf + ports: + - 3128:3128 strategy: matrix: python_version: ['3.7'] @@ -131,11 +139,15 @@ jobs: with: python-version: ${{ matrix.python_version }} - - name: Set up squid proxy via docker + - name: test proxy using curl command run: | - set -eux - docker run --name squid -d -p 127.0.0.1:3128:3128/tcp -p 127.0.0.1:3128:3128/udp -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 - docker port squid + curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com + + # - name: Set up squid proxy via docker + # run: | + # set -eux + # docker run --name squid -d -p 127.0.0.1:3128:3128/tcp -p 127.0.0.1:3128:3128/udp -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + # docker port squid # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From 973941380ccdd9d037632be3f3a4c51a9217799e Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 11:48:27 +0200 Subject: [PATCH 34/48] listen ports --- .github/workflows/ci.yml | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1afad76ef8..220a1ecaf5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,14 +114,6 @@ jobs: proxy: runs-on: ubuntu-latest - services: - squid: - image: sameersbn/squid:3.5.27-2 - volumes: - - ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd - - ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf - ports: - - 3128:3128 strategy: matrix: python_version: ['3.7'] @@ -143,11 +135,13 @@ jobs: run: | curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com - # - name: Set up squid proxy via docker - # run: | - # set -eux - # docker run --name squid -d -p 127.0.0.1:3128:3128/tcp -p 127.0.0.1:3128:3128/udp -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 - # docker port squid + - name: Set up squid proxy via docker + run: | + set -eux + docker run --name squid -d -p 127.0.0.1:3128:3128/tcp -p 127.0.0.1:3128:3128/udp -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + docker port squid + sleep 20 + netstat -vatn # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 From 0dc2081a0ec38db5f7f16ff54793d0adecb5f0d9 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 11:52:02 +0200 Subject: [PATCH 35/48] listen ports --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 220a1ecaf5..343389504d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,14 +131,10 @@ jobs: with: python-version: ${{ matrix.python_version }} - - name: test proxy using curl command - run: | - curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com - - name: Set up squid proxy via docker run: | set -eux - docker run --name squid -d -p 127.0.0.1:3128:3128/tcp -p 127.0.0.1:3128:3128/udp -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + docker run --name squid -d -p 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 docker port squid sleep 20 netstat -vatn From ce010eb8a9a0a57a8daba166edbe92b24a05fcc9 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 12:00:17 +0200 Subject: [PATCH 36/48] fake --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 343389504d..5381b7b23f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -137,6 +137,7 @@ jobs: docker run --name squid -d -p 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 docker port squid sleep 20 + iptables -I INPUT -p tcp --dport 3128 -j ACCEPT netstat -vatn # The 3.3.0 release of molecule introduced a breaking change. See From 4bd74133e7114bbf4de0e9b1b802cc221f55647b Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 12:25:03 +0200 Subject: [PATCH 37/48] test using script --- .github/workflows/ci.yml | 4 +-- plugins/module_utils/test_proxy_headers.py | 36 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 plugins/module_utils/test_proxy_headers.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5381b7b23f..96c689fab4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,9 +136,7 @@ jobs: set -eux docker run --name squid -d -p 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 docker port squid - sleep 20 - iptables -I INPUT -p tcp --dport 3128 -j ACCEPT - netstat -vatn + python ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/plugins/module_utils/test_proxy_headers.py # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 diff --git a/plugins/module_utils/test_proxy_headers.py b/plugins/module_utils/test_proxy_headers.py new file mode 100644 index 0000000000..3bc04237d4 --- /dev/null +++ b/plugins/module_utils/test_proxy_headers.py @@ -0,0 +1,36 @@ +# Copyright 2018 Red Hat | Ansible +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +import urllib3 + + +def main(): + try: + urllib3.disable_warnings() + params = {'keep_alive': True, 'proxy_basic_auth': "ansible:test"} + head = urllib3.util.make_headers(**params) + print("-- make_headers --") + proxy = urllib3.ProxyManager(proxy_url='http://localhost:3128/', proxy_headers=head) + print("-- ProxyManager --") + resp = proxy.request('GET', 'http://google.com/') + print("-- GET (status={}) --\n{}".format(resp.status, resp.headers)) + except Exception as e: + print("Raised => {}".format(e)) + + +if __name__ == '__main__': + main() From d8082703049c8ea21164677ac13644f9f241e1ac Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 12:28:48 +0200 Subject: [PATCH 38/48] add mandatory lib --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96c689fab4..c89d27ca35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,6 +131,11 @@ jobs: with: python-version: ${{ matrix.python_version }} + # The 3.3.0 release of molecule introduced a breaking change. See + # https://github.com/ansible-community/molecule/issues/3083 + - name: Install molecule and openshift dependencies + run: pip install ansible "molecule<3.3.0" yamllint openshift flake8 urllib3 + - name: Set up squid proxy via docker run: | set -eux @@ -138,11 +143,6 @@ jobs: docker port squid python ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/plugins/module_utils/test_proxy_headers.py - # The 3.3.0 release of molecule introduced a breaking change. See - # https://github.com/ansible-community/molecule/issues/3083 - - name: Install molecule and openshift dependencies - run: pip install ansible "molecule<3.3.0" yamllint openshift flake8 - - name: Create default collection path symlink run: | mkdir -p /home/runner/.ansible From fdac75532cc76ec9e9d22f3bda89d749c3941d3b Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 12:33:43 +0200 Subject: [PATCH 39/48] fix api call --- .github/workflows/ci.yml | 12 ++++++------ plugins/module_utils/common.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c89d27ca35..2da900ac6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,12 +136,12 @@ jobs: - name: Install molecule and openshift dependencies run: pip install ansible "molecule<3.3.0" yamllint openshift flake8 urllib3 - - name: Set up squid proxy via docker - run: | - set -eux - docker run --name squid -d -p 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 - docker port squid - python ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/plugins/module_utils/test_proxy_headers.py + # - name: Set up squid proxy via docker + # run: | + # set -eux + # docker run --name squid -d -p 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + # docker port squid + # python ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/plugins/module_utils/test_proxy_headers.py - name: Create default collection path symlink run: | diff --git a/plugins/module_utils/common.py b/plugins/module_utils/common.py index 48bb0788de..14d13e5c39 100644 --- a/plugins/module_utils/common.py +++ b/plugins/module_utils/common.py @@ -193,7 +193,7 @@ def auth_set(*names): if key == 'api_key': setattr(configuration, key, {'authorization': "Bearer {0}".format(value)}) elif key == 'proxy_headers': - headers = urllib3.make_headers(**value) + headers = urllib3.util.make_headers(**value) setattr(configuration, key, headers) else: setattr(configuration, key, value) From 2c28488e14f4958dcdd85790849b6b8751962e53 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 12:38:28 +0200 Subject: [PATCH 40/48] remove useless curl --- molecule/proxy/converge.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/molecule/proxy/converge.yml b/molecule/proxy/converge.yml index b73c85fb4c..e91b969cad 100644 --- a/molecule/proxy/converge.yml +++ b/molecule/proxy/converge.yml @@ -17,9 +17,6 @@ assert: that: (pod_list.resources | count) > 5 - - name: test curl using command - command: curl -x http://127.0.0.1:3128 --proxy-user ansible:test -I https://github.com - - name: cluster info k8s_cluster_info: proxy: http://127.0.0.1:3128 From 5dcf57092e791774d77f1fe0dd2b819c3d380e60 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 12:44:13 +0200 Subject: [PATCH 41/48] proxy --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2da900ac6a..c89d27ca35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,12 +136,12 @@ jobs: - name: Install molecule and openshift dependencies run: pip install ansible "molecule<3.3.0" yamllint openshift flake8 urllib3 - # - name: Set up squid proxy via docker - # run: | - # set -eux - # docker run --name squid -d -p 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 - # docker port squid - # python ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/plugins/module_utils/test_proxy_headers.py + - name: Set up squid proxy via docker + run: | + set -eux + docker run --name squid -d -p 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + docker port squid + python ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/plugins/module_utils/test_proxy_headers.py - name: Create default collection path symlink run: | From 72763cf88339446b79cd1e846c63dc852f9d5470 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 12:49:33 +0200 Subject: [PATCH 42/48] direct call --- .github/workflows/ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c89d27ca35..4edc6faa94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -142,15 +142,16 @@ jobs: docker run --name squid -d -p 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 docker port squid python ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/plugins/module_utils/test_proxy_headers.py + ansible-playbook ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/converge.yml -v - - name: Create default collection path symlink - run: | - mkdir -p /home/runner/.ansible - ln -s /home/runner/work/kubernetes/kubernetes /home/runner/.ansible/collections + # - name: Create default collection path symlink + # run: | + # mkdir -p /home/runner/.ansible + # ln -s /home/runner/work/kubernetes/kubernetes /home/runner/.ansible/collections - - name: Run molecule default test scenario - run: make test-molecule-proxy - working-directory: ./ansible_collections/kubernetes/core + # - name: Run molecule default test scenario + # run: make test-molecule-proxy + # working-directory: ./ansible_collections/kubernetes/core unit: runs-on: ubuntu-latest From 4a0e07138791e2a5fe3dd7b81408143c2b161001 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 12:55:15 +0200 Subject: [PATCH 43/48] direct call --- .github/workflows/ci.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4edc6faa94..712f1e0d45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -142,12 +142,15 @@ jobs: docker run --name squid -d -p 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 docker port squid python ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/plugins/module_utils/test_proxy_headers.py - ansible-playbook ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/converge.yml -v - # - name: Create default collection path symlink - # run: | - # mkdir -p /home/runner/.ansible - # ln -s /home/runner/work/kubernetes/kubernetes /home/runner/.ansible/collections + - name: Create default collection path symlink + run: | + mkdir -p /home/runner/.ansible + ln -s /home/runner/work/kubernetes/kubernetes /home/runner/.ansible/collections + + - name: Create default collection path symlink + run: | + ansible-playbook ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/converge.yml -v # - name: Run molecule default test scenario # run: make test-molecule-proxy From 89bbc9d64acb8cb47affde0f9854625d35370532 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 13:00:14 +0200 Subject: [PATCH 44/48] testing full col name --- molecule/proxy/converge.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/molecule/proxy/converge.yml b/molecule/proxy/converge.yml index e91b969cad..9711fe03ba 100644 --- a/molecule/proxy/converge.yml +++ b/molecule/proxy/converge.yml @@ -8,7 +8,7 @@ tasks: - name: Verify cluster is working. - k8s_info: + kubernetes.core.k8s_info: namespace: kube-system kind: Pod register: pod_list @@ -18,13 +18,13 @@ that: (pod_list.resources | count) > 5 - name: cluster info - k8s_cluster_info: + kubernetes.core.k8s_cluster_info: proxy: http://127.0.0.1:3128 proxy_headers: proxy_basic_auth: ansible:test - name: bad credentials - k8s_cluster_info: + kubernetes.core.k8s_cluster_info: proxy: http://127.0.0.1:3128 proxy_headers: proxy_basic_auth: ansible:uuuu @@ -37,7 +37,7 @@ - bad_cred is failed - name: create namespace - k8s: + kubernetes.core.k8s: definition: kind: namespace metadata: From 7a5fec8339e5c7ee763eac6b968f7c430141ce95 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 14:25:18 +0200 Subject: [PATCH 45/48] testing full col name --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 712f1e0d45..875ffd4701 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -149,8 +149,8 @@ jobs: ln -s /home/runner/work/kubernetes/kubernetes /home/runner/.ansible/collections - name: Create default collection path symlink - run: | - ansible-playbook ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/converge.yml -v + run: ansible-playbook ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/converge.yml -v + working-directory: ./ansible_collections/kubernetes/core # - name: Run molecule default test scenario # run: make test-molecule-proxy From c8bee39fd17896a2534b7a63871b7186aa67c65b Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 16:30:58 +0200 Subject: [PATCH 46/48] integration --- .github/workflows/ci.yml | 44 ---------------- plugins/module_utils/test_proxy_headers.py | 36 ------------- tests/integration/targets/proxy/aliases | 1 + .../targets/proxy/files/squid.conf | 10 ++++ .../targets/proxy/files/squid.passwd | 1 + tests/integration/targets/proxy/ping_proxy.py | 24 +++++++++ tests/integration/targets/proxy/playbook.yaml | 9 ++++ tests/integration/targets/proxy/runme.sh | 17 +++++++ .../targets/proxy/tasks/test_proxy.yaml | 50 +++++++++++++++++++ 9 files changed, 112 insertions(+), 80 deletions(-) delete mode 100644 plugins/module_utils/test_proxy_headers.py create mode 100644 tests/integration/targets/proxy/aliases create mode 100644 tests/integration/targets/proxy/files/squid.conf create mode 100644 tests/integration/targets/proxy/files/squid.passwd create mode 100644 tests/integration/targets/proxy/ping_proxy.py create mode 100644 tests/integration/targets/proxy/playbook.yaml create mode 100755 tests/integration/targets/proxy/runme.sh create mode 100644 tests/integration/targets/proxy/tasks/test_proxy.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 875ffd4701..0c05f7321c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,50 +112,6 @@ jobs: run: make test-molecule working-directory: ./ansible_collections/kubernetes/core - proxy: - runs-on: ubuntu-latest - strategy: - matrix: - python_version: ['3.7'] - steps: - - name: Check out code - uses: actions/checkout@v2 - with: - path: ansible_collections/kubernetes/core - - - name: Set up KinD cluster - uses: engineerd/setup-kind@v0.5.0 - - - name: Set up Python ${{ matrix.python_version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python_version }} - - # The 3.3.0 release of molecule introduced a breaking change. See - # https://github.com/ansible-community/molecule/issues/3083 - - name: Install molecule and openshift dependencies - run: pip install ansible "molecule<3.3.0" yamllint openshift flake8 urllib3 - - - name: Set up squid proxy via docker - run: | - set -eux - docker run --name squid -d -p 3128:3128 -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.passwd:/etc/squid/passwd -v ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 - docker port squid - python ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/plugins/module_utils/test_proxy_headers.py - - - name: Create default collection path symlink - run: | - mkdir -p /home/runner/.ansible - ln -s /home/runner/work/kubernetes/kubernetes /home/runner/.ansible/collections - - - name: Create default collection path symlink - run: ansible-playbook ${GITHUB_WORKSPACE}/ansible_collections/kubernetes/core/molecule/proxy/converge.yml -v - working-directory: ./ansible_collections/kubernetes/core - - # - name: Run molecule default test scenario - # run: make test-molecule-proxy - # working-directory: ./ansible_collections/kubernetes/core - unit: runs-on: ubuntu-latest strategy: diff --git a/plugins/module_utils/test_proxy_headers.py b/plugins/module_utils/test_proxy_headers.py deleted file mode 100644 index 3bc04237d4..0000000000 --- a/plugins/module_utils/test_proxy_headers.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 Red Hat | Ansible -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -import urllib3 - - -def main(): - try: - urllib3.disable_warnings() - params = {'keep_alive': True, 'proxy_basic_auth': "ansible:test"} - head = urllib3.util.make_headers(**params) - print("-- make_headers --") - proxy = urllib3.ProxyManager(proxy_url='http://localhost:3128/', proxy_headers=head) - print("-- ProxyManager --") - resp = proxy.request('GET', 'http://google.com/') - print("-- GET (status={}) --\n{}".format(resp.status, resp.headers)) - except Exception as e: - print("Raised => {}".format(e)) - - -if __name__ == '__main__': - main() diff --git a/tests/integration/targets/proxy/aliases b/tests/integration/targets/proxy/aliases new file mode 100644 index 0000000000..5903607233 --- /dev/null +++ b/tests/integration/targets/proxy/aliases @@ -0,0 +1 @@ +shippable/cloud/group1 diff --git a/tests/integration/targets/proxy/files/squid.conf b/tests/integration/targets/proxy/files/squid.conf new file mode 100644 index 0000000000..1a542a586a --- /dev/null +++ b/tests/integration/targets/proxy/files/squid.conf @@ -0,0 +1,10 @@ +http_port 3128 +acl SSL_ports port 443 +acl CONNECT method CONNECT + +auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd +auth_param basic children 5 +auth_param basic realm Squid Basic Authentication +auth_param basic credentialsttl 2 hours +acl auth_users proxy_auth REQUIRED +http_access allow auth_users diff --git a/tests/integration/targets/proxy/files/squid.passwd b/tests/integration/targets/proxy/files/squid.passwd new file mode 100644 index 0000000000..ee8917cc8f --- /dev/null +++ b/tests/integration/targets/proxy/files/squid.passwd @@ -0,0 +1 @@ +ansible:$apr1$SNezRr1E$5iTPBCbVCrJun1DsMLjM0. diff --git a/tests/integration/targets/proxy/ping_proxy.py b/tests/integration/targets/proxy/ping_proxy.py new file mode 100644 index 0000000000..55d8ab9f98 --- /dev/null +++ b/tests/integration/targets/proxy/ping_proxy.py @@ -0,0 +1,24 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright: (c) 2021, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +import urllib3 +import sys + + +def main(): + try: + urllib3.disable_warnings() + params = {'keep_alive': True, 'proxy_basic_auth': "ansible:test"} + head = urllib3.util.make_headers(**params) + proxy = urllib3.ProxyManager(proxy_url='http://localhost:3128/', proxy_headers=head) + resp = proxy.request('GET', 'http://google.com/') + sys.stdout.write("status => {}\n".format(resp.status)) + sys.exit(0) + except Exception as e: + sys.stderr.write("Raised => {}\n".format(e)) + sys.exit(1) + + +if __name__ == '__main__': + main() diff --git a/tests/integration/targets/proxy/playbook.yaml b/tests/integration/targets/proxy/playbook.yaml new file mode 100644 index 0000000000..8b740f876d --- /dev/null +++ b/tests/integration/targets/proxy/playbook.yaml @@ -0,0 +1,9 @@ +- name: Integration testing for kubernetes access api via proxy + hosts: localhost + gather_facts: no + + collections: + - kubernetes.core + + tasks: + - include_tasks: tasks/test_proxy.yaml diff --git a/tests/integration/targets/proxy/runme.sh b/tests/integration/targets/proxy/runme.sh new file mode 100755 index 0000000000..503fc353f7 --- /dev/null +++ b/tests/integration/targets/proxy/runme.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -eux + +docker rm -f squid + +docker run --name squid -d -p 3128:3128 -v $(pwd)/files/squid.passwd:/etc/squid/passwd -v $(pwd)/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 + +until [ "`docker inspect -f {{.State.Running}} squid`"=="true" ]; do + sleep 1 +done + +python $(pwd)/ping_proxy.py + +ansible-playbook playbook.yaml -v + +docker rm -f squid \ No newline at end of file diff --git a/tests/integration/targets/proxy/tasks/test_proxy.yaml b/tests/integration/targets/proxy/tasks/test_proxy.yaml new file mode 100644 index 0000000000..4126aebeca --- /dev/null +++ b/tests/integration/targets/proxy/tasks/test_proxy.yaml @@ -0,0 +1,50 @@ +--- +- name: Verify cluster is working. + kubernetes.core.k8s_info: + namespace: kube-system + kind: Pod + register: pod_list + +- name: Verify cluster has more than 5 pods running. + assert: + that: (pod_list.resources | count) > 5 + +- name: cluster info + kubernetes.core.k8s_cluster_info: + proxy: http://127.0.0.1:3128 + proxy_headers: + proxy_basic_auth: ansible:test + +- name: bad credentials + kubernetes.core.k8s_cluster_info: + proxy: http://127.0.0.1:3128 + proxy_headers: + proxy_basic_auth: ansible:uuuu + ignore_errors: true + register: bad_cred + +- name: ensure connection failed + assert: + that: + - bad_cred is failed + +- name: create namespace + kubernetes.core.k8s: + definition: + kind: namespace + metadata: + name: squid + proxy: http://127.0.0.1:3128 + proxy_headers: + proxy_basic_auth: ansible:test + +- name: delete namespace + kubernetes.core.k8s: + definition: + kind: namespace + metadata: + name: squid + proxy: http://127.0.0.1:3128 + proxy_headers: + proxy_basic_auth: ansible:test + state: absent From e639d24fe47f7c7c45558d8d7f3231df712bc076 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 16:56:38 +0200 Subject: [PATCH 47/48] remove useless --- Makefile | 3 -- molecule/default/converge.yml | 7 ----- molecule/proxy/converge.yml | 47 ------------------------------- molecule/proxy/files/squid.conf | 10 ------- molecule/proxy/files/squid.passwd | 1 - molecule/proxy/molecule.yml | 38 ------------------------- 6 files changed, 106 deletions(-) delete mode 100644 molecule/proxy/converge.yml delete mode 100644 molecule/proxy/files/squid.conf delete mode 100644 molecule/proxy/files/squid.passwd delete mode 100644 molecule/proxy/molecule.yml diff --git a/Makefile b/Makefile index 15a23daa3f..5bd6613e76 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,5 @@ test-integration: test-molecule: molecule test -test-molecule-proxy: - molecule test -s proxy - test-unit: ansible-test units --docker -v --color --python $(PYTHON_VERSION) $(?TEST_ARGS) diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index ef54036133..6e9387a16a 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -132,13 +132,6 @@ tags: [ waiter, k8s ] tags: - always - - name: Include proxy.yml - include_tasks: - file: tasks/proxy.yml - apply: - tags: [ proxy, k8s ] - tags: - - always roles: - role: helm diff --git a/molecule/proxy/converge.yml b/molecule/proxy/converge.yml deleted file mode 100644 index 9711fe03ba..0000000000 --- a/molecule/proxy/converge.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Converge - hosts: localhost - connection: local - - collections: - - kubernetes.core - - tasks: - - name: Verify cluster is working. - kubernetes.core.k8s_info: - namespace: kube-system - kind: Pod - register: pod_list - - - name: Verify cluster has more than 5 pods running. - assert: - that: (pod_list.resources | count) > 5 - - - name: cluster info - kubernetes.core.k8s_cluster_info: - proxy: http://127.0.0.1:3128 - proxy_headers: - proxy_basic_auth: ansible:test - - - name: bad credentials - kubernetes.core.k8s_cluster_info: - proxy: http://127.0.0.1:3128 - proxy_headers: - proxy_basic_auth: ansible:uuuu - ignore_errors: true - register: bad_cred - - - name: ensure connection failed - assert: - that: - - bad_cred is failed - - - name: create namespace - kubernetes.core.k8s: - definition: - kind: namespace - metadata: - name: squid - proxy: http://127.0.0.1:3128 - proxy_headers: - proxy_basic_auth: ansible:test diff --git a/molecule/proxy/files/squid.conf b/molecule/proxy/files/squid.conf deleted file mode 100644 index 1a542a586a..0000000000 --- a/molecule/proxy/files/squid.conf +++ /dev/null @@ -1,10 +0,0 @@ -http_port 3128 -acl SSL_ports port 443 -acl CONNECT method CONNECT - -auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd -auth_param basic children 5 -auth_param basic realm Squid Basic Authentication -auth_param basic credentialsttl 2 hours -acl auth_users proxy_auth REQUIRED -http_access allow auth_users diff --git a/molecule/proxy/files/squid.passwd b/molecule/proxy/files/squid.passwd deleted file mode 100644 index ee8917cc8f..0000000000 --- a/molecule/proxy/files/squid.passwd +++ /dev/null @@ -1 +0,0 @@ -ansible:$apr1$SNezRr1E$5iTPBCbVCrJun1DsMLjM0. diff --git a/molecule/proxy/molecule.yml b/molecule/proxy/molecule.yml deleted file mode 100644 index 4c5171a644..0000000000 --- a/molecule/proxy/molecule.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -driver: - name: delegated - options: - managed: false - login_cmd_template: 'docker exec -ti {instance} bash' - ansible_connection_options: - ansible_connection: docker -lint: | - set -e - yamllint . - flake8 -platforms: - - name: instance-kind -provisioner: - name: ansible - log: true - config_options: - inventory: - enable_plugins: kubernetes.core.k8s - lint: {} - inventory: - hosts: - plugin: kubernetes.core.k8s - host_vars: - localhost: - ansible_python_interpreter: '{{ ansible_playbook_python }}' - env: - ANSIBLE_FORCE_COLOR: 'true' - options: - vvv: True -scenario: - name: proxy - test_sequence: - - lint - - syntax - - converge - - verify From ec66b678eddc0345ecf51289b55525d4c84fc562 Mon Sep 17 00:00:00 2001 From: aubin Date: Mon, 26 Apr 2021 17:03:50 +0200 Subject: [PATCH 48/48] remove integration --- tests/integration/targets/proxy/aliases | 1 - .../targets/proxy/files/squid.conf | 10 ---- .../targets/proxy/files/squid.passwd | 1 - tests/integration/targets/proxy/ping_proxy.py | 24 --------- tests/integration/targets/proxy/playbook.yaml | 9 ---- tests/integration/targets/proxy/runme.sh | 17 ------- .../targets/proxy/tasks/test_proxy.yaml | 50 ------------------- 7 files changed, 112 deletions(-) delete mode 100644 tests/integration/targets/proxy/aliases delete mode 100644 tests/integration/targets/proxy/files/squid.conf delete mode 100644 tests/integration/targets/proxy/files/squid.passwd delete mode 100644 tests/integration/targets/proxy/ping_proxy.py delete mode 100644 tests/integration/targets/proxy/playbook.yaml delete mode 100755 tests/integration/targets/proxy/runme.sh delete mode 100644 tests/integration/targets/proxy/tasks/test_proxy.yaml diff --git a/tests/integration/targets/proxy/aliases b/tests/integration/targets/proxy/aliases deleted file mode 100644 index 5903607233..0000000000 --- a/tests/integration/targets/proxy/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/cloud/group1 diff --git a/tests/integration/targets/proxy/files/squid.conf b/tests/integration/targets/proxy/files/squid.conf deleted file mode 100644 index 1a542a586a..0000000000 --- a/tests/integration/targets/proxy/files/squid.conf +++ /dev/null @@ -1,10 +0,0 @@ -http_port 3128 -acl SSL_ports port 443 -acl CONNECT method CONNECT - -auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd -auth_param basic children 5 -auth_param basic realm Squid Basic Authentication -auth_param basic credentialsttl 2 hours -acl auth_users proxy_auth REQUIRED -http_access allow auth_users diff --git a/tests/integration/targets/proxy/files/squid.passwd b/tests/integration/targets/proxy/files/squid.passwd deleted file mode 100644 index ee8917cc8f..0000000000 --- a/tests/integration/targets/proxy/files/squid.passwd +++ /dev/null @@ -1 +0,0 @@ -ansible:$apr1$SNezRr1E$5iTPBCbVCrJun1DsMLjM0. diff --git a/tests/integration/targets/proxy/ping_proxy.py b/tests/integration/targets/proxy/ping_proxy.py deleted file mode 100644 index 55d8ab9f98..0000000000 --- a/tests/integration/targets/proxy/ping_proxy.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -# Copyright: (c) 2021, Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import urllib3 -import sys - - -def main(): - try: - urllib3.disable_warnings() - params = {'keep_alive': True, 'proxy_basic_auth': "ansible:test"} - head = urllib3.util.make_headers(**params) - proxy = urllib3.ProxyManager(proxy_url='http://localhost:3128/', proxy_headers=head) - resp = proxy.request('GET', 'http://google.com/') - sys.stdout.write("status => {}\n".format(resp.status)) - sys.exit(0) - except Exception as e: - sys.stderr.write("Raised => {}\n".format(e)) - sys.exit(1) - - -if __name__ == '__main__': - main() diff --git a/tests/integration/targets/proxy/playbook.yaml b/tests/integration/targets/proxy/playbook.yaml deleted file mode 100644 index 8b740f876d..0000000000 --- a/tests/integration/targets/proxy/playbook.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- name: Integration testing for kubernetes access api via proxy - hosts: localhost - gather_facts: no - - collections: - - kubernetes.core - - tasks: - - include_tasks: tasks/test_proxy.yaml diff --git a/tests/integration/targets/proxy/runme.sh b/tests/integration/targets/proxy/runme.sh deleted file mode 100755 index 503fc353f7..0000000000 --- a/tests/integration/targets/proxy/runme.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -docker rm -f squid - -docker run --name squid -d -p 3128:3128 -v $(pwd)/files/squid.passwd:/etc/squid/passwd -v $(pwd)/files/squid.conf:/etc/squid/squid.conf sameersbn/squid:3.5.27-2 - -until [ "`docker inspect -f {{.State.Running}} squid`"=="true" ]; do - sleep 1 -done - -python $(pwd)/ping_proxy.py - -ansible-playbook playbook.yaml -v - -docker rm -f squid \ No newline at end of file diff --git a/tests/integration/targets/proxy/tasks/test_proxy.yaml b/tests/integration/targets/proxy/tasks/test_proxy.yaml deleted file mode 100644 index 4126aebeca..0000000000 --- a/tests/integration/targets/proxy/tasks/test_proxy.yaml +++ /dev/null @@ -1,50 +0,0 @@ ---- -- name: Verify cluster is working. - kubernetes.core.k8s_info: - namespace: kube-system - kind: Pod - register: pod_list - -- name: Verify cluster has more than 5 pods running. - assert: - that: (pod_list.resources | count) > 5 - -- name: cluster info - kubernetes.core.k8s_cluster_info: - proxy: http://127.0.0.1:3128 - proxy_headers: - proxy_basic_auth: ansible:test - -- name: bad credentials - kubernetes.core.k8s_cluster_info: - proxy: http://127.0.0.1:3128 - proxy_headers: - proxy_basic_auth: ansible:uuuu - ignore_errors: true - register: bad_cred - -- name: ensure connection failed - assert: - that: - - bad_cred is failed - -- name: create namespace - kubernetes.core.k8s: - definition: - kind: namespace - metadata: - name: squid - proxy: http://127.0.0.1:3128 - proxy_headers: - proxy_basic_auth: ansible:test - -- name: delete namespace - kubernetes.core.k8s: - definition: - kind: namespace - metadata: - name: squid - proxy: http://127.0.0.1:3128 - proxy_headers: - proxy_basic_auth: ansible:test - state: absent