From patchwork Fri Oct 18 20:54:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13842406 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D485C1F4266 for ; Fri, 18 Oct 2024 20:54:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729284894; cv=none; b=SSLbqXwc0HgMRWdInvvyXp7c7Vui0v2UpPQ4AHeU7Wnh8Z278mWtrE1R+Si5HFzsaaETqXr7dYKfCcG/ZGfVs1BwcQCunozqZYB+3T70KGHbKwzAJaBR/dvQQFg+AOCoEw4h4zl6+qBR2hYc/J4HN9mLCQol4jSkNUG16T1+KbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729284894; c=relaxed/simple; bh=bktsViaCMT27ZiISHjgdP5nfBcWJIbpit5/Wn368Hmw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Aea7hhSRDX5AZ/tcnSP1qPxGc6YsvHyYdZlHMCcCpC8v6cYpljAtYg6JldcBtcsqlQQCQpZq62+bNzqCvUeQWja3+KF3b/DH+l2Cienq9sy85DcIChz0wPgxYhCOrUQZPGxk4Xa1Jb9Hc4kQMMdG9k12DNt6FiMcVVBW/sTHzr0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TPVpFKEZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TPVpFKEZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33696C4CEC3; Fri, 18 Oct 2024 20:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729284894; bh=bktsViaCMT27ZiISHjgdP5nfBcWJIbpit5/Wn368Hmw=; h=From:To:Cc:Subject:Date:From; b=TPVpFKEZRiHbsjtOZEH90Tj1HFJsdEarfNGRwR3BkBKz4WnVYKgapqLy9BnxYKM+b DxX5RKAT5mqvVc0iQgo8wMaVC1b/+sdLb+0o1aqDmYIp/xjSzcGej+0uVMEFB6QwSI 4hwpgCvPyn58SvxclYSNw+We99IDl5CWA/uj7hkF/fWAueien/t6RtzZMssx5Zj5Ln 1gXa3URmMWsL8KJDLsxPO73Kboanohaw/d/IL08DFcO/JWAs0dYnIY2KT5lR1Piq80 4cH/yka40rsMQzVSQ+0OZjo6sf2Qvp0lJnKw00fHAF93qDWqinZKS01IOEfXQ8wEbN oIAdxUNzcmZ9Q== From: cel@kernel.org To: Cc: Chuck Lever Subject: [RFC PATCH] nfsd: Refine the firewall settings on the -nfsd target node Date: Fri, 18 Oct 2024 16:54:46 -0400 Message-ID: <20241018205446.1869501-1-cel@kernel.org> X-Mailer: git-send-email 2.46.1 Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever In preparation for testing NFSD in the cloud, where target nodes might be exposed to the public internet, leave the firewall enabled and permit NFS traffic. The documentation for the ansible.posix.firewalld module states "Not tested on any Debian based system." For now, Debian-based target nodes still simply disable firewalld. Signed-off-by: Chuck Lever --- .../roles/nfsd/tasks/firewall/debian/main.yml | 11 ++++ .../roles/nfsd/tasks/firewall/redhat/main.yml | 65 +++++++++++++++++++ .../roles/nfsd/tasks/firewall/suse/main.yml | 65 +++++++++++++++++++ playbooks/roles/nfsd/tasks/main.yml | 20 +++--- playbooks/roles/nfsd/templates/nfs.conf.j2 | 3 + playbooks/roles/nfsd/vars/RedHat.yml | 2 + 6 files changed, 156 insertions(+), 10 deletions(-) create mode 100644 playbooks/roles/nfsd/tasks/firewall/debian/main.yml create mode 100644 playbooks/roles/nfsd/tasks/firewall/redhat/main.yml create mode 100644 playbooks/roles/nfsd/tasks/firewall/suse/main.yml I have tested this change with Fedora on libvirt, and RHEL 9.4 on AWS. I haven't tested these changes with SuSE-based target nodes. It looks like the menu option to select SuSE on the target nodes has disappeared. diff --git a/playbooks/roles/nfsd/tasks/firewall/debian/main.yml b/playbooks/roles/nfsd/tasks/firewall/debian/main.yml new file mode 100644 index 000000000000..0ba5272812a6 --- /dev/null +++ b/playbooks/roles/nfsd/tasks/firewall/debian/main.yml @@ -0,0 +1,11 @@ +--- +- name: Populate service facts + ansible.builtin.service_facts: + +- name: Turn off firewalld + become: true + ansible.builtin.systemd_service: + name: firewalld.service + enabled: false + state: stopped + when: '"firewalld.service" in ansible_facts.services' diff --git a/playbooks/roles/nfsd/tasks/firewall/redhat/main.yml b/playbooks/roles/nfsd/tasks/firewall/redhat/main.yml new file mode 100644 index 000000000000..39fab7773d09 --- /dev/null +++ b/playbooks/roles/nfsd/tasks/firewall/redhat/main.yml @@ -0,0 +1,65 @@ +--- +- name: Populate service facts + ansible.builtin.service_facts: + +- name: Turn on firewalld + become: true + ansible.builtin.systemd_service: + name: firewalld.service + enabled: true + state: started + when: '"firewalld.service" in ansible_facts.services' + +- name: Open the rpcbind service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + service: rpc-bind + permanent: true + immediate: true + state: enabled + +- name: Open the NFS service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + service: nfs + permanent: true + immediate: true + state: enabled + +- name: Open the NLM TCP service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + port: 4045/tcp + permanent: true + immediate: true + state: enabled + +- name: Open the NLM UDP service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + port: 4045/udp + permanent: true + immediate: true + state: enabled + +- name: Open the MNT TCP service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + port: 20048/tcp + permanent: true + immediate: true + state: enabled + +- name: Open the MNT UDP service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + port: 20048/udp + permanent: true + immediate: true + state: enabled diff --git a/playbooks/roles/nfsd/tasks/firewall/suse/main.yml b/playbooks/roles/nfsd/tasks/firewall/suse/main.yml new file mode 100644 index 000000000000..39fab7773d09 --- /dev/null +++ b/playbooks/roles/nfsd/tasks/firewall/suse/main.yml @@ -0,0 +1,65 @@ +--- +- name: Populate service facts + ansible.builtin.service_facts: + +- name: Turn on firewalld + become: true + ansible.builtin.systemd_service: + name: firewalld.service + enabled: true + state: started + when: '"firewalld.service" in ansible_facts.services' + +- name: Open the rpcbind service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + service: rpc-bind + permanent: true + immediate: true + state: enabled + +- name: Open the NFS service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + service: nfs + permanent: true + immediate: true + state: enabled + +- name: Open the NLM TCP service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + port: 4045/tcp + permanent: true + immediate: true + state: enabled + +- name: Open the NLM UDP service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + port: 4045/udp + permanent: true + immediate: true + state: enabled + +- name: Open the MNT TCP service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + port: 20048/tcp + permanent: true + immediate: true + state: enabled + +- name: Open the MNT UDP service port in firewalld + become: true + become_method: ansible.builtin.sudo + ansible.posix.firewalld: + port: 20048/udp + permanent: true + immediate: true + state: enabled diff --git a/playbooks/roles/nfsd/tasks/main.yml b/playbooks/roles/nfsd/tasks/main.yml index 63388f857627..5f944708b2ec 100644 --- a/playbooks/roles/nfsd/tasks/main.yml +++ b/playbooks/roles/nfsd/tasks/main.yml @@ -106,17 +106,17 @@ state: present when: selinux_status.rc == 0 -# FIXME: open ports instead -- name: Populate service facts - service_facts: +- name: Open ports in NFS server's firewall (Debian) + ansible.builtin.include_tasks: roles/nfsd/tasks/firewall/debian/main.yml + when: ansible_os_family == 'Debian' -- name: Turn off firewalld - become: yes - ansible.builtin.systemd_service: - name: firewalld.service - enabled: false - state: stopped - when: '"firewalld.service" in ansible_facts.services' +- name: Open ports in NFS server's firewall (Suse) + ansible.builtin.include_tasks: roles/nfsd/tasks/firewall/suse/main.yml + when: ansible_os_family == 'Suse' + +- name: Open ports in NFS server's firewall (Red Hat) + ansible.builtin.include_tasks: roles/nfsd/tasks/firewall/redhat/main.yml + when: ansible_os_family == 'RedHat' - name: Start up nfsd become: yes diff --git a/playbooks/roles/nfsd/templates/nfs.conf.j2 b/playbooks/roles/nfsd/templates/nfs.conf.j2 index a5f4a714ec34..e319f9246904 100644 --- a/playbooks/roles/nfsd/templates/nfs.conf.j2 +++ b/playbooks/roles/nfsd/templates/nfs.conf.j2 @@ -1,6 +1,9 @@ [general] pipefs-directory={{ pipefs_directory }} +[lockd] +port=4045 + [nfsd] udp=y rdma=y diff --git a/playbooks/roles/nfsd/vars/RedHat.yml b/playbooks/roles/nfsd/vars/RedHat.yml index 091c827c777d..ccffdcc4fdd9 100644 --- a/playbooks/roles/nfsd/vars/RedHat.yml +++ b/playbooks/roles/nfsd/vars/RedHat.yml @@ -1,9 +1,11 @@ --- nfsd_packages: - checkpolicy + - firewalld - lvm2 - nfs-utils - policycoreutils + - python3-firewall - python3-policycoreutils fstype_userspace_progs: