Red Hat Training
A Red Hat training course is available for RHEL 8
36.6.2. 配置带有 TLS 的服务器日志
您可以使用 logging
系统角色在 RHEL 系统中将日志配置为服务器,并通过运行 Ansible playbook 从带有 TLS 的远程日志系统接收日志。
此流程对 Ansible 清单中主机组中的所有主机配置 TLS。
先决条件
- 您有在要配置 TLS 的受管节点上运行 playbook 的权限。
- 受管节点列在控制节点上的清单文件中。
-
ansible
和rhel-system-roles
软件包已安装在控制节点上。
流程
使用以下内容创建一个
playbook.yml
文件:--- - name: Deploying remote input and remote_files output with certs hosts: server roles: - rhel-system-roles.logging vars: logging_pki_files: - ca_cert_src: /local/path/to/ca_cert.pem cert_src: /local/path/to/cert.pem private_key_src: /local/path/to/key.pem logging_inputs: - name: input_name type: remote tcp_ports: 514 tls: true permitted_clients: ['clients.example.com'] logging_outputs: - name: output_name type: remote_files remote_log_path: /var/log/remote/%FROMHOST%/%PROGRAMNAME:::secpath-replace%.log async_writing: true client_count: 20 io_buffer_size: 8192 logging_flows: - name: flow_name inputs: [input_name] outputs: [output_name]
playbook 使用以下参数:
logging_pki_files
-
使用这个参数您可以配置 TLS,并且必须传递
ca_cert_src
、cert_src
和private_key_src
参数。 ca_cert
-
表示 CA 证书的路径。默认路径为
/etc/pki/tls/certs/ca.pem
,文件名由用户设置。 cert
-
表示证书的路径。默认路径为
/etc/pki/tls/certs/server-cert.pem
,文件名由用户设置。 private_key
-
表示私钥的路径。默认路径为
/etc/pki/tls/private/server-key.pem
,文件名由用户设置。 ca_cert_src
-
代表复制到目标主机的本地 CA 证书文件路径。如果指定了
ca_cert
,则会将其复制到该位置。 cert_src
-
代表复制到目标主机的本地证书文件路径。如果指定了
cert
,则会将其复制到该位置。 private_key_src
-
表示复制到目标主机的本地密钥文件的路径。如果指定了
private_key
,则会将其复制到该位置。 tls
-
使用此参数可确保在网络上安全地传输日志。如果不想要安全包装程序,您可设置
tls: true
。
验证 playbook 语法:
# ansible-playbook --syntax-check playbook.yml
在清单文件上运行 playbook:
# ansible-playbook -i inventory_file playbook.yml