]> xn--ix-yja.es Git - alex.git/commitdiff
Add finer firewall control
authoralex <alex@pdp7.net>
Sat, 16 Sep 2023 11:36:12 +0000 (13:36 +0200)
committeralex <alex@pdp7.net>
Sat, 16 Sep 2023 11:36:44 +0000 (13:36 +0200)
personal_infra/playbooks/roles/deploy_ragent/tasks/main.yml
personal_infra/puppet/modules/tinc/manifests/init.pp
personal_infra/puppet/site/01-tinc.pp

index 4df4cc0378e633fadebd571a9ae2025a7a9c5095..38cacab5fa624e1fb8bc7a39ade639b46a32bdcc 100644 (file)
     state: restarted
 - name: open firewall
   command: firewall-cmd --permanent --add-port=21488/tcp
-  when: ansible_os_family == "RedHat" and ansible_distribution_major_version in ("7", "8", "9") and ansible_virtualization_type != "lxc"
+  when: ansible_os_family == "RedHat" and ansible_distribution_major_version in ("7", "8", "9") and ansible_virtualization_type != "lxc" and not network.disable_firewall
 - name: reload firewall
   command: firewall-cmd --reload
-  when: ansible_os_family == "RedHat" and ansible_distribution_major_version in ("7", "8", "9") and ansible_virtualization_type != "lxc"
+  when: ansible_os_family == "RedHat" and ansible_distribution_major_version in ("7", "8", "9") and ansible_virtualization_type != "lxc" and not network.disable_firewall
 - name: force check
   community.general.nagios:
     action: forced_check
index be37330214d308f01db18b6f7c7edb9ed19dfc3d..581593a6c9042d0845efd2cee2e9c22206f1988c 100644 (file)
@@ -1,4 +1,4 @@
-class tinc($tinc_name, $tinc_location, $tinc_connect_to, $tinc_locations, $tinc_ip, $tinc_netmask, $tinc_other_networks) {
+class tinc($tinc_name, $tinc_location, $tinc_connect_to, $tinc_locations, $tinc_ip, $tinc_netmask, $tinc_other_networks, $firewall = true) {
   # https://bugzilla.redhat.com/show_bug.cgi?id=2153663
   if($facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '9') {
     copr {'tinc':
@@ -71,7 +71,7 @@ cat /etc/ansible/tinc/public_${location['address']}.pem >>/etc/tinc/${tinc_name}
     notify => Service["tinc@${tinc_name}"],
   }
 
-  if ($facts['os']['family'] == 'RedHat') {
+  if ($facts['os']['family'] == 'RedHat' and $firewall) {
     exec {'open firewall for tinc':
       command => '/usr/bin/firewall-cmd --permanent --add-port=655/{tcp,udp}',
       unless => '/usr/bin/firewall-cmd --query-port=655/udp',
index 148e5988f85be7f1b56826412de9bddd9707bed2..7228a870c7d1a4c751cb19eee0631beb54acca5c 100644 (file)
@@ -22,5 +22,6 @@ if 'tinc' in lookup("group_names") {
     tinc_ip             => lookup("network.self_internal_ip"),
     tinc_netmask        => lookup("network.self_internal_netmask"),
     tinc_other_networks => $tinc_other_networks,
+    firewall            => !lookup("network.disable_firewall"),
   }
 }