Skip to content

postfix service on specific port fails #100

Description

@go8ose

Describe the bug

I get a SaltRenderError when I try to use this forumla to make postfix listen on localhost:10025.

Setup

I'm using a github fork of this repository. It's on version 077a6a6.

Steps to reproduce the bug

I have a pillar that reads (in part, snipped for brevity):

 16 postfix:
 17   manage_master_config: True
 18   master_config:
 19     enable_dovecot: True
 20     enable_submission: True
 21     services:
 22         # Make postfix listen on a port for emails to return from amavisd.
 23         localhost:10025:
 24           command: smtpd
 25           type: inet
 26           private: n
 27           args:
 28              - 'content_filter='
 29              - 'smtpd_delay_reject=no'

(Edit 2019-10-06, fixed example pillar to show "localhost:10025" instead of "localhost_10025", as the former actually causes the SaltRenderError, the later is what I had committed to my pillar to avoid the exception being thrown)

When I run salt, I see an error.

$ sudo salt 'mcconnell*' --state-output=changes state.apply postfix.config  saltenv=
dev pillarenv=dev test=True
mcconnell.lan:
  Name: postfix - Function: pkg.installed - Result: Clean Started: - 22:26:29.418995 Duration: 52.299 
ms
  Name: /etc/postfix/main.cf - Function: file.managed - Result: Clean Started: - 22:26:29.476628 Durat
ion: 95.722 ms
----------
          ID: /etc/postfix/master.cf
    Function: file.managed
      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 1933, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1951, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/states/file.py", line 2769, in managed
                  **kwargs
                File "/usr/lib/python2.7/dist-packages/salt/modules/file.py", line 4824, in check_mana
ged_changes
                  **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/modules/file.py", line 4265, in get_manage
d
                  **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 169, in render_t
mpl
                  output = render_str(tmplstr, context, tmplpath)
                File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 406, in render_j
inja_tmpl
                  buf=tmplstr)
              SaltRenderError: Jinja variable 'unicode object' has no attribute 'get': "<Template memory:7f00b17cded0>", "0"
     Started: 22:26:29.572605
    Duration: 133.425 ms
     Changes:   
----------
…

Expected behaviour

I would expect salt to write out a /etc/postfix/master.cf file that includes an entry for "localhost:10025", which has the arguments listed above (such as content_filter, smtpd_delay_reject, etc). I would expect salt to restart postfix, and then postfix to be listening on port 10025.

Versions report

$ salt --versions-report
Salt Version:
           Salt: 2019.2.1

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.5.3
      docker-py: Not Installed
          gitdb: 2.0.0
      gitpython: 2.1.1
          ioflo: Not Installed
         Jinja2: 2.9.4
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.13 (default, Sep 26 2018, 18:42:22)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: 2.0.1
        timelib: Not Installed
        Tornado: 4.4.3
            ZMQ: 4.2.1

System Versions:
           dist: debian 9.11
         locale: UTF-8
        machine: x86_64
        release: 4.9.0-9-amd64
         system: Linux
        version: debian 9.11

Additional context

I've done some investigation. I suspect in postfix/files/master.cf, in the "Handle custom services" section at the end, the "pillar.get" on 'postfix:master_config:services:%s' is causing a lookup of 'postfix:master_config:services:localhost:10025', which is not a key that exists in my pillar.

I don't know how to define a pillar that will result in the formula writing out a postfix service entry for "localhost:10025", and will also satisfy that pillar.get lookup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions