-
Notifications
You must be signed in to change notification settings - Fork 33
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
Provide example or method to show differences between defined vs in-use configuration #140
Comments
That's what I thought https://github.com/linux-system-roles/firewall#available-ansible-facts was supposed to be used for. Is that not suitable for your purposes?
|
Those facts are definitely helpful, however here I'd consider them more as a necessary building block than a complete solution. An example could be a case where a large number of systems have two zones configured and few rich rules in use. Having readily available Ansible to print out the differences for those servers with differences a readable manner would be very helpful. For instance, if someone opened the HTTP service in addition to the currently configured and expected HTTPS service in the public zone and created an extra rich rule in another zone, how to "easily" and in compact manner provide that information? Thanks. |
It seems to me that this is what check mode is intended for. Does the firewall role check mode not work for this situation? Or is it that the output of check mode is not easily consumable, and that you would like the data formatted in a more "user friendly" format? |
Sorry for the delay with this one, I somehow missed your questions earlier. Wrt check mode, I noticed that it doesn't work when replacing previous rules, filed #151 about that. The check mode works very well when adding something. For instance, consider this simple example:
If I run a playbook with this configuration, and then add However, if I really run the playbook with those two sources (192.168.1.1 and 192.168.122.1) enabled and then after that remove 192.168.1.1 from the variable/sources, the next playbook run will show all ok. But at this point I have no way of knowing whether any additional sources except for the currently defined 192.168.122.1 are allowed or not. Hopefully this makes it clearer what I was after initially. Thanks. |
To confirm, you would like a method to get the firewall's runtime configuration (in-use) vs its permanent (defined) as a way to verify that the in-use configuration is the expected configuration, as well as see these differences in check mode? For instance, if you used the following instructions: firewall:
- zone: public
source: 192.168.122.1
target: DROP
state: enabled You would want to see an output similar to below, showing the other dropped sources (or even a full summary of the modified zone's active settings):
Is this a correct understanding of the issue? |
The basis of this issue is the intention to have the full firewall configuration represented by ansible (inventory) variables. In cases where the configuration represented by the variables cannot be enforced anytime by using "previous: replaced", as in production environments, it hence would be good to have a mechanism to compare the configuration as represented by the variables with the actual configuration on managed hosts and get a report of the differences. So when that report showed changes, a maintenance for adjusting the firewall configuration could be scheduled. The "currently defined configuration" thus refers to the configuration as defined by the ansible variables. The "currently in-use configuration" refers to the actual (runtime + permanent) configuration on the managed hosts. For example, let's say this playbook contains the full desired configuration for the firewall:
Running the playbook, the resulting firewall configuration will be
Let's say somebody manually changes the configuration of a managed host:
Running the playbook again using --check and --diff, there is no change reported,
Running the playbook without --check, it reports
but there is no information given of what has changed. Also, running the same playbook without "previous: replaced" will not show any differences, because the configuration defined by the variables is part of the actual configuration. A potential output for the proposed comparison using "previous: replaced" in check mode could be something like
or another mechanism to show that the https and http services are not part of the configuration as defined by the variables, but are present in the actual configuration on the host. |
When using
Why can you not use
Can you provide an example of how you would like the differences to be reported? Because of the way that
output format. Also - when using firewall:
- previous: replaced
- some_setting: default_value When you apply this, the first thing the role does is to process the |
That would be ideal for understanding what settings have changed. The example I already gave in my previous comment would be a nice option, as ansible users would be used to this way of reporting. However, as you say it may be very difficult to report using the typical ansible, maybe a modified version of the facts as given by https://github.com/linux-system-roles/firewall#available-ansible-facts could be outputted.
Firstly, as myllynen commented replacing previous rules causes firewalld restart that is not suitable for most production environments - because of the short period during the restart where not new connections are allowed potentially causing issues for sensitive applications. Secondly, to be in full control of the firewall configuration it is vital to know about any potential changes to ensure proper functionality, for example in the (hopefully rare) case an administrator did some manual change to the configuration and would not update the ansible variables for firewall configuration, running the role using previous: replaced will potentially cause issues due to changed configuration. Having previous: replaced in check mode in production would be a potential option, but currently would not show which changes to the configuration would be done. Would it be possible to add the runtime configuration to the facts as given by https://github.com/linux-system-roles/firewall#available-ansible-facts ? Then the custom facts could be compared to the ansible variables to get a full picture of what would change.
To be able to understand what configuration the role replaces using "previous: replaced" I would say it will provide more information to compare the value before running the role, |
@juliaschindler Thanks for the info. Can you provide an example of how you would like the differences to be reported? |
Hello and sorry for the very late response! As because of the way that previous: replaced is implemented, it may be very difficult to report using the typical ansible, I thought of comparing the defined variables with the found firewall configuration and printing the differences if any. In the following example, there was done work zone configuration by the role. Then, manually, the http service was added to the work zone permanently. An example of the differences shown for services that are added to zone work but are not defined via ansible variables could be the following (see below). It could be expanded to 1. also show services that should be added to a zone as defined via ansible variables but are not in the actual configuration, and 2. for all zones and other configuration items like sources. Do you think that might be a viable approach to include in the role to show differences even with previous: replaced?
|
Thanks. Not sure when we can get someone to work on this, but this is helpful. |
Since replacing previous rules causes firewalld restart it is not suitable for most production environments. In case not replacing previous rules the defined configuration may not be what is in use due to local changes or previous playbook runs with different configuration. An organization might be adhering to security standards that require listing or verifying that only certain ports and services are open in firewall.
There should be a way to display differences between currently defined configuation vs currently in-use configuration. Preferably this would be a configurable step during firewall configuration which would show differences as part of a playbook run after configuring firewall. This should also be doable in check mode. Alternatively, a separate playbook or at least a document example should be available to allow organizations avoid reinventing the wheel here.
Thanks.
The text was updated successfully, but these errors were encountered: