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

Can we add the ability for ansible.posix.firewalld to use a list of services to enable? #520

Open
tdcam opened this issue Dec 28, 2023 · 0 comments
Labels
firewalld synchronize Issue and PR for firewalld module

Comments

@tdcam
Copy link

tdcam commented Dec 28, 2023

SUMMARY

For many functions, if you pass a list, the function will process all the list entries. Like for ansible.builtin.dnf, if you do a list of packages, all will get installed. But for ansible.posix.firewalld, if you try to add a list of services to enable, it fails. Under the hood, it appears that the service you list gets added to firewall-cmd --add-service, which only processes one service.

Does it make sense to add the ability to list services and have the function add it in separate firewall-cmd --add-service calls?

So a playbook would be something like:


  • name: Open ports in the firewall
    hosts: web-servers
    tasks:
    • name: add http and https to the firewall
      ansible.posix.firewalld:
      service:
      • http
      • https
        permanent: true
        immediate: true
        state: enabled

Then the function would run firewall-cmd --add-service=X for every service in the list.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

ansible.posix.firewalld

ADDITIONAL INFORMATION

Instead of having to write a single play for every port you want opened, write one play with all the services you want open and the function would loop through the services and run firewall-cmd --add-service for each one.

---
- name: Open ports in the firewall
  hosts: web-servers
  tasks:
    - name: add http and https to the firewall
    ansible.posix.firewalld:
      service:
        - http
        - https
      permanent: true
      immediate: true
      state: enabled
@saito-hideki saito-hideki added the firewalld synchronize Issue and PR for firewalld module label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
firewalld synchronize Issue and PR for firewalld module
Projects
None yet
Development

No branches or pull requests

2 participants