From dcd18fa053b441e2cb1a5cfb13c0b3394eaafe61 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Wed, 27 Jan 2021 11:56:46 -0600 Subject: [PATCH] Add an alias for "port" when handling firewall rules This change adds an internal alias for port to dport. This is done to allow legacy config to operate as expected should a user have overrides with the puppet legacy option. Should the action plugin encounter a rule with the deprecated option a notice will be printed on screen containing the rule and and information on how to convert it so that functionality isn't lost on a future release. Change-Id: I0643345a144a4b4c94c11465e9f8a82f13da146d Signed-off-by: Kevin Carter --- .../ansible_plugins/action/tripleo_iptables.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tripleo_ansible/ansible_plugins/action/tripleo_iptables.py b/tripleo_ansible/ansible_plugins/action/tripleo_iptables.py index 0512845f2..7a38e50b0 100644 --- a/tripleo_ansible/ansible_plugins/action/tripleo_iptables.py +++ b/tripleo_ansible/ansible_plugins/action/tripleo_iptables.py @@ -242,9 +242,20 @@ class ActionModule(ActionBase): } ) - if 'dport' in rule: + # NOTE(cloudnull): while dport is the only supported option, + # port has been added as an ailias to ensure + # our legacy configs remain functional. + if 'dport' in rule or 'port' in rule: dport_rule_data = versioned_rule_data.copy() - dports = rule['dport'] + dports = rule.get('dport', 'port') + + if 'port' in rule: + DISPLAY.v( + 'The use of "port" is deprecated and will be' + ' removed in a future release. Please convert' + ' all uses of "port" to "dport".' + ) + if not isinstance(dports, list): dports = [dports]