-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from rancherfederal/jcox10-add-psa-config
Jcox10 add psa config
- Loading branch information
Showing
8 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## This is an Ansible managed file, contents will be overwritten ## | ||
|
||
{{ file_contents }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
roles/rke2_server/tasks/add-pod-security-admission-config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
- name: Create the /etc/rancher/rke2 config dir | ||
ansible.builtin.file: | ||
path: /etc/rancher/rke2 | ||
state: directory | ||
recurse: yes | ||
|
||
- name: Add pod security admission config file | ||
vars: | ||
file_contents: "{{ lookup('file', pod_security_admission_config_file_path) }}" | ||
ansible.builtin.template: | ||
src: ansible_header.j2 | ||
dest: "/etc/rancher/rke2/pod-security-admission-config.yaml" | ||
mode: '0640' | ||
owner: root | ||
group: root | ||
when: | ||
- pod_security_admission_config_file_path is defined | ||
- pod_security_admission_config_file_path|length != 0 | ||
notify: Restart rke2-server | ||
|
||
- name: Remove pod security admission config file | ||
when: | ||
- pod_security_admission_config_file_path is not defined or pod_security_admission_config_file_path|length == 0 | ||
block: | ||
- name: Check that the PSA config file exists | ||
ansible.builtin.stat: | ||
path: "/etc/rancher/rke2/pod-security-admission-config.yaml" | ||
register: stat_result | ||
|
||
- name: "Check that the PSA config file has ansible managed comments" | ||
ansible.builtin.lineinfile: | ||
name: "/etc/rancher/rke2/pod-security-admission-config.yaml" | ||
line: '## This is an Ansible managed file, contents will be overwritten ##' | ||
state: present | ||
check_mode: yes | ||
register: ansible_managed_check | ||
when: stat_result.stat.exists | bool is true | ||
|
||
- name: Remove the PSA config file if exists and has ansible managed comments | ||
ansible.builtin.file: | ||
path: "/etc/rancher/rke2/pod-security-admission-config.yaml" | ||
state: absent | ||
when: | ||
- ansible_managed_check.changed | bool is false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# This sample list was generated from: | ||
# https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/authentication-permissions-and-global-configuration/psa-config-templates#exempting-required-rancher-namespaces | ||
# For security reasons, this list should be as concise as possible | ||
# only include active namespaces that need to be except from a restricted profile. | ||
|
||
--- | ||
apiVersion: apiserver.config.k8s.io/v1 | ||
kind: AdmissionConfiguration | ||
plugins: | ||
- name: PodSecurity | ||
configuration: | ||
apiVersion: pod-security.admission.config.k8s.io/v1 | ||
kind: PodSecurityConfiguration | ||
defaults: | ||
enforce: "restricted" | ||
enforce-version: "latest" | ||
audit: "restricted" | ||
audit-version: "latest" | ||
warn: "restricted" | ||
warn-version: "latest" | ||
exemptions: | ||
usernames: [] | ||
runtimeClasses: [] | ||
namespaces: [calico-apiserver, | ||
calico-system, | ||
cattle-alerting, | ||
cattle-csp-adapter-system, | ||
cattle-elemental-system, | ||
cattle-epinio-system, | ||
cattle-externalip-system, | ||
cattle-fleet-local-system, | ||
cattle-fleet-system, | ||
cattle-gatekeeper-system, | ||
cattle-global-data, | ||
cattle-global-nt, | ||
cattle-impersonation-system, | ||
cattle-istio, | ||
cattle-istio-system, | ||
cattle-logging, | ||
cattle-logging-system, | ||
cattle-monitoring-system, | ||
cattle-neuvector-system, | ||
cattle-prometheus, | ||
cattle-provisioning-capi-system, | ||
cattle-resources-system, | ||
cattle-sriov-system, | ||
cattle-system, | ||
cattle-ui-plugin-system, | ||
cattle-windows-gmsa-system, | ||
cert-manager, | ||
cis-operator-system, | ||
fleet-default, | ||
ingress-nginx, | ||
istio-system, | ||
kube-node-lease, | ||
kube-public, | ||
kube-system, | ||
longhorn-system, | ||
local-path-storage, | ||
rancher-alerting-drivers, | ||
security-scan, | ||
tigera-operator] |