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

module.run http.query fail in States #51969

Open
valentin2105 opened this Issue Mar 5, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@valentin2105
Copy link

valentin2105 commented Mar 5, 2019

Description of Issue/Question

Hello,

I try to apply theses state, the make a POST request to an API :

add-device-observium:
  module.run:
    - name: http.query
    - url: https://observium.domain.tld/api/v0/devices/
    - method: POST
    - username: REDATECTED
    - password: REDACTED
    - data: '{"hostname":"host.name.tld"}'
    - header: "Content-Type: application/json"

If I run the module like salt '*' http.query https://.... it work.

But when I apply the state, the method (POST) and maybe other args are ignored, and of course, the request fail :

[INFO    ] Running state [http.query] at time 09:43:45.220647
[INFO    ] Executing state module.run for [http.query]
[WARNING ] The function "module.run" is using its deprecated version and will expire in version "Sodium".
[DEBUG   ] LazyLoaded http.query
[DEBUG   ] Requesting URL https://observium.domain.tld/api/v0/devices/ using GET method
[DEBUG   ] Using backend: tornado
[INFO    ] {u'ret': {u'status': 401, u'error': u'HTTP 401: Unauthorized'}}

I have tried the http.query state directly, but it doesn't work too. Only the http.query module work, on cli.

Any idea how to fix that ? Thanks.

Versions Report

Salt Version:
           Salt: 2019.2.0

Dependency Versions:
           cffi: Not Installed
       cherrypy: 3.5.0
       dateutil: 2.5.3
      docker-py: Not Installed
          gitdb: 2.0.0
      gitpython: 2.1.1
          ioflo: Not Installed
         Jinja2: 2.9.4
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: 1.3.7
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.13 (default, Sep 26 2018, 18:42:22)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: 2.0.1
        timelib: Not Installed
        Tornado: 4.4.3
            ZMQ: 4.2.1

System Versions:
           dist: debian 9.8
         locale: UTF-8
        machine: x86_64
        release: 4.9.0-8-amd64
         system: Linux
        version: debian 9.8

@max-arnold

This comment has been minimized.

Copy link
Contributor

max-arnold commented Mar 5, 2019

It looks like you need to switch to the newer use_superseded format: https://docs.saltstack.com/en/latest/ref/states/all/salt.states.module.html#execution-of-salt-modules-from-within-states

Try adding the following snippet to a minion config:

use_superseded:
  - module.run

@dwoz dwoz added this to the Blocked milestone Mar 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.