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

"ERROR: Bad port 'SSH'" (from community.general.ufw) #5

Closed
pdemarti opened this issue Oct 31, 2021 · 1 comment
Closed

"ERROR: Bad port 'SSH'" (from community.general.ufw) #5

pdemarti opened this issue Oct 31, 2021 · 1 comment

Comments

@pdemarti
Copy link

Describe the bug

It seems that community.general.ufw doesn't work with the task "Allow all access to SSH, DNS, and WWW".
When playing that task, we see:

TASK [Allow all access to SSH, DNS, and WWW] ********************************************************************************************************************************
failed: [192.168.1.2] (item=SSH) => {"ansible_loop_var": "item", "changed": false, "commands": ["/usr/sbin/ufw status verbose", "/usr/bin/grep -h '^### tuple' /lib/ufw/user.rules /lib/ufw/user6.rules /etc/ufw/user.rules /etc/ufw/user6.rules /var/lib/ufw/user.rules /var/lib/ufw/user6.rules", "/usr/sbin/ufw --version", "/usr/sbin/ufw allow from any to any port SSH"], "item": "SSH", "msg": "ERROR: Bad port 'SSH'\n"}
failed: [192.168.1.2] (item=DNS) => {"ansible_loop_var": "item", "changed": false, "commands": ["/usr/sbin/ufw status verbose", "/usr/bin/grep -h '^### tuple' /lib/ufw/user.rules /lib/ufw/user6.rules /etc/ufw/user.rules /etc/ufw/user6.rules /var/lib/ufw/user.rules /var/lib/ufw/user6.rules", "/usr/sbin/ufw --version", "/usr/sbin/ufw allow from any to any port DNS"], "item": "DNS", "msg": "ERROR: Bad port 'DNS'\n"}
failed: [192.168.1.2] (item=WWW) => {"ansible_loop_var": "item", "changed": false, "commands": ["/usr/sbin/ufw status verbose", "/usr/bin/grep -h '^### tuple' /lib/ufw/user.rules /lib/ufw/user6.rules /etc/ufw/user.rules /etc/ufw/user6.rules /var/lib/ufw/user.rules /var/lib/ufw/user6.rules", "/usr/sbin/ufw --version", "/usr/sbin/ufw allow from any to any port WWW"], "item": "WWW", "msg": "ERROR: Bad port 'WWW'\n"}
failed: [192.168.1.2] (item=WWW Secure) => {"ansible_loop_var": "item", "changed": false, "commands": ["/usr/sbin/ufw status verbose", "/usr/bin/grep -h '^### tuple' /lib/ufw/user.rules /lib/ufw/user6.rules /etc/ufw/user.rules /etc/ufw/user6.rules /var/lib/ufw/user.rules /var/lib/ufw/user6.rules", "/usr/sbin/ufw --version", "/usr/sbin/ufw allow from any to any port WWW Secure"], "item": "WWW Secure", "msg": "ERROR: Wrong number of arguments\n"}

Proposed fix:

Change port into name in the task:

@@ -163,7 +177,7 @@
       become: true
       community.general.ufw:
         rule: allow
-        port: '{{ item }}'
+        name: '{{ item }}'
       loop:
         - SSH
         - DNS
@benbalter
Copy link
Owner

Thanks for flagging that. Corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants