saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:

Home Page:https://repo.saltproject.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] proxmox salt-cloud driver provides inadequate information on errors

pjcreath opened this issue · comments

I'm not sure if this is a bug exactly, but it's also not exactly a feature request, since there's not really a "new" feature that requires documentation.

Description

The salt-cloud proxmox driver provides misleading error messages on authentication failure and incomplete messages on parameter validation failure.

Pull request with fix and tests to follow.

Setup

  • salt master (hostname "salt") is running in a container on the Proxmox host.
  • Proxmox (hostname "pve") is running on bare metal, on-premises.
/etc/salt/cloud.providers.d/proxmox.conf
proxmox:
  minion:
    master: salt
  user: mysaltuser@pve
  password: notreallythepassword
  url: pve
  driver: proxmox
/etc/salt/cloud.profiles.d/proxmox.conf
ol8:
  provider: proxmox
  pool: mypool
  image: local:vztmpl/oraclelinux-8-official_amd64.tar.gz
  storage: local-zfs
  technology: lxc
  host: pve
  onboot: 1
  pubkey: mypubkey
  ip_address: 192.168.0.222

Steps to Reproduce the behavior

Authentication errors:

Set the password in cloud.providers.d/proxmox.conf to the wrong password.
salt-cloud --list-images proxmox

Output
[ERROR   ] Failed to get the output of 'proxmox.avail_images()': 'NoneType' object is not subscriptable
proxmox:
    ----------
"'NoneType' object is not subscriptable"... Guess what's wrong with your configuration?

Parameter validation errors:

Set the password in cloud.providers.d/proxmox.conf back to the right password if necessary.
Change the value of "onboot" in cloud.profiles.d/proxmox.conf from "1" to "true".
salt-cloud -p ol8 testvm2

Output
[ERROR   ] Error creating testvm2 on PROXMOX

The following exception was thrown when trying to run the initial deployment: 
400 Client Error: Parameter verification failed. for url: https://pve:8006/api2/json/nodes/pve/lxc
Error: There was a profile error: Failed to deploy VM
What parameter failed? Who knows...

Expected behavior

Authentication errors:

salt-cloud --list-images proxmox

Output
[ERROR   ] Failed to get the output of 'proxmox.avail_locations()': 401 Client Error: authentication failure for url: https://pve:8006/api2/json/access/ticket
proxmox:
    ----------
Oh, there's something wrong with my credentials!

Parameter validation errors:

salt-cloud -p ol8 testvm2

Output
[ERROR   ] Error creating testvm2 on PROXMOX

The following exception was thrown when trying to run the initial deployment: 
400 Client Error: Parameter verification failed. for url: https://pve:8006/api2/json/nodes/pve/lxc
{"data":null,"errors":{"onboot":"type check ('boolean') failed - got 'True'"}}
Error: There was a profile error: Failed to deploy VM
There's the missing detail provided by the Proxmox server: Proxmox doesn't like textual booleans!

Versions Report

salt --versions-report
Salt Version:
          Salt: 3004.1
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.6.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.10.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: Not Installed
        Python: 3.6.8 (default, Apr 11 2022, 08:25:52)
  python-gnupg: 0.4.6
        PyYAML: 3.12
         PyZMQ: 19.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: oracle 8.6 
        locale: UTF-8
       machine: x86_64
       release: 5.15.35-1-pve
        system: Linux
       version: Oracle Linux Server 8.6