Skip to content

Commit ab7f301

Browse files
committed
WIP: It's not a hacky workaround if it works
1 parent 8987d40 commit ab7f301

File tree

4 files changed

+92
-21
lines changed

4 files changed

+92
-21
lines changed

doc/source/configuration/firewall.rst

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,28 @@ VM:
253253
zone: "{{ admin_oc_net_name | net_zone }}"
254254
state: disabled
255255
256-
Extra rules have higher precedence than the default rules, but are not
256+
Extra rules have higher precedence than the default rules but are not
257257
validated before being applied. Use with caution. If you need to add a custom
258258
rule, consider adding it to the default rule list with an appropriate boolean
259259
condition, and where possible merge your changes back into upstream SKC.
260260

261+
Kolla-Ansible configuration
262+
---------------------------
263+
264+
Ensure Kolla Ansible opens up ports in firewalld for services on the public
265+
API network:
266+
267+
.. code-block:: yaml
268+
:caption: ``etc/kayobe/kolla/globals.yml``
269+
270+
enable_external_api_firewalld: true
271+
external_api_firewalld_zone: "{{ public_net_name | net_zone }}"
272+
273+
Ensure every network in ``networks.yml`` has a zone defined. The standard
274+
configuration is to set the internal network zone to ``trusted`` and every
275+
other zone to the name of the network. See
276+
``etc/kayobe/environments/ci-multinode/networks.yml`` for a practical example.
277+
261278
Validation
262279
----------
263280

@@ -268,33 +285,55 @@ that will be applied to a host.
268285
269286
kayobe configuration dump --var-name stackhpc_firewalld_rules --limit <host>
270287
271-
If the command above prints a template, rather than a clean list of rules, the
272-
configuration is invalid. The kayobe configuration dump command can be used on
273-
other variables such as ``stackhpc_firewalld_rules_default`` or
288+
A shorter version, ``stackhpc_firewalld_rules_debug`` prints the rules in a
289+
simplified format:
290+
291+
.. code-block:: bash
292+
293+
kayobe configuration dump --var-name stackhpc_firewalld_rules_debug --limit <host>
294+
295+
If the commands above print a template, rather than a list of rules, the
296+
configuration may be invalid. The ``kayobe configuration dump`` command can be
297+
used on other variables such as ``stackhpc_firewalld_rules_default`` or
274298
``stackhpc_*_firewalld_rules_template`` to debug the configuration. See the
275299
`How it works`_ section for more details.
276300

277-
Kolla-Ansible configuration
278-
---------------------------
301+
It can be useful to print the active ports on each type of host, to create
302+
rules for running services. The internal network is currently left open. The
303+
below command will print all other open ports:
279304

280-
Ensure Kolla Ansible opens up ports in firewalld for services on the public
281-
API network:
305+
.. code-block:: bash
282306
283-
.. code-block:: yaml
284-
:caption: ``etc/kayobe/kolla/globals.yml``
307+
ss -lntpu | grep --invert-match '<internal net ip>'
285308
286-
enable_external_api_firewalld: true
287-
external_api_firewalld_zone: "{{ public_net_name | net_zone }}"
309+
It is strongly recommended that you dry-run the changes using ``--diff`` and
310+
``--check`` before applying to a production system:
288311

289-
Ensure every network in ``networks.yml`` has a zone defined. The standard
290-
configuration is to set the internal network zone to ``trusted`` and every
291-
other zone to the name of the network. See
292-
``etc/kayobe/environments/ci-multinode/networks.yml`` for a practical example.
312+
.. code-block:: bash
313+
:caption: ``Overcloud diff example``
314+
315+
kayobe overcloud host configure -t firewall --diff --check
293316
294317
Applying changes
295318
----------------
296319

297-
Use the ``kayobe * host configure`` commands to apply the changes:
320+
Before applying these changes, you should be completely sure you are not going
321+
to lock yourself out of any hosts. If you are deploying these changes to a test
322+
environment, it might be appropriate to set a password on the stack user so
323+
that you can access the host through a BMC or horizon console.
324+
325+
The following Kayobe command can be used to set a password on all overcloud
326+
hosts:
327+
328+
.. code-block:: bash
329+
330+
kayobe overcloud host command run --command "echo 'stack:super-secret-password' | sudo chpasswd" --show-output
331+
332+
Changes should be applied to controllers one at a time to ensure connectivity
333+
is not lost.
334+
335+
Once you are sure you know what you are doing, use the ``kayobe * host
336+
configure`` commands to apply the firewall changes:
298337

299338
.. code-block:: bash
300339
@@ -304,7 +343,13 @@ Use the ``kayobe * host configure`` commands to apply the changes:
304343
kayobe seed host configure -t network,firewall
305344
# For Infrastructure VM hosts
306345
kayobe infra vm host configure -t network,firewall
307-
# For Overcloud hosts
346+
# For the First Controller
347+
kayobe overcloud host configure -t network,firewall -l controllers[0]
348+
# For the Second Controller
349+
kayobe overcloud host configure -t network,firewall -l controllers[1]
350+
# For the Third Controller
351+
kayobe overcloud host configure -t network,firewall -l controllers[2]
352+
# For the rest of the Overcloud hosts
308353
kayobe overcloud host configure -t network,firewall
309354
310355
How it works
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
3+
stackhpc_firewalld_rules_extra:
4+
- port: "{{ vxlan_dstport }}/udp"
5+
network: "{{ admin_oc_net_name }}"
6+
zone: "{{ admin_oc_net_name | net_zone }}"
7+
state: enabled

etc/kayobe/environments/ci-multinode/networks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ storage_mgmt_net_name: storage_mgmt
7272
# Network definitions.
7373

7474
# Admin overcloud network
75-
admin_oc_zone: "trusted"
75+
admin_oc_zone: "admin_oc"
7676

7777
# Internal network
7878
internal_cidr: 192.168.37.0/24

etc/kayobe/inventory/group_vars/all/firewall

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,19 @@ stackhpc_firewalld_rules_default: |
4848
{% if rule.zone is not defined %}
4949
{% set rule = rule | combine({'zone': rule.network | net_zone }) %}
5050
{% endif %}
51+
{% if rule not in stackhpc_firewalld_rules_formatted %}
5152
{% if rule | ansible.utils.remove_keys('state') in stackhpc_firewalld_rules_formatted | map('ansible.utils.remove_keys', 'state') %}
52-
{% set stackhpc_firewalld_rules_formatted = 'Invalid configuration! Two matching firewalld rules probably exist with different states' + 1 %}
53+
{% set _ = stackhpc_firewalld_rules_formatted.append({'state':'failure'}) %}
5354
{% elif rule.network is not defined %}
5455
{% set _ = stackhpc_firewalld_rules_formatted.append(rule) %}
5556
{% elif rule.network in network_interfaces and rule.network | net_zone %}
5657
{% set _ = stackhpc_firewalld_rules_formatted.append(rule) %}
5758
{% endif %}
59+
{% endif %}
5860
{% endfor %}
5961
{% endif %}
6062
{% endfor %}
61-
{{ stackhpc_firewalld_rules_formatted }}
63+
{{ undef(hint='ERROR: Conflicting firewall rules found') if ({'state':'failure'} in stackhpc_firewalld_rules_formatted) else stackhpc_firewalld_rules_formatted }}
6264

6365
stackhpc_firewalld_rules_template: |
6466
{{ stackhpc_common_firewalld_rules_template +
@@ -71,6 +73,23 @@ stackhpc_firewalld_rules_template: |
7173
(stackhpc_wazuh_manager_infra_vm_firewalld_rules_template if 'wazuh-manager' in group_names else []) +
7274
(stackhpc_ansible_control_infra_vm_firewalld_rules_template if inventory_hostname == 'localhost' else []) }}
7375

76+
###############################################################################
77+
# Debug Vars
78+
79+
# This variable is not applied anywhere. It exists for debugging purpouses
80+
# only. Print it with:
81+
# kayobe configuration dump --var-name stackhpc_firewalld_rules_debug
82+
stackhpc_firewalld_rules_debug: |
83+
{% set stackhpc_firewalld_services_debug = [] %}
84+
{% for rule in stackhpc_firewalld_rules %}
85+
{% if rule.service is defined %}
86+
{% set _ = stackhpc_firewalld_services_debug.append(rule.service + ' ' + rule.state + ' ' + rule.zone | default()) %}
87+
{% else %}
88+
{% set _ = stackhpc_firewalld_services_debug.append(rule.port + ' ' + rule.state + ' ' + rule.zone | default()) %}
89+
{% endif %}
90+
{% endfor %}
91+
{{ stackhpc_firewalld_services_debug | list }}
92+
7493
###############################################################################
7594
# Extra firewalld rules
7695

0 commit comments

Comments
 (0)