Giter Site home page Giter Site logo

Comments (17)

boskiv avatar boskiv commented on July 28, 2024

I have also tried to make ansible.cfg file

[defaults]
inventory = inventory
library = venv/lib/python2.7/site-packages/ansible

After this my playbooks run but task fail

(venv) ➜  vault-demo git:(master) ✗ ansible-playbook playbook.yml

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [hashivault_write] ********************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "Could not find imported module support code for hashivault_write.  Looked for either * or hashivault"}

NO MORE HOSTS LEFT *************************************************************
 [WARNING]: Could not create retry file 'playbook.retry'.         [Errno 2] No such file or directory: ''


PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1   

from ansible-modules-hashivault.

TerryHowe avatar TerryHowe commented on July 28, 2024

It sounds like some sort of install problem, like it just can't find the module at all.

To see if I can recreate this problem, can you paste in from your venv

python --version
pip list

and let me know what OS you are using.

from ansible-modules-hashivault.

boskiv avatar boskiv commented on July 28, 2024
(venv) ➜  vault-demo git:(master) ✗ python --version
Python 2.7.12
(venv) ➜  vault-demo git:(master) ✗ pip list
ansible (2.1.2.0)
ansible-modules-hashivault (1.1.8)
cffi (1.8.3)
cryptography (1.5.2)
enum34 (1.1.6)
hvac (0.2.16)
idna (2.1)
ipaddress (1.0.17)
Jinja2 (2.8)
MarkupSafe (0.23)
paramiko (2.0.2)
pip (8.1.2)
pyasn1 (0.1.9)
pycparser (2.14)
pycrypto (2.6.1)
PyYAML (3.12)
requests (2.11.1)
setuptools (28.2.0)
six (1.10.0)
wheel (0.30.0a0)

OSX 10.11.6 El Capitan

from ansible-modules-hashivault.

TerryHowe avatar TerryHowe commented on July 28, 2024

Huh, I'm running right now on same OS, I have Python 2.7.10, but I don't see that making a difference.

(asdf) THowe-MBPro:~ THowe$ python --version
Python 2.7.10
(asdf) THowe-MBPro:~ THowe$ pip list
ansible (2.1.2.0)
ansible-modules-hashivault (1.1.8)
cffi (1.8.3)
cryptography (1.5.2)
enum34 (1.1.6)
hvac (0.2.16)
idna (2.1)
ipaddress (1.0.17)
Jinja2 (2.8)
MarkupSafe (0.23)
paramiko (2.0.2)
pip (8.1.2)
pyasn1 (0.1.9)
pycparser (2.14)
pycrypto (2.6.1)
PyYAML (3.12)
requests (2.11.1)
setuptools (28.2.0)
six (1.10.0)
wheel (0.30.0a0)

Just created a venv asdf and ran

pip install ansible ansible-modules-hashivault

I was able to write, but read failed. I have VAULT_ADDR and VAULT_TOKEN set and exported, but if you didn't have that, you'd get another error.

from ansible-modules-hashivault.

boskiv avatar boskiv commented on July 28, 2024

Did you make ansible.cfg or it works by default ?

from ansible-modules-hashivault.

TerryHowe avatar TerryHowe commented on July 28, 2024

My hosts file is empty for that test. I did add --- on my yml file:

---
- hosts: localhost
  tasks:
    - hashivault_write:
        secret: giant
        data:
            foo: foe
            fie: fum
    - hashivault_read: secret='giant' key='fie' register='fie'
    - debug: msg="Value is {{fie.value}}"

from ansible-modules-hashivault.

TerryHowe avatar TerryHowe commented on July 28, 2024

No ansible.cfg file

from ansible-modules-hashivault.

TerryHowe avatar TerryHowe commented on July 28, 2024

The register is not working for me which is odd though.

from ansible-modules-hashivault.

boskiv avatar boskiv commented on July 28, 2024

After remove ansible.cfg I have other error, but I suppose it's because no env vars.

TASK [hashivault_write] ********************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Exception: Invalid URL '/v1/secret/giant': No schema supplied. Perhaps you meant http:///v1/secret/giant?", "rc": 1, "stack_trace": "Traceback (most recent call last):\n  File \"/var/folders/bp/6jc9dx8d33q94zfh8bm8x3r40000gn/T/ansible_HXt4Va/ansible_modlib.zip/ansible/module_utils/hashivault.py\", line 98, in hashivault_write\n    client.write(('secret/%s' % secret), **data)\n  File \"/Users/ivan.skiridomov/PycharmProjects/vault-demo/venv/lib/python2.7/site-packages/hvac/v1/__init__.py\", line 64, in write\n    response = self._put('/v1/{0}'.format(path), json=kwargs)\n  File \"/Users/ivan.skiridomov/PycharmProjects/vault-demo/venv/lib/python2.7/site-packages/hvac/v1/__init__.py\", line 900, in _put\n    return self.__request('put', url, **kwargs)\n  File \"/Users/ivan.skiridomov/PycharmProjects/vault-demo/venv/lib/python2.7/site-packages/hvac/v1/__init__.py\", line 922, in __request\n    allow_redirects=False, **_kwargs)\n  File \"/Users/ivan.skiridomov/PycharmProjects/vault-demo/venv/lib/python2.7/site-packages/requests/sessions.py\", line 461, in request\n    prep = self.prepare_request(req)\n  File \"/Users/ivan.skiridomov/PycharmProjects/vault-demo/venv/lib/python2.7/site-packages/requests/sessions.py\", line 394, in prepare_request\n    hooks=merge_hooks(request.hooks, self.hooks),\n  File \"/Users/ivan.skiridomov/PycharmProjects/vault-demo/venv/lib/python2.7/site-packages/requests/models.py\", line 294, in prepare\n    self.prepare_url(url, params)\n  File \"/Users/ivan.skiridomov/PycharmProjects/vault-demo/venv/lib/python2.7/site-packages/requests/models.py\", line 354, in prepare_url\n    raise MissingSchema(error)\nMissingSchema: Invalid URL '/v1/secret/giant': No schema supplied. Perhaps you meant http:///v1/secret/giant?\n"}

from ansible-modules-hashivault.

TerryHowe avatar TerryHowe commented on July 28, 2024

Yeh, that looks normal. You just don't have VAULT_ADDR set and exported or you can specify in the yml for that.

from ansible-modules-hashivault.

boskiv avatar boskiv commented on July 28, 2024

Now it's read/write success but register no, as your write

TASK [debug] *******************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'fie' is undefined\n\nThe error appears to have been in '/Users/ivan.skiridomov/PycharmProjects/vault-demo/playbook.yml': line 10, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n    - hashivault_read: secret='giant' key='fie' register='fie'\n    - debug: msg=\"Value is {{fie.value}}\"\n      ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes.  Always quote template expression brackets when they\nstart a value. For instance:\n\n    with_items:\n      - {{ foo }}\n\nShould be written as:\n\n    with_items:\n      - \"{{ foo }}\"\n"}

from ansible-modules-hashivault.

TerryHowe avatar TerryHowe commented on July 28, 2024

yeh, I'm seeing that. I'm using an action plugin on top of that and I'm looking at that now to see if it does something to make the register work.

from ansible-modules-hashivault.

boskiv avatar boskiv commented on July 28, 2024

This works fine:

---
- hosts: localhost
  tasks:
    - hashivault_write:
        secret: giant
        data:
            foo: foe
            fie: fum
    - hashivault_read:
        secret: giant
        key: fie
      register: fie

    - debug: msg="Value is {{fie.value}}"
TASK [debug] *******************************************************************
ok: [localhost] => {
    "msg": "Value is fum"
}

from ansible-modules-hashivault.

TerryHowe avatar TerryHowe commented on July 28, 2024

Ah, cool, yeh, I think the register was being passed on at the wrong level and I have a hack in my action plugin to make it work (which I should get rid of).

The sample is just wrong.

from ansible-modules-hashivault.

TerryHowe avatar TerryHowe commented on July 28, 2024

I think I linked this in the readme, but this action plugin helps set some default values. Or use VAULT_ADDR, VAULT_TOKEN.

https://terryhowe.wordpress.com/2016/05/02/setting-ansible-module-defaults-using-action-plugins/

from ansible-modules-hashivault.

bearrito avatar bearrito commented on July 28, 2024

Seeing the same. Are the examples up to date? What is the solution?

from ansible-modules-hashivault.

TerryHowe avatar TerryHowe commented on July 28, 2024

Are you still seeing this @bearrito ? I assume you got past this. I was away all weekend.

from ansible-modules-hashivault.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.