Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network: support for [RoutingPolicyRule] and its most common parameters #45

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ for emergencies or non-content releases).

## [Unreleased]

- Added `routing_policy_rules` block to the `network` role.

## [25.2.0] - 2025-01-11

### Added
Expand Down
20 changes: 20 additions & 0 deletions src/roles/network/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,26 @@ argument_specs:
mtu_bytes:
description: The MTU to be applied to this route.
type: str
routing_policy_rules:
description: Rules for policy-based routing.
type: list
elements: dict
options:
from:
description: Source address prefix to match.
type: str
to:
description: Destination address prefix to match.
type: str
firewall_mark:
description: Netfilter firewall mark to match.
type: str
table:
description: Routing table to look up in case of match.
type: str
priority:
description: Priority of this rule.
type: int
dhcpv4:
description: Attributes of the DHCPv4 client on the network.
type: dict
Expand Down
17 changes: 17 additions & 0 deletions src/roles/network/templates/network.j2
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@
{% endif %}
{% endfor %}

{% endfor %}
{% endif %}
{% if "routing_policy_rules" in network -%}
{% for v in network.routing_policy_rules -%}
[RoutingPolicyRule]
{% for arg, value in v.items() %}
{% if value is string or value is integer %}
{{ network_routing_policy_rule_arguments[arg] }}={{ value }}
{% elif value is boolean %}
{{ network_routing_policy_rule_arguments[arg] }}={{ value|ternary('yes','no') }}
{% else %}
{% for v in value %}
{{ network_routing_policy_rule_arguments[arg] }}={{ v }}
{% endfor %}
{% endif %}
{% endfor %}

{% endfor %}
{% endif %}
{% if "cake" in network -%}
Expand Down
7 changes: 7 additions & 0 deletions workflow-support/parameter_mapping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ network_route_arguments:
source: Source
type: Type

network_routing_policy_rule_arguments:
from: From
to: To
firewall_mark: FirewallMark
table: Table
priority: Priority

network_dhcpv4_arguments:
client_identifier: ClientIdentifier
hostname: Hostname
Expand Down
2 changes: 2 additions & 0 deletions workflow-support/templates/network-vars.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ network_dhcpv6_arguments: {{ network_dhcpv6_arguments }}
network_ipv6acceptra_arguments: {{ network_ipv6acceptra_arguments }}

network_cake_arguments: {{ network_cake_arguments }}

network_routing_policy_rule_arguments: {{ network_routing_policy_rule_arguments }}