ansible-role-systemd_networkd/vars/main.yml
Dmitriy Rabotyagov 18b36137dc Ensure filename is always defined for network/netdev
Right now we define resulting filename in the loop itself, which limits
ability to predict expected filename for another loop where list might
get filtered.

So to get more expected behaviour between tasks we always add filename
to the elements in vars.

Change-Id: I579980ea3a5e9349d25885530c979649cb6dcb81
2023-12-08 17:51:16 +00:00

36 lines
1.5 KiB
YAML

---
# Copyright 2018, Logan Vig <logan2211@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
## APT Cache options
cache_timeout: 600
_systemd_networks_named: |-
{% set named_networks = systemd_networks | selectattr('filename', 'defined') %}
{% for network in systemd_networks | rejectattr('filename', 'defined') %}
{% set network_filename = [loop.index0, systemd_networkd_prefix, network['interface']] %}
{% set _ = network.update({'filename': network_filename | join('-') }) %}
{% set _ = named_networks.append(network) %}
{% endfor %}
{{ named_networks }}
_systemd_netdevs_named: |-
{% set named_netdevs = systemd_netdevs | selectattr('filename', 'defined') %}
{% for netdev in systemd_netdevs | rejectattr('filename', 'defined') %}
{% set netdev_filename = [loop.index0, systemd_networkd_prefix, netdev['NetDev']['Name']] %}
{% set _ = netdev.update({'filename': netdev_filename | join('-') }) %}
{% set _ = named_netdevs.append(netdev) %}
{% endfor %}
{{ named_netdevs }}