Skip to content

User creation and DB creation in the same run not working #152

Open
@johnkeates

Description

@johnkeates

Creating a user and assigning a database (or the other way around) doesn't work properly. Probably because users are fetched and cached?


      ID: postgres_user-provisioner_local
Function: postgres_user.present
    Name: provisioner_local
  Result: True
 Comment: The user provisioner_local has been created
 Started: 15:13:29.747481
Duration: 519.459 ms
 Changes:   
          ----------
          provisioner_local:
              Present

      ID: postgres_database-provisioner_local
Function: postgres_database.present
    Name: provisioner_local
  Result: False
 Comment: An exception occurred in this state: Traceback (most recent call last):
            File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1746, in call
              **cdata['kwargs'])
            File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1704, in wrapper
              return f(*args, **kwargs)
            File "/usr/lib/python2.7/dist-packages/salt/states/postgres_database.py", line 98, in present
              dbs = __salt__['postgres.db_list'](**db_args)
            File "/usr/lib/python2.7/dist-packages/salt/modules/postgres.py", line 461, in db_list
              password=password)
            File "/usr/lib/python2.7/dist-packages/salt/modules/postgres.py", line 417, in psql_query
              password=password)
            File "/usr/lib/python2.7/dist-packages/salt/modules/postgres.py", line 364, in _psql_prepare_and_run
              rcmd, runas=runas, password=password, host=host, port=port, user=user)
            File "/usr/lib/python2.7/dist-packages/salt/modules/postgres.py", line 181, in _run_psql
              ret = __salt__['cmd.run_all'](cmd, python_shell=False, **kwargs)
            File "/usr/lib/python2.7/dist-packages/salt/modules/cmdmod.py", line 1662, in run_all
              **kwargs)
            File "/usr/lib/python2.7/dist-packages/salt/modules/cmdmod.py", line 394, in _run
              'User \'{0}\' is not available'.format(runas)
          CommandExecutionError: User 'provisioner_local' is not available
 Started: 15:13:30.268091
Duration: 13.714 ms
 Changes:   `

Pillar:
`

postgres:
  #pg_hba.conf: salt://postgres/pg_hba.conf
  conf_dir: /etc/postgresql/9.4/main
  lookup:
    pkg: 'postgresql-9.4'
    pkg_client: 'postgresql-client-9.4'
    pkg_dev: 'postgresql-server-dev-9.4'
    pkg_contrib: 'postgresql-contrib-9.4'
    pg_hba: '/etc/postgresql/9.4/main/pg_hba.conf'
  version: 9.4

  users:
      provisioner_local:
        password: 'dfsjkle45980dfgkjl'
        createdb: False

  acls:
    - ['host', 'provisioner_local', 'provisioner_local', '0.0.0.0/0', 'md5']


  databases:
    provisioner_local:
      owner: 'provisioner_local'
      user: 'provisioner_local'
      template: 'template0'
      lc_ctype: 'C.UTF-8'
      lc_collate: 'C.UTF-8'
   
  postgresconf: |
    listen_addresses = '0.0.0.0'

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions