iptables to_ports translates to –to-ports instead of –dports

Summary

I am using iptables in a play book and when setting to_ports it will output as --to-ports instead of --dports

Issue Type

Bug Report

Component Name

ansible.builtin.iptables

Ansible Version

ansible 2.10.7
  config file = /home/blue/workspace/linode-swarm/ansible/ansible.cfg
  configured module search path = ['/home/blue/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/blue/.local/lib/python3.8/site-packages/ansible
  executable location = /home/blue/.local/bin/ansible
  python version = 3.8.6 (default, Jan 27 2021, 15:42:20) [GCC 10.2.0]

Configuration

DEFAULT_HOST_LIST(/home/blue/workspace/linode-swarm/ansible/ansible.cfg) = ['/home/blue/workspace/linode-swarm/ansible/inventory']
DEFAULT_REMOTE_USER(/home/blue/workspace/linode-swarm/ansible/ansible.cfg) = root

OS / Environment

Target:
Linode – Nanode Ubuntu 20
Summary
1 CPU Core
25 GB Storage
1 GB RAM
0 Volumes

Steps to Reproduce

    - name: allow swarm nodes tcp
      iptables:
        chain: INPUT
        source: "{{item}}/32"
        jump: ACCEPT
        ctstate: NEW
        to_ports: 2377,7946
        protocol: tcp
      loop: "{{SWARM_ADDRS}}"

Expected Results

-t filter -A INPUT -p tcp -s 192.168.131.162/32 -j ACCEPT  -m multiport --dports 2377,7946 -m conntrack --ctstate NEW

Actual Results

-t filter -A INPUT -p tcp -s 192.168.131.162/32 -j ACCEPT --to-ports 2377,7946 -m conntrack --ctstate NEW

1 possible answer(s) on “iptables to_ports translates to –to-ports instead of –dports