salt
salt copied to clipboard
issue with csh and postgres state
I just ran across a little problem in 0.17.4 using a postgres state:
[root@pg-4 ~]# salt --versions-report
Salt: 0.17.4
Python: 2.7.6 (default, Dec 9 2013, 20:05:37)
Jinja2: 2.7.1
M2Crypto: 0.21.1
msgpack-python: 0.2.2
msgpack-pure: Not Installed
pycrypto: 2.6.1
PyYAML: 3.10
PyZMQ: 14.0.1
ZMQ: 4.0.3
root@pg-4:/root # salt-call state.sls atlassian.db
[INFO ] Executing command '/sbin/zfs help || :' in directory '/root'
[INFO ] Loading fresh modules for state activity
[INFO ] Executing command '/sbin/zfs help || :' in directory '/root'
[INFO ] Executing command '/sbin/zfs help || :' in directory '/root'
[INFO ] Fetching file ** skipped **, latest already in cache 'salt://atlassian/db/init.sls'
[INFO ] Executing state postgres_user.present for jirauser
[INFO ] Executing command '/usr/local/bin/psql --no-align --no-readline --dbname postgres -c \'SELECT setting FROM pg_catalog.pg_settings WHERE name = \'"\'"\'server_version\'"\'"\'\' -t' as user 'pgsql' in directory '/usr/local/pgsql'
[ERROR ] Command '/usr/local/bin/psql --no-align --no-readline --dbname postgres -c 'SELECT setting FROM pg_catalog.pg_settings WHERE name = '"'"'server_version'"'"'' -t' failed with return code: 1
[ERROR ] stderr: csh: Permission denied.
[WARNING ] Attempt to parse version of Postgres server failed. Is the server responding?
[ERROR ] An exception occurred in this state: Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/salt/state.py", line 1307, in call
ret = self.states[cdata['full']](*cdata['args'])
File "/usr/local/lib/python2.7/site-packages/salt/states/postgres_user.py", line 102, in present
if __salt__['postgres.user_exists'](name, runas=user):
File "/usr/local/lib/python2.7/site-packages/salt/modules/postgres.py", line 490, in user_exists
runas=runas)
File "/usr/local/lib/python2.7/site-packages/salt/modules/postgres.py", line 416, in user_list
if ver >= distutils.version.LooseVersion('9.1'):
File "/usr/local/lib/python2.7/distutils/version.py", line 296, in __cmp__
return cmp(self.version, other.version)
AttributeError: 'NoneType' object has no attribute 'version'
on FreeBSD, root's shell is /bin/csh, so the csh: permission denied error made me thing this was some sort of shell env parsing issue.
So, I changed the root shell to /bin/bash and everything works:
[root@pg-4 ~]# echo $SHELL
/bin/csh
[root@pg-4 ~]# export SHELL=/bin/bash
[root@pg-4 ~]# echo $SHELL
/bin/bash
[root@pg-4 ~]# salt-call state.sls atlassian.db
[INFO ] Executing command '/sbin/zfs help || :' in directory '/root'
[INFO ] Loading fresh modules for state activity
[INFO ] Executing command '/sbin/zfs help || :' in directory '/root'
[INFO ] Executing command '/sbin/zfs help || :' in directory '/root'
[INFO ] Fetching file ** skipped **, latest already in cache 'salt://atlassian/db/init.sls'
[INFO ] Executing state postgres_user.present for jirauser
[INFO ] Executing command '/usr/local/bin/psql --no-align --no-readline --dbname postgres -c \'SELECT setting FROM pg_catalog.pg_settings WHERE name = \'"\'"\'server_version\'"\'"\'\' -t' as user 'pgsql' in directory '/usr/local/pgsql'
[INFO ] Executing command '/usr/local/bin/psql --no-align --no-readline --dbname postgres -v datestyle=ISO,MDY -c \'COPY (SELECT rolname as "name", rolsuper as "superuser", rolinherit as "inherits privileges", rolcreaterole as "can create roles", rolcreatedb as "can create databases", rolcatupdate as "can update system catalogs", rolcanlogin as "can login", rolreplication as "replication", rolconnlimit as "connections", rolvaliduntil::timestamp(0) as "expiry time", rolconfig as "defaults variables" FROM pg_roles) TO STDOUT WITH CSV HEADER\'' as user 'pgsql' in directory '/usr/local/pgsql'
[INFO ] User jirauser is already present
[INFO ] Executing state postgres_database.present for jiradb
local:
----------
State: - postgres_user
Name: jirauser
Function: present
Result: True
Comment: User jirauser is already present
Changes:
----------
State: - postgres_database
Name: jiradb
Function: present
Result: True
Comment: Database jiradb is already present
Changes:
----------
State: - postgres_user
Name: feuser
Function: present
Result: True
Comment: The user feuser has been created
Changes: feuser: Present
----------
State: - postgres_database
Name: crucibledb
Function: present
Result: True
Comment: The database crucibledb has been created
Changes: crucibledb: Present
----------
State: - postgres_user
Name: stashuser
Function: present
Result: True
Comment: The user stashuser has been created
Changes: stashuser: Present
----------
State: - postgres_database
Name: stashdb
Function: present
Result: True
Comment: The database stashdb has been created
Changes: stashdb: Present
Summary
------------
Succeeded: 6
Failed: 0
------------
Total: 6
This didn't seem to be a problem in 0.17.2, but its been a while since I've ran this specific state manually.
Thanks for the report!
Some execution modules like the module for Postgres just shell out to commands on the system to perform their tasks. I suspect there's just something funky going on with your csh on that system. I'm not sure how we can really address this in Salt, to be honest.