Oefenweb / ansible-postfix

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

Issues when changing IP address and running ansible #41

Closed jamesalford closed 3 years ago

jamesalford commented 6 years ago

Set IP address to a.b.c.d on the server Run this role

# grep inet_interfaces /etc/postfix/main.cf
inet_interfaces = a.b.c.d

Change IP address to a.b.c.e

Run the role again and apt fails at running newaliases step Running newaliases newaliases: fatal: parameter inet_interfaces: no local interface found for a.b.c.d

Looks like the fact is updated for ansible_default_ipv4.address but because apt install step is before the config for postfix the error occurs.

jamesalford commented 6 years ago

Worked around this with this:

- name: check for config file
  stat:
    path: /etc/postfix/main.cf
  register: postfix_conf

- name: change IP address
  lineinfile:
    path: /etc/postfix/main.cf
    regexp: '^inet_interfaces = '
    line: 'inet_interfaces = {{ ansible_default_ipv4.address }}'
  when: postfix_conf.stat.exists
  register: change_ip

- name: restart service
  service: name=postfix state=restarted
  when: change_ip.changed
tersmitten commented 3 years ago

Closing due to inactivity