I'm trying to use a conditional based on pillar data within a statefile that creates pgsql users/databases based on a flag in pillar and I'm not having any luck. I've attempted to use variants on the following "if" methods without much luck.... To confirm, calling salt hostname\* pillar.data key=postgres_config, returns the appropriate information as does calling pillar.get. It just seems to never evaluate as "true" in this instances.
postgres_config:
devel_staging:
database_host: localhost
database_name: devel_staging
database_username: username
database_password: lulpasswordlul
database_port: 5432
database_local: 1
{% for dbname, args in pillar['postgres_config'].iteritems() %}
{% if {{ args['database_username'] }} == "1" %}
create-role-{{ dbname }}:
postgres_user.present:
- name: {{ args['database_username'] }}
- createdb: False
- createuser: False
- superuser: False
- encrypted: True
- password: {{ args['database_password'] }}
- runas: postgres
- require:
- service: postgresql-9.1
postgres_database.present:
- owner: {{ args['database_username'] }}
- name: {{ args['database_name'] }}
- runas: postgres
- lc_ctype: en_US.UTF-8
- lc_collate: en_US.UTF-8
- encoding: UTF8
- require:
- postgres_user: {{ args['database_username'] }}
{% endif %}
{% endfor %}