Skip to content

PostgreSQL Module doesn't work on Windows #38263

@cetra3

Description

@cetra3

Description of Issue/Question

The PostgreSQL module doesn't appear to work at all on Windows. This causes a few failings with regards to setting up databases via states etc..

Setup

  • Load up Salt Stack 2016.11 on a Windows PC
  • Ensure PostgreSQL is installed somewhere and the /bin/ dir is on the PATH
  • Ensure you have the postgres options in your minion config:
postgres.host: '127.0.0.1'
postgres.port: '5432'
postgres.user: 'postgres'
postgres.pass: 'postgres'
postgres.maintenance_db: 'postgres'

Steps to Reproduce Issue

Run salt-call --local postgres.create_db 'test'

You will get the following output:

[INFO    ] Executing command ['C:\\Program Files\\PostgreSQL\\9.5\\bin\\psql.EXE', '--no-align', '--no-readline', '--no-psqlrc', '--no-password', '--dbname', 'p
ostgres', '-c', 'CREATE DATABASE "test"'] as user 'postgres' in directory 'C:\'
Traceback (most recent call last):
  File "C:\salt\bin\lib\site-packages\salt\cli\caller.py", line 197, in call
    ret['return'] = func(*args, **kwargs)
  File "C:\salt\bin\lib\site-packages\salt\modules\postgres.py", line 551, in db_create
    password=password, runas=runas)
  File "C:\salt\bin\lib\site-packages\salt\modules\postgres.py", line 364, in _psql_prepare_and_run
    rcmd, runas=runas, password=password, host=host, port=port, user=user)
  File "C:\salt\bin\lib\site-packages\salt\modules\postgres.py", line 181, in _run_psql
    ret = __salt__['cmd.run_all'](cmd, python_shell=False, **kwargs)
  File "C:\salt\bin\lib\site-packages\salt\modules\cmdmod.py", line 1654, in run_all
    **kwargs)
  File "C:\salt\bin\lib\site-packages\salt\modules\cmdmod.py", line 375, in _run
    raise CommandExecutionError(msg)
CommandExecutionError: password is a required argument for runas on Windows
Error running 'postgres.db_create': password is a required argument for runas on Windows

Versions Report

(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)

C:\salt>salt-call.bat --versions-report
Salt Version:
           Salt: 2016.11.1

Dependency Versions:
           cffi: 1.7.0
       cherrypy: 7.1.0
       dateutil: 2.5.3
          gitdb: 0.6.4
      gitpython: 2.0.8
          ioflo: 1.5.5
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: 1.4.5
       M2Crypto: Not Installed
           Mako: 1.0.4
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)]
   python-gnupg: 0.3.8
         PyYAML: 3.11
          PyZMQ: 16.0.1
           RAET: Not Installed
          smmap: 0.9.0
        timelib: 0.2.4
        Tornado: 4.4.1
            ZMQ: 4.1.6

System Versions:
           dist:
        machine: AMD64
        release: 2012Server
         system: Windows
        version: 2012Server 6.2.9200 SP0 Multiprocessor Free

Metadata

Metadata

Assignees

Labels

PlatformRelates to OS, containers, platform-based utilities like FS, system based appsWindowsbugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions