'For loop only takes last element in list?

Currently, I'm trying to disable and mask several network related system services using SaltStack under Ubuntu 20.04. Now, things got a bit confusing here. In the end, I need to disable several services, so I built a for loop accordingly, please see below:

init.sls:
stop_netplan_services:
  service.disabled:
    {% for services in [ 'systemd-resolved', 'systemd-networkd.socket', 'systemd-networkd', 'systemd-networkd-wait-online', 'networkd-dispatcher' ] %}
    - name: {{ services }}
    {% endfor %}
    - require:
      - dead_netplan_services

If I trigger my high state, only the last service in the list gets respected, talking about the networkd-dispatcher here. Everything else simply does not get applied. Why is 'systemd-resolved', 'systemd-networkd.socket' etc ... ignored in this for loop?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source