[support] Cannot figure out how to install
I'm sorry, I realise I'm doing something dumb, but I cannot figure out what:
# pip install ansible-modules-hashivault
Collecting ansible-modules-hashivault
Downloading ansible-modules-hashivault-4.5.4.tar.gz (74 kB)
|████████████████████████████████| 74 kB 393 kB/s
Requirement already satisfied: ansible>=2.0.0 in /usr/lib/python3/dist-packages (from ansible-modules-hashivault) (2.9.6)
Collecting hvac>=0.9.5
Downloading hvac-0.10.4-py2.py3-none-any.whl (122 kB)
|████████████████████████████████| 122 kB 13.5 MB/s
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from ansible-modules-hashivault) (2.22.0)
Requirement already satisfied: six>=1.5.0 in /usr/lib/python3/dist-packages (from hvac>=0.9.5->ansible-modules-hashivault) (1.14.0)
Building wheels for collected packages: ansible-modules-hashivault
Building wheel for ansible-modules-hashivault (setup.py) ... done
Created wheel for ansible-modules-hashivault: filename=ansible_modules_hashivault-4.5.4-py3-none-any.whl size=143149 sha256=0a96823af124db1d10f1729a26543c03a3555750256a9212b3c928fe67b326e7
Stored in directory: /root/.cache/pip/wheels/e3/7c/df/a5c034c68ed13b2ad549377d961068959201df9dca211f87ea
Successfully built ansible-modules-hashivault
Installing collected packages: hvac, ansible-modules-hashivault
Successfully installed ansible-modules-hashivault-4.5.4 hvac-0.10.4
# ansible localhost -m hashivault_write
localhost | FAILED! => {
"msg": "The module hashivault_write was not found in configured module paths"
}
Any playbook I try to run, also complain that they do not know hashivault_write module. What am I doing wrong?
# ansible --version
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.2 (default, Jul 16 2020, 14:00:26) [GCC 9.3.0]
The above is from an ubuntu box, but I'm trying to make it work with awx, which is running in a Red Hat container. Having the similar/same issue there as well. Tried ubuntu to see if I could get it working at all.
Related: https://github.com/TerryHowe/ansible-modules-hashivault/issues/55. However, this does not seem to be limited to ubuntu, since I see the same problem in awx_task container (official awx distribution) that as of the time of writing uses CentOS 8.
I had to create the following role to get this module working:
- name: ensure hvac
pip:
name: hvac
state: latest
- name: ensure ansible-modules-hashivault
# Install module into ususal default path that awx changes for tasks run in awx_task conatiner to something else
shell: |
ansible-galaxy install 'git+https://github.com/TerryHowe/ansible-modules-hashivault.git' -p ~/.ansible/roles
- name: ensure modules directory exists
# Make sure that the default path for modules, where ansible searches for them exists.
# By default in awx_task container it does not
file:
path: ~/.ansible/plugins/modules
state: directory
- name: ensure module_utils directory exists
# Same as above but for module_utils
file:
path: ~/.ansible/plugins/module_utils
state: directory
- name: Create a symbolic link for module
# Make sure that the module installed with the first task
# appears under the directory created by the second task
file:
src: ~/.ansible/roles/ansible-modules-hashivault/ansible/modules/hashivault/
dest: ~/.ansible/plugins/modules/hashivault
state: link
- name: Create a symbolic link module_utils
# Same as above but for module_utils
file:
src: ~/.ansible/roles/ansible-modules-hashivault/ansible/module_utils/hashivault.py
dest: ~/.ansible/plugins/module_utils/hashivault.py
state: link
This role cannot be added to the playbook using the module itself, since the playbook parse will fail if the module is not there yet, so this role needs to be executed from a separate playbook.
There is also this: https://github.com/ansible/awx/blob/devel/docs/custom_virtualenvs.md but it boggles my mind that it has to be that difficult.
The question is not solved by that though. How is it designed to be installed?
Might be solved by https://github.com/TerryHowe/ansible-modules-hashivault/pull/263 which I haven't messed with yet.
@TerryHowe: yes! Please make this an ansible collection!
Related issue https://github.com/TerryHowe/ansible-modules-hashivault/issues/234
Other issues tracking this
@TerryHowe this sounds a bit terse to me. In this thread a PR is linked which is now closed. And an issue about ansible galaxy. Neither of these track the original concern. Can you please elaborate which "other issues" tracking this, and how they are, in your opinion related?
@TerryHowe I'm still hoping for a response. Should I copy this to a new issue so we could track it there, if no existing issues immediately come to mind?