-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding remove functionality and header
- Loading branch information
Adam Leiner
committed
May 21, 2024
1 parent
4ae0e59
commit 9c4122f
Showing
5 changed files
with
51 additions
and
20 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
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 }} |
16 changes: 0 additions & 16 deletions
16
roles/rke2_common/tasks/add-pod-security-admission-config.yml
This file was deleted.
Oops, something went wrong.
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 | ||
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" | ||
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 | ||
|
||
- 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 == false | ||
when: | ||
- pod_security_admission_config_file_path is not defined or pod_security_admission_config_file_path|length == 0 | ||
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