--- - name: Gather package facts package_facts: manager: apt - name: Check if ifupdown2 is installed set_fact: must_mask: "{{ 'ifupdown2' not in ansible_facts.packages }}" - name: Mask networking before installing ifupdown2 systemd: name: networking.service masked: true when: must_mask - name: Install ifupdown2 (debian version) apt: name: ifupdown2 when: "not ifupdown2__need_upstream_version" # FIXME: ifupdown2 3.1.0-1 is not yet available, but is needed for its # better VxLAN support # See https://github.com/CumulusNetworks/ifupdown2/issues/211 - name: Install upstream version of ifupdown2 block: - name: Upload .deb file copy: src: ifupdown2_3.1.0-1_all.deb dest: /tmp/ifupdown2_3.1.0-1_all.deb - name: Install .deb file apt: deb: /tmp/ifupdown2_3.1.0-1_all.deb when: "ifupdown2__need_upstream_version" - name: Unmask networking now that ifupdown2 is installed systemd: name: networking.service masked: false when: must_mask - name: Configure ifupdown2 template: src: interfaces.j2 dest: /etc/network/interfaces owner: root group: root mode: u=rw,g=r,o= notify: - Restart networking - Bring all interfaces up - name: Enable and start networking systemd: name: networking.service state: started enabled: true ...