--- - name: add network files become: true ansible.builtin.template: src: "{{ item.source }}" dest: "{{ item.destination }}" owner: root group: root mode: 0664 with_items: - source: vlan.netdev.j2 destination: /etc/systemd/network/30-vlan{{ network_vlan_id }}.netdev - source: vlan.network.j2 destination: /etc/systemd/network/31-vlan{{ network_vlan_id }}.network - source: bridge.netdev.j2 destination: /etc/systemd/network/40-br{{ network_vlan_id }}.netdev - source: bridge.network.j2 destination: /etc/systemd/network/41-br{{ network_vlan_id }}.network - name: modify lacp network file become: true ansible.builtin.lineinfile: state: present insertafter: '^\[Network\]$' line: VLAN=vlan{{ network_vlan_id }} path: /etc/systemd/network/21-lacp.network - name: restart systemd-networkd become: true ansible.builtin.service: name: systemd-networkd.service state: restarted