Oefenweb / ansible-postfix

Ansible role to set up postfix in Debian-like systems
MIT License
173 stars 82 forks source link

`--check` command results in "Unexpected templating type error occurred on (# {{ ansible_managed }}" ... 'bool' object is not iterable" #110

Closed markstos closed 2 years ago

markstos commented 3 years ago

Below is the full error I got.

Here are the vars I had defined in the playbook:

  vars:
    postfix_aliases:
      - user: root
        alias: devops@example.com
    postfix_relayhost: email-smtp.us-east-1.amazonaws.com
    postfix_relaytls: true
    postfix_inet_interfaces: true
    # AWS IAM SES credentials (not access key):
    postfix_sasl_user: "REDACTED"
    postfix_sasl_password: "REDACTED"

Ansible 2.10.7, running against a Ubuntu 18.04 server

FAILED! => {"changed": false, "msg": "AnsibleError: Unexpected templating type error occurred on (# {{ ansible_managed }}\n\n# See /usr/share/postfix/main.cf.dist for a commented, more complete version\n\n# Debian specific:  Specifying a file name will cause the first\n# line of that file to be used as the name.  The Debian default\n# is /etc/mailname.\nmyorigin = {{ postfix_mailname_file }}\n\nsmtpd_banner = {{ postfix_smtpd_banner }}\nbiff = no\n\n# appending .domain is the MUA's job.\nappend_dot_mydomain = no\n\n# Uncomment the next line to generate \"delayed mail\" warnings\n#delay_warning_time = 4h\n\nreadme_directory = no\n\n{% if postfix_compatibility_level is defined %}\ncompatibility_level = {{ postfix_compatibility_level }}\n{% endif %}\n\n# TLS parameters\nsmtpd_tls_cert_file = {{ postfix_smtpd_tls_cert_file }}\nsmtpd_tls_key_file = {{ postfix_smtpd_tls_key_file }}\nsmtpd_use_tls=yes\nsmtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache\nsmtp_tls_session_cache_database = btree:${data_directory}/smtp_scache\n\n# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for\n# information on enabling SSL in the smtp client.\n\nmyhostname = {{ postfix_hostname }}\ndefault_database_type = {{ postfix_default_database_type }}\nalias_maps = {{ postfix_default_database_type }}:{{ postfix_aliases_file }}\nalias_database = {{ postfix_default_database_type }}:{{ postfix_aliases_file }}\n{% if postfix_virtual_aliases %}\nvirtual_alias_maps = {{ postfix_default_database_type }}:{{ postfix_virtual_aliases_file }}\n{% endif %}\n{% if postfix_sender_canonical_maps %}\nsender_canonical_maps = {{ postfix_sender_canonical_maps_database_type }}:{{ postfix_sender_canonical_maps_file }}\n{% endif %}\n{% if postfix_recipient_canonical_maps %}\nrecipient_canonical_maps = {{ postfix_recipient_canonical_maps_database_type }}:{{ postfix_recipient_canonical_maps_file }}\n{% endif %}\n{% if postfix_transport_maps %}\ntransport_maps = {{ postfix_transport_maps_database_type }}:{{ postfix_transport_maps_file }}\n{% endif %}\n{% if postfix_sender_dependent_relayhost_maps %}\nsender_dependent_relayhost_maps = {{ postfix_default_database_type }}:{{ postfix_sender_dependent_relayhost_maps_file }}\n{% endif %}\n{% if postfix_smtp_generic_maps %}\nsmtp_generic_maps = {{ postfix_smtp_generic_maps_database_type }}:{{ postfix_smtp_generic_maps_file }}\n{% endif %}\n{% if postfix_header_checks %}\nsmtp_header_checks = {{ postfix_header_checks_database_type }}:{{ postfix_header_checks_file }}\n{% endif %}\nmydestination = {{ postfix_mydestination | join(', ') }}\nmynetworks = {{ postfix_mynetworks | join(' ') }}\nmailbox_size_limit = 0\nrecipient_delimiter = +\n{% if postfix_inet_interfaces is string %}\ninet_interfaces = {{ postfix_inet_interfaces }}\n{% else %}\ninet_interfaces = {{ postfix_inet_interfaces | join(', ') }}\n{% endif %}\n{% if postfix_inet_protocols is string %}\ninet_protocols = {{ postfix_inet_protocols }}\n{% else %}\ninet_protocols = {{ postfix_inet_protocols | join(', ') }}\n{% endif %}\n\n{% if postfix_relayhost %}\n{% if postfix_relayhost_mxlookup %}\nrelayhost = {{ postfix_relayhost }}:{{ postfix_relayhost_port }}\n{% else %}\nrelayhost = [{{ postfix_relayhost }}]:{{ postfix_relayhost_port }}\n{% endif %}\n{% if postfix_sasl_auth_enable %}\nsmtp_sasl_auth_enable = {{ postfix_sasl_auth_enable | bool | ternary('yes', 'no') }}\nsmtp_sasl_password_maps = {{ postfix_default_database_type }}:{{ postfix_sasl_passwd_file }}\nsmtp_sasl_security_options = {{ postfix_sasl_security_options }}\nsmtp_sasl_tls_security_options = {{ postfix_sasl_tls_security_options }}\nsmtp_sasl_mechanism_filter = {{ postfix_sasl_mechanism_filter }}\n{% endif %}\n{% if postfix_relaytls %}\nsmtp_use_tls = {{ postfix_relaytls | bool | ternary('yes', 'no') }}\nsmtp_tls_security_level = {{ postfix_smtp_tls_security_level }}\nsmtp_tls_note_starttls_offer = {{ postfix_smtp_tls_note_starttls_offer | bool | ternary('yes', 'no') }}\n{% if postfix_smtp_tls_cafile is defined %}\nsmtp_tls_CAfile = {{ postfix_smtp_tls_cafile }}\n{% endif %}\n{% endif %}\n{% else %}\nrelayhost =\n{% endif %}\n\n{% if postfix_smtpd_client_restrictions is defined %}\nsmtpd_client_restrictions = {{ postfix_smtpd_client_restrictions | join(', ') }}\n{% endif %}\n{% if postfix_smtpd_helo_restrictions is defined %}\nsmtpd_helo_restrictions = {{ postfix_smtpd_helo_restrictions | join(', ') }}\n{% endif %}\n{% if postfix_smtpd_sender_restrictions is defined %}\nsmtpd_sender_restrictions = {{ postfix_smtpd_sender_restrictions | join(', ') }}\n{% endif %}\n{% if postfix_smtpd_recipient_restrictions is defined %}\nsmtpd_recipient_restrictions = {{ postfix_smtpd_recipient_restrictions | join(', ') }}\n{% endif %}\n{% if postfix_smtpd_relay_restrictions is defined %}\nsmtpd_relay_restrictions = {{ postfix_smtpd_relay_restrictions | join(', ') }}\n{% endif %}\n{% if postfix_smtpd_data_restrictions is defined %}\nsmtpd_data_restrictions = {{ postfix_smtpd_data_restrictions | join(', ') }}\n{% endif %}\n\nmessage_size_limit = {{  postfix_message_size_limit }}\n\n# Disable the SMTP VRFY command. This stops some techniques used to harvest email addresses.\ndisable_vrfy_command = {{ postfix_disable_vrfy_command | bool | ternary('yes', 'no') }}\n\n{% for raw_option in postfix_raw_options | default([]) %}\n{{ raw_option }}\n{% endfor %}\n): 'bool' object is not iterable"}
ljurgs commented 3 years ago

postfix_inet_interfaces: true

I'm pretty sure this line is your problem, this needs to be a string or an array of strings. The default value for the role is 'ALL', so I'd just just omit this line completely unless you want to restrict binding to 127.0.0.1 or another trusted network: http://www.postfix.org/postconf.5.html#inet_interfaces

tersmitten commented 2 years ago

Close due to inactivity and a possible fix. Feel free to reopen if you still think this is a bug.