community.general icon indicating copy to clipboard operation
community.general copied to clipboard

RHEL8 pip3 and python-consul2 support

Open deeco opened this issue 2 years ago • 16 comments

Summary

when trying to run the community kv get error for "python-consul" here https://github.com/ansible-collections/community.general/blob/015566fb06628f5799ec2a0d33da0c4599262a28/plugins/lookup/consul_kv.py#L128

New distro only supports pip3 and would also like to know if pytohn-consul2 is supported ?

Issue Type

Bug Report

Component Name

https://github.com/ansible-collections/community.general/blob/main/plugins/lookup/

Ansible Version

$ ansible --version

AWX tower via operator version 0.21

Community.general Version

$ ansible-galaxy collection list community.general

 - name: community.general
    source: https://galaxy.ansible.com

Configuration

$ ansible-config dump --only-changed

  • name: Retrieve a value from the key/value store community.general.consul_kv: host: dev-consul.domain.com port: 32690 key: test/testkey register: test_key

  • name: Print Key Value debug: var: test_key

  • name: retrieving a KV from consul cluster on non default port debug: msg: "{{ lookup('community.general.consul_kv', 'test/testkey', host='dev-consul.domain.com', port='32690') }}"

OS / Environment

rhel 8 and k8s

Steps to Reproduce


  • name: Retrieve a value from the key/value store community.general.consul_kv: host: dev-consul.domain.com port: 32690 key: test/testkey register: test_key

  • name: Print Key Value debug: var: test_key

  • name: retrieving a KV from consul cluster on non default port debug: msg: "{{ lookup('community.general.consul_kv', 'test/testkey', host='dev-consul.domain.com', port='32690') }}"

Expected Results

expect version to be installed but never installs due to updated distro believe

Actual Results


'python-consul is required for consul_kv lookup. see http://python-consul.readthedocs.org/en/latest/#installation')

Code of Conduct

  • [X] I agree to follow the Ansible Code of Conduct

deeco avatar Sep 06 '22 19:09 deeco

cc @Akasurde @None @RevBits @azenk @dagwieers @delineaKrehl @eric-belhomme @felixfontein @galanoff @jparrill @jpmens @konstruktoid @lungj @samdoran @scottsb @tylerezimmerman click here for bot help

ansibullbot avatar Sep 06 '22 20:09 ansibullbot

You probably have to make sure that python-consul is installed in the execution environment used by AWX/Tower (assuming your version of AWX/Tower uses EEs).

felixfontein avatar Sep 06 '22 20:09 felixfontein

You probably have to make sure that python-consul is installed in the execution environment used by AWX/Tower (assuming your version of AWX/Tower uses EEs).

Thanks for that @felixfontein , I also verified this and the ee environment has python consul installed, also exec into pod to verify this, ran the installer directly again to be sure also

deeco avatar Sep 06 '22 20:09 deeco

could it be from within the task or scheduler containers it is also required ?

deeco avatar Sep 06 '22 20:09 deeco

FYI , the below returns the full key, i am only interested in the value within the data block

- name: Retrieve a value from the key/value store
  community.general.consul_kv:
    host: dev-consul.domain.com
    port: 32690
    key: test/testkey
    register: test_key

deeco avatar Sep 06 '22 20:09 deeco

Hi @deeco from what I gather, import consul will work with both python-consul and python-consul2. On the assumption that the -consul2 library kept API compatibility with the previous one, everything should work fine, and we could simply update the error message and docs to signal that any one of the two will work.

If the API is different, then we should ensure that this plugin will be able to handle that difference accordingly.

russoz avatar Oct 24 '22 04:10 russoz

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot avatar Nov 09 '22 04:11 ansibullbot

!component =plugins/lookups/consul_kv.py

felixfontein avatar Nov 09 '22 06:11 felixfontein

!component +plugins/modules/consul_kv.py

felixfontein avatar Nov 09 '22 06:11 felixfontein

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot avatar Nov 09 '22 06:11 ansibullbot

cc @sgargan click here for bot help

ansibullbot avatar Nov 09 '22 06:11 ansibullbot

cc @apollo13 click here for bot help

ansibullbot avatar Feb 01 '24 11:02 ansibullbot

Both packages are years old and I think consul_kv would be better off with a rewrite to not require that library. urllib should be enough to make the http requests :)

apollo13 avatar Feb 01 '24 11:02 apollo13

ansible.module_utils.urls has also a useful interface and can be used, and it comes with ansible-core, so there's no need for any library at all :)

felixfontein avatar Feb 01 '24 15:02 felixfontein

cc @Ilgmi click here for bot help

ansibullbot avatar Jun 16 '24 17:06 ansibullbot