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

URI module LIST method #49716

Closed
yura-shutkin opened this issue Dec 10, 2018 · 10 comments · Fixed by #49719
Closed

URI module LIST method #49716

yura-shutkin opened this issue Dec 10, 2018 · 10 comments · Fixed by #49719
Labels
affects_2.8 This issue/PR affects Ansible v2.8 feature This issue/PR relates to a feature request. module This issue/PR relates to a module. net_tools Net-tools category support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@yura-shutkin
Copy link

yura-shutkin commented Dec 10, 2018

SUMMARY

Please add LIST method to URI module.
https://www.vaultproject.io/api/auth/userpass/index.html List users need LIST method. Right now I need to create task that differs from others. I use curl with different set of args and output

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

uri

ADDITIONAL INFORMATION

I use ansible for managing hashicorp vault configs. I need LIST method for get list of available users and for some other API queries to Hashicorp Vault

---
# Delete orphan userpass users
- name: Compile list described userpass users
  set_fact:
    described_userpass_users: "{{ described_userpass_users }} + [ '{{ item.params.login }}' ]"
  with_items: "{{ vault_config_applicator_userpass_users }}"
  loop_control:
    label: "{{ item.params.login }}"

# Better choice is to get list of all known userpass auth backends and delete every unknown user
# ansible module uri have no method LIST
- name: Get list existed users
  uri:
    url: "{{ vault_config_applicator_url }}/v1/auth/userpass/users"
    method: LIST
    user: "{{ vault_config_applicator_basic_auth_user }}"
    password: "{{ vault_config_applicator_basic_auth_pass }}"
    validate_certs: "{{ vault_config_applicator_validate_certs }}"
    headers:
      X-Vault-Token: "{{ vault_config_applicator_creds.token }}"
    follow_redirects: safe
    return_content: false
    status_code: 200
    timeout: "{{ vault_config_applicator_query_timeout }}"
  register:
    userpass_users_response

- name: Set list existed userspass users
  set_fact:
    existed_userpass_users: "{{ existed_userpass_users }} + [ '{{ item | regex_replace('/$', '') }}' ]"
  with_items:
    - "{{ userpass_users_response.json.data.keys() }}"

- name: Set orphan userpass users list
  set_fact:
    userpass_orphans: "{{ existed_userpass_users | difference(described_userpass_users) }}"

- name: Delete userpass orphans
  uri:
    url: "{{ vault_config_applicator_url }}/v1/auth/userpass/users/{{ userpass_orphan }}"
    method: DELETE
    user: "{{ vault_config_applicator_basic_auth_user }}"
    password: "{{ vault_config_applicator_basic_auth_pass }}"
    validate_certs: "{{ vault_config_applicator_validate_certs }}"
    headers:
      X-Vault-Token: "{{ vault_config_applicator_creds.token }}"
    follow_redirects: safe
    return_content: false
    status_code: 204
    timeout: "{{ vault_config_applicator_query_timeout }}"
  with_items:
    - "{{ userpass_orphans }}"
  loop_control:
    loop_var: userpass_orphan

Sorry, I can't give you access to config applicator repo or write more code cause NDA
But I'll be glad to answer your questions

@ansibot

This comment has been minimized.

@ansibot
Copy link
Contributor

ansibot commented Dec 10, 2018

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. net_tools Net-tools category support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Dec 10, 2018
@yura-shutkin

This comment has been minimized.

@ansibot

This comment has been minimized.

@dagwieers
Copy link
Member

@yura-shutkin We will not be adding LIST, as that would only fix this use-case. I think we need to look into making the method a clear text field (within certain limits).

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Dec 10, 2018
@yura-shutkin
Copy link
Author

Thank you.

@dagwieers
Copy link
Member

@yura-shutkin You're welcome :-)

@momusau
Copy link

momusau commented May 3, 2019

Hi,

I know this has been closed, but with the merge feature does this mean that we can use the LIST method in the uri module now? I have tried and I'm still hit with the error that LIST is not one of the method's we can use.

@dagwieers
Copy link
Member

It should work for Ansible v2.8, I wanted to backport this but it did not happen.
Do you want this in Ansible v2.7 ?

@momusau
Copy link

momusau commented May 4, 2019

Yeah, that would be ideal to be honest.

@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 feature This issue/PR relates to a feature request. module This issue/PR relates to a module. net_tools Net-tools category support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants