Comments (9)
probably wants a default argument, which in this case would be
{%- if not salt.get('postgres.user_create', False) %}
from postgres-formula.
@fcrozat Thanks for you report.
I've tested the code with Salt 2016.3.4
and 2016.11.1
many times and it always works fine for me. Maybe it is related to particular jinja
module version installed...
Try to replace the line with the following:
{%- if 'postgres.user_create' not in salt.keys() %}
I hope this will help. If so, we update the code accordingly.
from postgres-formula.
changing to {%- if not salt.get('postgres.user_create', False) %} works fine.
other proposed fix ( %- if 'postgres.user_create' not in salt.keys() %} )doesn't work:
-
Rendering SLS 'base:postgres.manage' failed: Jinja error: 'FunctionWrapper' object has no attribute 'call'
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/utils/templates.py", line 368, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "", line 5, in top-level template code
AttributeError: 'FunctionWrapper' object has no attribute 'call'; line 5 --- {%- from "postgres/map.jinja" import postgres with context -%} {%- from "postgres/macros.jinja" import format_state with context -%} {# }{%- if not salt.get('postgres.user_create') %} #} {%- if 'postgres.user_create' not in salt.keys() %} <====================== # Salt states for managing PostgreSQL is not available, # need to provision client binaries first include: [...] ---
from postgres-formula.
@fcrozat Thanks a lot for testing.
This is very interesting, it looks like ordinary Python methods cannot be reliably used for special Jinja objects such as salt
, at least in your case. And I think the get()
method cannot be fully trusted here to do the job I thought it was supposed to do.
Please, could you try the last one code snippet since only you are able to reproduce the issue?
Check this out if it would work:
{%- if salt['postgres.user_create']|default(none) is not callable %}
I assume this is the safest check for the exec module function present (and actually is a function) in the state run scope.
Thanks again for your involvement.
from postgres-formula.
I can confirm the latest proposed fix works fine here.
from postgres-formula.
Cool! That was very helpful, @fcrozat. Soon I will come up with a PR to fix this and other similar calls to the salt
object across the formula.
from postgres-formula.
I have submitted PR #150 to address this issue.
from postgres-formula.
@fcrozat PR #150 has been merged. I think this issue could be closed. Thanks for your participation!
from postgres-formula.
@javierbertoli Since this is already resolved, please close it out. Thanks!
from postgres-formula.
Related Issues (20)
- Command "service postgresql initdb" run failing on /etc/init.d/postgresql
- jinja strip white spaces option in salt master config causes a broken pg_hba.conf HOT 2
- use_upstream_repo is unable to install the latest version of pg on Centos 7 HOT 4
- Unable to locate package on debian stretch HOT 16
- Package 'libpqxx' not found
- Initial postgresql.conf file not managed HOT 12
- osFamilyMap.yaml FreeBSD default user HOT 3
- Setting `postgres.port` does not work on `RedHat` OSes
- "LATIN1" does not match locale "en_US.UTF-8" HOT 8
- Does not work with Debian Buster HOT 1
- Uses initdb even when it's not needed
- state failures on archlinux HOT 1
- Tavis CI job failure for redhat
- freebsd: User 'pgsql' is not available
- [BUG] tablespace state failure on CENT8/RHEL8
- [BUG] nothing provides libicui18n.so.52.1()(64bit) for postgresql10 HOT 2
- [BUG] postgres.dev state fails on suse
- [FEATURE] replace module.run function when postgres.bake_image=True
- [BUG] Postgesql version install 14 instead of 13
- [BUG] postgresql-common conflicts with pgdg-keyring HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postgres-formula.