--- - name: install postfix package apt: name: postfix state: present - name: basic postfix options vars: postfix_options: mydestination: "{{ postfix_base_mydestination | join(', ') }}" mynetworks: "{{ postfix_base_mynetworks | join(', ') }}" relayhost: "{{ postfix_base_relayhost }}" inet_interfaces: "{{ postfix_base_inet_interfaces | join(', ') }}" inet_protocols: "{{ postfix_base_inet_protocols | join(', ') }}" loop: "{{ postfix_options | dict2items }}" loop_control: label: "{{ item.key }} = {{ item.value }}" lineinfile: regexp: "^#?\\s*{{ item.key }}\\s*=" line: "{{ item.key }} = {{ item.value }}" dest: /etc/postfix/main.cf notify: restart postfix