Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy param does not accept authentication header #55

Closed
senpai-d opened this issue Apr 13, 2021 · 7 comments
Closed

Proxy param does not accept authentication header #55

senpai-d opened this issue Apr 13, 2021 · 7 comments
Labels
verified The issue is reproduced

Comments

@senpai-d
Copy link

SUMMARY

When setting a proxy url in the proxy param, the username:password header is not read. It only accesses the URL, which returns a 407 if authentication is required for the proxy.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

k8s

ANSIBLE VERSION
ansible 2.9.0
   config file = /home/user/.ansible.cfg
   configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
   ansible python module location = /home/user/projects/python_envs/ansible-env/lib/python3.6/site-packages/ansible
   executable location = /home/user/projects/python_envs/ansible-env/bin/ansible
   python version = 3.6.9 (default, Jan 26 2021, 15:33:00)
CONFIGURATION
DEFAULT_ROLES_PATH(/home/user/.ansible.cfg) = ['/home/user/.ansible/roles', '/usr/share/ansible/roles', '/etc/ansible/roles']
RETRY_FILES_ENABLED(/home/user/.ansible.cfg) = False
OS / ENVIRONMENT

WSL Ubuntu 18.03
Pythion 3.6 virtual environment

STEPS TO REPRODUCE

With a proxy url such as http://USERNAME:[email protected]:3001, the USERNAME:PASSWORD header is not loaded in, resulting in a 401 due to authentication required with proxy.

- name: Set up namespace
  hosts: localhost
  tasks:
    - name: create namespace
      k8s:
        host: "https://kube-cluster.com"
        api_key: "api_token"
        proxy: "http://USERNAME:[email protected]:3001"
        state: present
        name: "new-default-namespace"
        api_version: "v1"
        state: present
EXPECTED RESULTS

Expected for the namespace to be created.

ACTUAL RESULTS

Received a 407 from proxy server.

kubernetes.client.rest.ApiException: (401)
Reason: authenticationrequired

The rest of the output is proxy server error being returned.

@tima tima transferred this issue from ansible-collections/community.kubernetes Apr 13, 2021
@abikouo
Copy link
Contributor

abikouo commented Apr 14, 2021

Hi @senpai-d
Thanks for reporting this issue, I will try to reproduce

@abikouo
Copy link
Contributor

abikouo commented Apr 14, 2021

@senpai-d
could you please check with this pull request #58 ?

@senpai-d
Copy link
Author

Hi @abikouo ,

I have installed the collection locally to test it out and the proxy_headers variable was picked up but it still returned an authentication required.

Does the username:password need to be encoded or anything?

Thanks.

@abikouo
Copy link
Contributor

abikouo commented Apr 15, 2021

@senpai-d could you please display the version of the kubernetes python api you are using ?

python -c "import kubernetes;print(kubernetes.__version__)"

please also try to use https in your proxy server

@abikouo
Copy link
Contributor

abikouo commented Apr 15, 2021

@senpai-d using this simple playbook I can talk to the kubernetes api via proxy.

- name: create namespace
  hosts: localhost
  gather_facts: false
  tasks:
  - name: create namespace proxy
    kubernetes.core.k8s:
      kind: namespace
      name: proxy
      proxy: "http://192.168.123.7:3128" => This is my proxy host and port
      proxy_headers: "ansible:test"  => username = 'ansible' and password = 'test' set in clear in the playbook
      state: present

@senpai-d
Copy link
Author

We have tried 1.12 and 1.17 for the kubernetes client version.

We have got it to work with k8s_info successfully, but when we use k8s, the connection times out. We aren't sure if it is proxy related, but we use the same host for k8s_info and k8s, but only k8s_info seems to work.

@abikouo
Copy link
Contributor

abikouo commented Apr 30, 2021

@senpai-d thats strange, on our side it is working for both module as it is the same api used. could you please check that it is related to your proxy ?
I close this issue, feel free to re-open if needed

@abikouo abikouo added verified The issue is reproduced and removed needs_verify labels Apr 30, 2021
@abikouo abikouo closed this as completed May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
verified The issue is reproduced
Projects
None yet
Development

No branches or pull requests

2 participants