--- - when: netplan_manage block: - name: Install netplan ansible.builtin.apt: name: netplan.io - name: Update netplan default.yaml ansible.builtin.copy: content: "{{netplan_content}}" dest: /etc/netplan/default.yaml owner: root group: root mode: '0640' register: netplan_default_yaml - name: Apply netplan when: netplan_default_yaml.changed and netplan_apply ansible.builtin.command: argv: ['netplan', 'apply']