Skip to content

postgres_tablespace.present fails for [x] if x already present #158

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

Closed
noelmcloughlin opened this issue Sep 14, 2017 · 2 comments
Closed

Comments

@noelmcloughlin
Copy link
Contributor

Using variation of pillar.example causes formula failure (fedora 26/Salt 2017.7)

   [ERROR   ] Command '['/bin/psql', '--no-align', '--no-readline', '--no-psqlrc', '--no-password', '--dbname', 'postgres', '-c', 'CREATE TABLESPACE "my_space" OWNER "localUser" LOCATION \'/srv/my_tablespace\' ']' failed with return code: 1
    [ERROR   ] stderr: ERROR:  could not set permissions on directory "/srv/my_tablespace": Permission denied
   [ERROR   ] retcode: 1
   [ERROR   ] Error connecting to Postgresql server
   [ERROR   ] An exception occurred in this state: Traceback (most recent call last): File"/usr/lib/python2.7/site-packages/salt/state.py", line 1837, in call  **cdata['kwargs'])  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1794, in wrapper return f(*args, **kwargs) File "/usr/lib/python2.7/site-packages/salt/states/postgres_tablespace.py", line 121, in present if tblspaces[name]['Location'] != directory and not __opts__['test']:
   KeyError: 'my_space'

      ID: postgres_user-localUser
Function: postgres_user.present
    Name: localUser
  Result: True
 Comment: The user localUser has been created
 Started: 00:36:50.125273
Duration: 2517.922 ms
 Changes: 
          ----------
          localUser:
              Present

      ID: postgresql-tablespace-dir-my_space
Function: file.directory
    Name: /srv/my_tablespace
  Result: True
 Comment: Directory /srv/my_tablespace updated
 Started: 00:36:47.685616
Duration: 2.077 ms
 Changes:
          ----------
          /srv/my_tablespace:
              New Dir

      ID: postgres_tablespace-my_space
Function: postgres_tablespace.present
    Name: my_space
  Result: False
 Comment: An exception occurred in this state: Traceback (most recent call last):
            File "/usr/lib/python2.7/site-packages/salt/state.py", line 1837, in call
              **cdata['kwargs'])
            File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1794, in wrapper
              return f(*args, **kwargs)
            File "/usr/lib/python2.7/site-packages/salt/states/postgres_tablespace.py", line 121, in present
              if tblspaces[name]['Location'] != directory and not __opts__['test']:
          KeyError: 'my_space'
 Started: 00:36:55.939996
Duration: 697.953 ms
 Changes:

The directory /srv/my_dablespace/ is owned by POSIX user/group "postgres:postgres" with 0700 permissions. There is no POSIX user named localUser

Updating the pillar.example changing user to postgres does not help.

      ID: postgresql-tablespace-dir-my_space
Function: file.directory
    Name: /srv/my_tablespace
  Result: False
 Comment: The following requisites were not found
                           require: postgres_user: postgres_user_postgres
 Changes:
@noelmcloughlin
Copy link
Contributor Author

noelmcloughlin commented Sep 14, 2017

PR #159 does NOT address this issue.

@noelmcloughlin noelmcloughlin changed the title State postgres_tablespace-my_space fails using pillar.example Fedora: postgres_tablespace-my_space fails using pillar.example Sep 14, 2017
@noelmcloughlin noelmcloughlin changed the title Fedora: postgres_tablespace-my_space fails using pillar.example postgres_tablespace.present fails for [x] if x already present Jan 17, 2018
@noelmcloughlin
Copy link
Contributor Author

Fix using same workaround described in #161

$ sudo rm -fr /var/lib/postgresql/  /srv/my_tablespace/
$ for p in $(dpkg-query --list | grep postgres | awk '{print $2}' ); do sudo apt-get -y --purge remove ${p}; done
$ sudo apt autoremove -y
$ dpkg-query --list | grep postgres | awk '{print $2}'

$ sudo salt-call state.highstate --local 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant