ktls: allow setting up hosts with tlshd
PATCH 1/1 ktls: allow setting up hosts with tlshd
Add a new option to the post-install "goals" phase to configure tlshd for TLS handshake upcalls. This adds a new playbook to build a CA, generate certs for the hosts, and then configure tlshd to use them.
Finally, it also adds a new NFS fstests option to test RPC over TLS (using xprtsec=mtls).
--- Makefile | 4 + kconfigs/Kconfig.bringup.goals | 9 ++ playbooks/ktls.yml | 4 + playbooks/roles/fstests/templates/nfs/nfs.config | 7 ++ .../roles/ktls/tasks/install-deps/debian/main.yml | 10 ++ playbooks/roles/ktls/tasks/install-deps/main.yml | 9 ++ .../roles/ktls/tasks/install-deps/redhat/main.yml | 15 +++ .../roles/ktls/tasks/install-deps/suse/main.yml | 9 ++ playbooks/roles/ktls/tasks/main.yml | 110 +++++++++++++++++++++ playbooks/roles/ktls/templates/tlshd.conf | 39 ++++++++ scripts/bringup.Makefile | 5 + scripts/ktls.Makefile | 8 ++ workflows/fstests/nfs/Kconfig | 9 +- workflows/fstests/nfs/Makefile | 3 + 14 files changed, 240 insertions(+), 1 deletion(-)
Makefile +4 -0
@@ -114,6 +114,10 @@ ifeq (y,$(CONFIG_WORKFLOWS)) include workflows/Makefile endif # CONFIG_WORKFLOWS +ifeq (y,$(CONFIG_KDEVOPS_SETUP_KTLS)) +include scripts/ktls.Makefile +endif # CONFIG_KDEVOPS_SETUP_KTLS + ifeq (y,$(CONFIG_KDEVOPS_SETUP_NFSD)) include scripts/nfsd.Makefile endif # CONFIG_KDEVOPS_SETUP_NFSD
kconfigs/Kconfig.bringup.goals +9 -0
@@ -56,6 +56,15 @@ config KDEVOPS_TRY_INSTALL_KDEV_TOOLS most kernel developers might prefer to have installed on target systems. +config KDEVOPS_SETUP_KTLS + bool "Configure ktls on the hosts with self-signed CA" + default n + help + Enabling this will have kdevops create a self-signed certificate + authority, and configure tlshd on the hosts to use it. This is + necessary for testing RPC over TLS, or some NVMe over fabrics + configurations. + config KDEVOPS_SETUP_NFSD bool "Set up the kernel nfs server" default n
playbooks/ktls.yml new file +4 -0
@@ -0,0 +1,4 @@ +--- +- hosts: all + roles: + - role: ktls
playbooks/roles/fstests/templates/nfs/nfs.config +7 -0
@@ -15,6 +15,13 @@ CANON_DEVS=yes # Test with default mount options [nfs_default] {% endif %} +{% if fstests_nfs_section_tls -%} + +# Test NFS with RPC over TLS +[nfs_tls] +TEST_FS_MOUNT_OPTS="-o xprtsec=mtls" +MOUNT_OPTIONS="-o xprtsec=mtls" +{% endif %} {% if fstests_nfs_section_v40 -%} # Test NFSv4.0
playbooks/roles/ktls/tasks/install-deps/debian/main.yml new file +10 -0
@@ -0,0 +1,10 @@ +--- +- name: Install ktls dependencies + become: yes + become_method: sudo + apt: + name: + - python3-cryptography + - ktls-utils + state: present + update_cache: yes
playbooks/roles/ktls/tasks/install-deps/main.yml new file +9 -0
@@ -0,0 +1,9 @@ +--- +# tasks to install dependencies for pynfs +- name: oscheck distribution ospecific setup + import_tasks: tasks/install-deps/debian/main.yml + when: ansible_facts['os_family']|lower == 'debian' +- import_tasks: tasks/install-deps/suse/main.yml + when: ansible_facts['os_family']|lower == 'suse' +- import_tasks: tasks/install-deps/redhat/main.yml + when: ansible_facts['os_family']|lower == 'redhat'
playbooks/roles/ktls/tasks/install-deps/redhat/main.yml new file +15 -0
@@ -0,0 +1,15 @@ +--- +- name: Install ktls dependencies + become: yes + become_method: sudo + dnf: + update_cache: yes + name: "{{ packages }}" + retries: 3 + delay: 5 + register: result + until: result.rc == 0 + vars: + packages: + - python3-cryptography + - ktls-utils
playbooks/roles/ktls/tasks/install-deps/suse/main.yml new file +9 -0
@@ -0,0 +1,9 @@ +--- +- name: Install ktls dependencies + become: yes + become_method: sudo + zypper: + state: present + name: + - python3-cryptography + - ktls-utils
playbooks/roles/ktls/tasks/main.yml new file +110 -0
110 lines not on this page · raw message
playbooks/roles/ktls/templates/tlshd.conf new file +39 -0
@@ -0,0 +1,39 @@ +# +# Copyright (c) 2022 Oracle and/or its affiliates. +# +# This file is part of ktls-utils. +# +# ktls-utils is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# See tlshd.conf(5) for details. +# + +[debug] +loglevel=0 +tls=0 +nl=0 + +[authenticate] +#keyrings= <keyring>;<keyring>;<keyring> + +[authenticate.client] +x509.truststore=/etc/pki/tls/certs/ca-cert.pem +x509.certificate=/etc/pki/tls/certs/ktls.pem +x509.private_key=/etc/pki/tls/private/ktls.key + +[authenticate.server] +x509.truststore=/etc/pki/tls/certs/ca-cert.pem +x509.certificate=/etc/pki/tls/certs/ktls.pem +x509.private_key=/etc/pki/tls/private/ktls.key
scripts/bringup.Makefile +5 -0
@@ -21,6 +21,11 @@ ifeq (y,$(CONFIG_KDEVOPS_SETUP_NFSD)) KDEVOPS_BRING_UP_DEPS += nfsd endif # KDEVOPS_SETUP_NFSD +ifeq (y,$(CONFIG_KDEVOPS_SETUP_KTLS)) +KDEVOPS_BRING_UP_DEPS += ktls +KDEVOPS_DESTROY_DEPS += ktls-destroy +endif # KDEVOPS_SETUP_KTLS + update_etc_hosts: $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \ -f 30 -i hosts playbooks/update_etc_hosts.yml
scripts/ktls.Makefile new file +8 -0
@@ -0,0 +1,8 @@ +ktls: + $(Q)ansible-playbook $(ANSIBLE_VERBOSE) --extra-vars=@./extra_vars.yaml \ + -f 30 -i hosts playbooks/ktls.yml + +ktls-destroy: + $(Q)rm -rf $(TOPDIR)/ca + +PHONY += ktls ktls-destroy
workflows/fstests/nfs/Kconfig +8 -1
@@ -54,11 +54,18 @@ config FSTESTS_NFS_SECTION_DEFAULT time of this writing, this makes the client autonegotiate an NFS version, starting with v4.2 if it's available. +config FSTESTS_NFS_SECTION_TLS + bool "Enable testing section: nfs_tls" + default n + depends on KDEVOPS_SETUP_KTLS + help + Enabling this will test with the xprtsec=tls mount option. + config FSTESTS_NFS_SECTION_V40 bool "Enable testing section: nfs_v40" default n help - Enabling this will test NFSv4.0 + Enabling this will test NFSv4.0. config FSTESTS_NFS_SECTION_V3 bool "Enable testing section: nfs_v3"
workflows/fstests/nfs/Makefile +3 -0
@@ -9,6 +9,9 @@ FSTESTS_ARGS += fstests_nfs_server_host='$(FSTESTS_NFS_SERVER_HOST)' ifeq (y,$(CONFIG_FSTESTS_NFS_SECTION_DEFAULT)) FSTESTS_ARGS += fstests_nfs_section_default=True endif +ifeq (y,$(CONFIG_FSTESTS_NFS_SECTION_TLS)) +FSTESTS_ARGS += fstests_nfs_section_tls=True +endif ifeq (y,$(CONFIG_FSTESTS_NFS_SECTION_V40)) FSTESTS_ARGS += fstests_nfs_section_v40=True endif
---
base-commit: 2f7d9b13a7ac734e2fb40ed68e45150af9d727ef
change-id: 20231212-ktls-5534fde5777c
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 110 lines · Jeff Layton
Add a new option to the post-install "goals" phase to configure tlshd for TLS handshake upcalls. This adds a new playbook to build a CA, generate certs for the hosts, and then configure tlshd to use them.
Finally, it also adds a new NFS fstests option to test RPC over TLS (using xprtsec=mtls).
Signed-off-by Jeff Layton <[email protected]>--- Makefile | 4 + kconfigs/Kconfig.bringup.goals | 9 ++ playbooks/ktls.yml | 4 + playbooks/roles/fstests/templates/nfs/nfs.config | 7 ++ .../roles/ktls/tasks/install-deps/debian/main.yml | 10 ++ playbooks/roles/ktls/tasks/install-deps/main.yml | 9 ++ .../roles/ktls/tasks/install-deps/redhat/main.yml | 15 +++ .../roles/ktls/tasks/install-deps/suse/main.yml | 9 ++ playbooks/roles/ktls/tasks/main.yml | 110 +++++++++++++++++++++ playbooks/roles/ktls/templates/tlshd.conf | 39 ++++++++ scripts/bringup.Makefile | 5 + scripts/ktls.Makefile | 8 ++ workflows/fstests/nfs/Kconfig | 9 +- workflows/fstests/nfs/Makefile | 3 + 14 files changed, 240 insertions(+), 1 deletion(-)Makefile +4
-0@@ -114,6 +114,10 @@ ifeq (y,$(CONFIG_WORKFLOWS)) include workflows/Makefile endif # CONFIG_WORKFLOWS +ifeq (y,$(CONFIG_KDEVOPS_SETUP_KTLS)) +include scripts/ktls.Makefile +endif # CONFIG_KDEVOPS_SETUP_KTLS + ifeq (y,$(CONFIG_KDEVOPS_SETUP_NFSD)) include scripts/nfsd.Makefile endif # CONFIG_KDEVOPS_SETUP_NFSDkconfigs/Kconfig.bringup.goals +9
-0@@ -56,6 +56,15 @@ config KDEVOPS_TRY_INSTALL_KDEV_TOOLS most kernel developers might prefer to have installed on target systems. +config KDEVOPS_SETUP_KTLS + bool "Configure ktls on the hosts with self-signed CA" + default n + help + Enabling this will have kdevops create a self-signed certificate + authority, and configure tlshd on the hosts to use it. This is + necessary for testing RPC over TLS, or some NVMe over fabrics + configurations. + config KDEVOPS_SETUP_NFSD bool "Set up the kernel nfs server" default nplaybooks/ktls.yml new file +4
-0@@ -0,0 +1,4 @@ +--- +- hosts: all + roles: + - role: ktlsplaybooks/roles/fstests/templates/nfs/nfs.config +7
-0@@ -15,6 +15,13 @@ CANON_DEVS=yes # Test with default mount options [nfs_default] {% endif %} +{% if fstests_nfs_section_tls -%} + +# Test NFS with RPC over TLS +[nfs_tls] +TEST_FS_MOUNT_OPTS="-o xprtsec=mtls" +MOUNT_OPTIONS="-o xprtsec=mtls" +{% endif %} {% if fstests_nfs_section_v40 -%} # Test NFSv4.0playbooks/roles/ktls/tasks/install-deps/debian/main.yml new file +10
-0@@ -0,0 +1,10 @@ +--- +- name: Install ktls dependencies + become: yes + become_method: sudo + apt: + name: + - python3-cryptography + - ktls-utils + state: present + update_cache: yesplaybooks/roles/ktls/tasks/install-deps/main.yml new file +0
-0
playbooks/roles/ktls/tasks/install-deps/main.yml line 4
Quoted 4 lines
playbooks/roles/ktls/tasks/install-deps/main.yml new file +4
-0@@ -0,0 +1,9 @@ +--- +# tasks to install dependencies for pynfs +- name: oscheck distribution ospecific setup + import_tasks: tasks/install-deps/debian/main.yml
Since this is a new set of install-deps, how about usinginclude_tasks: instead?
Quoted 279 lines
playbooks/roles/ktls/tasks/install-deps/main.yml new file +5
-0+ when: ansible_facts['os_family']|lower == 'debian' +- import_tasks: tasks/install-deps/suse/main.yml + when: ansible_facts['os_family']|lower == 'suse' +- import_tasks: tasks/install-deps/redhat/main.yml + when: ansible_facts['os_family']|lower == 'redhat'playbooks/roles/ktls/tasks/install-deps/redhat/main.yml new file +15
-0@@ -0,0 +1,15 @@ +--- +- name: Install ktls dependencies + become: yes + become_method: sudo + dnf: + update_cache: yes + name: "{{ packages }}" + retries: 3 + delay: 5 + register: result + until: result.rc == 0 + vars: + packages: + - python3-cryptography + - ktls-utilsplaybooks/roles/ktls/tasks/install-deps/suse/main.yml new file +9
-0@@ -0,0 +1,9 @@ +--- +- name: Install ktls dependencies + become: yes + become_method: sudo + zypper: + state: present + name: + - python3-cryptography + - ktls-utilsplaybooks/roles/ktls/tasks/main.yml new file +110
-0@@ -0,0 +1,110 @@ +- name: Import optional extra_args file + include_vars: "{{ item }}" + ignore_errors: yes + with_first_found: + - files: + - "../extra_vars.yml" + - "../extra_vars.yaml" + - "../extra_vars.json" + skip: true + +- name: Install dependencies + import_tasks: install-deps/main.yml + +- name: Construct the path to the CA directory + delegate_to: localhost + set_fact: + ca_dir: "{{ topdir_path }}/ca/{{ kdevops_host_prefix }}" + +- name: Create directory to hold the CA on local host + delegate_to: localhost + run_once: true + ansible.builtin.file: + path: "{{ ca_dir }}" + state: directory + +- name: Create private key for CA + delegate_to: localhost + run_once: true + community.crypto.openssl_privatekey: + path: "{{ ca_dir }}/ca-cert.key" + +- name: Create certificate signing request (CSR) for CA certificate + delegate_to: localhost + run_once: true + community.crypto.openssl_csr_pipe: + privatekey_path: "{{ ca_dir }}/ca-cert.key" + common_name: "kdevops {{ kdevops_host_prefix }} CA" + use_common_name_for_san: false # since we do not specify SANs, don't use CN as a SAN + basic_constraints: + - 'CA:TRUE' + basic_constraints_critical: true + key_usage: + - keyCertSign + key_usage_critical: true + register: ca_csr + +- name: Create self-signed CA certificate from CSR + delegate_to: localhost + run_once: true + community.crypto.x509_certificate: + path: "{{ ca_dir }}/ca-cert.pem" + csr_content: "{{ ca_csr.csr }}" + privatekey_path: "{{ ca_dir }}/ca-cert.key" + provider: selfsigned + +- name: Create private key for new TLS certificate + community.crypto.openssl_privatekey: + path: "/etc/pki/tls/private/ktls.key" + become: yes + +- name: Copy CA cert to all of the hosts + ansible.builtin.copy: + src: "{{ ca_dir }}/ca-cert.pem" + dest: "/etc/pki/tls/certs/ca-cert.pem" + owner: root + group: root + mode: 0644 + become: yes + +- name: Create certificate signing request (CSR) for new certificate + community.crypto.openssl_csr_pipe: + privatekey_path: "/etc/pki/tls/private/ktls.key" + subject_alt_name: + - "DNS:{{ ansible_host }}" + - "IP:{{ ansible_default_ipv4.address }}" + register: csr + become: yes + +- name: Sign certificate with our CA + community.crypto.x509_certificate_pipe: + csr_content: "{{ csr.csr }}" + provider: ownca + ownca_path: "{{ ca_dir }}/ca-cert.pem" + ownca_privatekey_path: "{{ ca_dir }}/ca-cert.key" + ownca_not_after: +365d # valid for one year + ownca_not_before: "-1d" # valid since yesterday + delegate_to: localhost + register: certificate + +- name: Write certificate file on host + copy: + dest: "/etc/pki/tls/certs/ktls.pem" + content: "{{ certificate.certificate }}" + become: yes + +- name: Install new /etc/tlshd.conf + ansible.builtin.copy: + src: "{{ playbook_dir }}/roles/ktls/templates/tlshd.conf" + dest: "/etc/tlshd.conf" + owner: root + group: root + mode: 0644 + become: yes + +- name: Enable and start tlshd + become: yes + ansible.builtin.systemd_service: + name: tlshd.service + enabled: true + state: reloadedplaybooks/roles/ktls/templates/tlshd.conf new file +39
-0@@ -0,0 +1,39 @@ +# +# Copyright (c) 2022 Oracle and/or its affiliates. +# +# This file is part of ktls-utils. +# +# ktls-utils is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# See tlshd.conf(5) for details. +# + +[debug] +loglevel=0 +tls=0 +nl=0 + +[authenticate] +#keyrings= <keyring>;<keyring>;<keyring> + +[authenticate.client] +x509.truststore=/etc/pki/tls/certs/ca-cert.pem +x509.certificate=/etc/pki/tls/certs/ktls.pem +x509.private_key=/etc/pki/tls/private/ktls.key + +[authenticate.server] +x509.truststore=/etc/pki/tls/certs/ca-cert.pem +x509.certificate=/etc/pki/tls/certs/ktls.pem +x509.private_key=/etc/pki/tls/private/ktls.keyscripts/bringup.Makefile +5
-0@@ -21,6 +21,11 @@ ifeq (y,$(CONFIG_KDEVOPS_SETUP_NFSD)) KDEVOPS_BRING_UP_DEPS += nfsd endif # KDEVOPS_SETUP_NFSD +ifeq (y,$(CONFIG_KDEVOPS_SETUP_KTLS)) +KDEVOPS_BRING_UP_DEPS += ktls +KDEVOPS_DESTROY_DEPS += ktls-destroy +endif # KDEVOPS_SETUP_KTLS + update_etc_hosts: $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \ -f 30 -i hosts playbooks/update_etc_hosts.ymlscripts/ktls.Makefile new file +8
-0@@ -0,0 +1,8 @@ +ktls: + $(Q)ansible-playbook $(ANSIBLE_VERBOSE) --extra-vars=@./extra_vars.yaml \ + -f 30 -i hosts playbooks/ktls.yml + +ktls-destroy: + $(Q)rm -rf $(TOPDIR)/ca + +PHONY += ktls ktls-destroyworkflows/fstests/nfs/Kconfig +8
-1@@ -54,11 +54,18 @@ config FSTESTS_NFS_SECTION_DEFAULT time of this writing, this makes the client autonegotiate an NFS version, starting with v4.2 if it's available. +config FSTESTS_NFS_SECTION_TLS + bool "Enable testing section: nfs_tls" + default n + depends on KDEVOPS_SETUP_KTLS + help + Enabling this will test with the xprtsec=tls mount option. + config FSTESTS_NFS_SECTION_V40 bool "Enable testing section: nfs_v40" default n help - Enabling this will test NFSv4.0 + Enabling this will test NFSv4.0. config FSTESTS_NFS_SECTION_V3 bool "Enable testing section: nfs_v3"workflows/fstests/nfs/Makefile +3
-1@@ -9,6 +9,9 @@ FSTESTS_ARGS += fstests_nfs_server_host='$(FSTESTS_NFS_SERVER_HOST)' ifeq (y,$(CONFIG_FSTESTS_NFS_SECTION_DEFAULT)) FSTESTS_ARGS += fstests_nfs_section_default=True endif +ifeq (y,$(CONFIG_FSTESTS_NFS_SECTION_TLS)) +FSTESTS_ARGS += fstests_nfs_section_tls=True +endif ifeq (y,$(CONFIG_FSTESTS_NFS_SECTION_V40)) FSTESTS_ARGS += fstests_nfs_section_v40=True endif ---base-commit:
2f7d9b13a7ac734e2fb40ed68e45150af9d727ef
change-id: 20231212-ktls-5534fde5777cBest regards,
Signature · 1 line
Jeff Layton <[email protected]>
Signature · 1 line
Chuck Lever
Quoted 110 lines · Chuck Lever
Quoted 109 lines · Jeff Layton
Add a new option to the post-install "goals" phase to configure tlshd for TLS handshake upcalls. This adds a new playbook to build a CA, generate certs for the hosts, and then configure tlshd to use them.
Finally, it also adds a new NFS fstests option to test RPC over TLS (using xprtsec=mtls).
Signed-off-by Jeff Layton <[email protected]>--- Makefile | 4 + kconfigs/Kconfig.bringup.goals | 9 ++ playbooks/ktls.yml | 4 + playbooks/roles/fstests/templates/nfs/nfs.config | 7 ++ .../roles/ktls/tasks/install-deps/debian/main.yml | 10 ++ playbooks/roles/ktls/tasks/install-deps/main.yml | 9 ++ .../roles/ktls/tasks/install-deps/redhat/main.yml | 15 +++ .../roles/ktls/tasks/install-deps/suse/main.yml | 9 ++ playbooks/roles/ktls/tasks/main.yml | 110 +++++++++++++++++++++ playbooks/roles/ktls/templates/tlshd.conf | 39 ++++++++ scripts/bringup.Makefile | 5 + scripts/ktls.Makefile | 8 ++ workflows/fstests/nfs/Kconfig | 9 +- workflows/fstests/nfs/Makefile | 3 + 14 files changed, 240 insertions(+), 1 deletion(-)Makefile +4
-0@@ -114,6 +114,10 @@ ifeq (y,$(CONFIG_WORKFLOWS)) include workflows/Makefile endif # CONFIG_WORKFLOWS +ifeq (y,$(CONFIG_KDEVOPS_SETUP_KTLS)) +include scripts/ktls.Makefile +endif # CONFIG_KDEVOPS_SETUP_KTLS + ifeq (y,$(CONFIG_KDEVOPS_SETUP_NFSD)) include scripts/nfsd.Makefile endif # CONFIG_KDEVOPS_SETUP_NFSDkconfigs/Kconfig.bringup.goals +9
-0@@ -56,6 +56,15 @@ config KDEVOPS_TRY_INSTALL_KDEV_TOOLS most kernel developers might prefer to have installed on target systems. +config KDEVOPS_SETUP_KTLS + bool "Configure ktls on the hosts with self-signed CA" + default n + help + Enabling this will have kdevops create a self-signed certificate + authority, and configure tlshd on the hosts to use it. This is + necessary for testing RPC over TLS, or some NVMe over fabrics + configurations. + config KDEVOPS_SETUP_NFSD bool "Set up the kernel nfs server" default nplaybooks/ktls.yml new file +4
-0@@ -0,0 +1,4 @@ +--- +- hosts: all + roles: + - role: ktlsplaybooks/roles/fstests/templates/nfs/nfs.config +7
-0@@ -15,6 +15,13 @@ CANON_DEVS=yes # Test with default mount options [nfs_default] {% endif %} +{% if fstests_nfs_section_tls -%} + +# Test NFS with RPC over TLS +[nfs_tls] +TEST_FS_MOUNT_OPTS="-o xprtsec=mtls" +MOUNT_OPTIONS="-o xprtsec=mtls" +{% endif %} {% if fstests_nfs_section_v40 -%} # Test NFSv4.0playbooks/roles/ktls/tasks/install-deps/debian/main.yml new file +10
-0@@ -0,0 +1,10 @@ +--- +- name: Install ktls dependencies + become: yes + become_method: sudo + apt: + name: + - python3-cryptography + - ktls-utils + state: present + update_cache: yesplaybooks/roles/ktls/tasks/install-deps/main.yml new file +0
-0
Quoted 10 lines
playbooks/roles/ktls/tasks/install-deps/main.yml line 4
Quoted 5 lines
playbooks/roles/ktls/tasks/install-deps/main.yml new file +4
-0@@ -0,0 +1,9 @@ +--- +# tasks to install dependencies for pynfs +- name: oscheck distribution ospecific setup + import_tasks: tasks/install-deps/debian/main.ymlSince this is a new set of install-deps, how about using
include_tasks: instead?
Thanks! That seems to work just as well. I've incorporated that change in tree for now.
Quoted 280 lines
Quoted 279 lines
playbooks/roles/ktls/tasks/install-deps/main.yml new file +5
-0+ when: ansible_facts['os_family']|lower == 'debian' +- import_tasks: tasks/install-deps/suse/main.yml + when: ansible_facts['os_family']|lower == 'suse' +- import_tasks: tasks/install-deps/redhat/main.yml + when: ansible_facts['os_family']|lower == 'redhat'playbooks/roles/ktls/tasks/install-deps/redhat/main.yml new file +15
-0@@ -0,0 +1,15 @@ +--- +- name: Install ktls dependencies + become: yes + become_method: sudo + dnf: + update_cache: yes + name: "{{ packages }}" + retries: 3 + delay: 5 + register: result + until: result.rc == 0 + vars: + packages: + - python3-cryptography + - ktls-utilsplaybooks/roles/ktls/tasks/install-deps/suse/main.yml new file +9
-0@@ -0,0 +1,9 @@ +--- +- name: Install ktls dependencies + become: yes + become_method: sudo + zypper: + state: present + name: + - python3-cryptography + - ktls-utilsplaybooks/roles/ktls/tasks/main.yml new file +110
-0@@ -0,0 +1,110 @@ +- name: Import optional extra_args file + include_vars: "{{ item }}" + ignore_errors: yes + with_first_found: + - files: + - "../extra_vars.yml" + - "../extra_vars.yaml" + - "../extra_vars.json" + skip: true + +- name: Install dependencies + import_tasks: install-deps/main.yml + +- name: Construct the path to the CA directory + delegate_to: localhost + set_fact: + ca_dir: "{{ topdir_path }}/ca/{{ kdevops_host_prefix }}" + +- name: Create directory to hold the CA on local host + delegate_to: localhost + run_once: true + ansible.builtin.file: + path: "{{ ca_dir }}" + state: directory + +- name: Create private key for CA + delegate_to: localhost + run_once: true + community.crypto.openssl_privatekey: + path: "{{ ca_dir }}/ca-cert.key" + +- name: Create certificate signing request (CSR) for CA certificate + delegate_to: localhost + run_once: true + community.crypto.openssl_csr_pipe: + privatekey_path: "{{ ca_dir }}/ca-cert.key" + common_name: "kdevops {{ kdevops_host_prefix }} CA" + use_common_name_for_san: false # since we do not specify SANs, don't use CN as a SAN + basic_constraints: + - 'CA:TRUE' + basic_constraints_critical: true + key_usage: + - keyCertSign + key_usage_critical: true + register: ca_csr + +- name: Create self-signed CA certificate from CSR + delegate_to: localhost + run_once: true + community.crypto.x509_certificate: + path: "{{ ca_dir }}/ca-cert.pem" + csr_content: "{{ ca_csr.csr }}" + privatekey_path: "{{ ca_dir }}/ca-cert.key" + provider: selfsigned + +- name: Create private key for new TLS certificate + community.crypto.openssl_privatekey: + path: "/etc/pki/tls/private/ktls.key" + become: yes + +- name: Copy CA cert to all of the hosts + ansible.builtin.copy: + src: "{{ ca_dir }}/ca-cert.pem" + dest: "/etc/pki/tls/certs/ca-cert.pem" + owner: root + group: root + mode: 0644 + become: yes + +- name: Create certificate signing request (CSR) for new certificate + community.crypto.openssl_csr_pipe: + privatekey_path: "/etc/pki/tls/private/ktls.key" + subject_alt_name: + - "DNS:{{ ansible_host }}" + - "IP:{{ ansible_default_ipv4.address }}" + register: csr + become: yes + +- name: Sign certificate with our CA + community.crypto.x509_certificate_pipe: + csr_content: "{{ csr.csr }}" + provider: ownca + ownca_path: "{{ ca_dir }}/ca-cert.pem" + ownca_privatekey_path: "{{ ca_dir }}/ca-cert.key" + ownca_not_after: +365d # valid for one year + ownca_not_before: "-1d" # valid since yesterday + delegate_to: localhost + register: certificate + +- name: Write certificate file on host + copy: + dest: "/etc/pki/tls/certs/ktls.pem" + content: "{{ certificate.certificate }}" + become: yes + +- name: Install new /etc/tlshd.conf + ansible.builtin.copy: + src: "{{ playbook_dir }}/roles/ktls/templates/tlshd.conf" + dest: "/etc/tlshd.conf" + owner: root + group: root + mode: 0644 + become: yes + +- name: Enable and start tlshd + become: yes + ansible.builtin.systemd_service: + name: tlshd.service + enabled: true + state: reloadedplaybooks/roles/ktls/templates/tlshd.conf new file +39
-0@@ -0,0 +1,39 @@ +# +# Copyright (c) 2022 Oracle and/or its affiliates. +# +# This file is part of ktls-utils. +# +# ktls-utils is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# See tlshd.conf(5) for details. +# + +[debug] +loglevel=0 +tls=0 +nl=0 + +[authenticate] +#keyrings= <keyring>;<keyring>;<keyring> + +[authenticate.client] +x509.truststore=/etc/pki/tls/certs/ca-cert.pem +x509.certificate=/etc/pki/tls/certs/ktls.pem +x509.private_key=/etc/pki/tls/private/ktls.key + +[authenticate.server] +x509.truststore=/etc/pki/tls/certs/ca-cert.pem +x509.certificate=/etc/pki/tls/certs/ktls.pem +x509.private_key=/etc/pki/tls/private/ktls.keyscripts/bringup.Makefile +5
-0@@ -21,6 +21,11 @@ ifeq (y,$(CONFIG_KDEVOPS_SETUP_NFSD)) KDEVOPS_BRING_UP_DEPS += nfsd endif # KDEVOPS_SETUP_NFSD +ifeq (y,$(CONFIG_KDEVOPS_SETUP_KTLS)) +KDEVOPS_BRING_UP_DEPS += ktls +KDEVOPS_DESTROY_DEPS += ktls-destroy +endif # KDEVOPS_SETUP_KTLS + update_etc_hosts: $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \ -f 30 -i hosts playbooks/update_etc_hosts.ymlscripts/ktls.Makefile new file +8
-0@@ -0,0 +1,8 @@ +ktls: + $(Q)ansible-playbook $(ANSIBLE_VERBOSE) --extra-vars=@./extra_vars.yaml \ + -f 30 -i hosts playbooks/ktls.yml + +ktls-destroy: + $(Q)rm -rf $(TOPDIR)/ca + +PHONY += ktls ktls-destroyworkflows/fstests/nfs/Kconfig +8
-1@@ -54,11 +54,18 @@ config FSTESTS_NFS_SECTION_DEFAULT time of this writing, this makes the client autonegotiate an NFS version, starting with v4.2 if it's available. +config FSTESTS_NFS_SECTION_TLS + bool "Enable testing section: nfs_tls" + default n + depends on KDEVOPS_SETUP_KTLS + help + Enabling this will test with the xprtsec=tls mount option. + config FSTESTS_NFS_SECTION_V40 bool "Enable testing section: nfs_v40" default n help - Enabling this will test NFSv4.0 + Enabling this will test NFSv4.0. config FSTESTS_NFS_SECTION_V3 bool "Enable testing section: nfs_v3"workflows/fstests/nfs/Makefile +3
-1@@ -9,6 +9,9 @@ FSTESTS_ARGS += fstests_nfs_server_host='$(FSTESTS_NFS_SERVER_HOST)' ifeq (y,$(CONFIG_FSTESTS_NFS_SECTION_DEFAULT)) FSTESTS_ARGS += fstests_nfs_section_default=True endif +ifeq (y,$(CONFIG_FSTESTS_NFS_SECTION_TLS)) +FSTESTS_ARGS += fstests_nfs_section_tls=True +endif ifeq (y,$(CONFIG_FSTESTS_NFS_SECTION_V40)) FSTESTS_ARGS += fstests_nfs_section_v40=True endif ---base-commit:
2f7d9b13a7ac734e2fb40ed68e45150af9d727ef
change-id: 20231212-ktls-5534fde5777cBest regards,
Signature · 1 line
Jeff Layton <[email protected]>
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 8 lines · Jeff Layton
Add a new option to the post-install "goals" phase to configure tlshd for TLS handshake upcalls. This adds a new playbook to build a CA, generate certs for the hosts, and then configure tlshd to use them.
Finally, it also adds a new NFS fstests option to test RPC over TLS (using xprtsec=mtls).
Signed-off-by Jeff Layton <[email protected]>
All looks good to me.
Luis