diff --git a/linux_os/guide/system/permissions/files/rootfiles/rootfiles_configured/ansible/shared.yml b/linux_os/guide/system/permissions/files/rootfiles/rootfiles_configured/ansible/shared.yml index d248f49f973a..8a043475b30b 100644 --- a/linux_os/guide/system/permissions/files/rootfiles/rootfiles_configured/ansible/shared.yml +++ b/linux_os/guide/system/permissions/files/rootfiles/rootfiles_configured/ansible/shared.yml @@ -6,10 +6,29 @@ {{%- set files = ["bash_logout", "bash_profile", "bashrc", "cshrc", "tcshrc", ] %}} +- name: "{{{ rule_title }}} - Ensure source directory exists" + ansible.builtin.file: + path: /usr/share/rootfiles + state: directory + mode: '0755' + owner: root + group: root + {{%- for file in files %}} {{% set dest_path = "/root/." ~ file -%}} {{% set source_path = "/usr/share/rootfiles/." ~ file -%}} {{% set new_line = "C " ~ dest_path ~ " 600 root root - " ~ source_path %}} +- name: "{{{ rule_title }}} - Stat {{{ dest_path }}}" + ansible.builtin.stat: + path: "{{{ dest_path }}}" + register: {{{ rule_id }}}_{{{ file }}}_root_stat +- name: "{{{ rule_title }}} - Copy {{{ dest_path }}} to {{{ source_path }}} if missing" + ansible.builtin.copy: + src: "{{{ dest_path }}}" + dest: "{{{ source_path }}}" + remote_src: true + force: false + when: {{{ rule_id }}}_{{{ file }}}_root_stat.stat.exists - name: "{{{ rule_title }}} - Find configuration files" ansible.builtin.find: paths: /etc/tmpfiles.d/ diff --git a/linux_os/guide/system/permissions/files/rootfiles/rootfiles_configured/bash/shared.sh b/linux_os/guide/system/permissions/files/rootfiles/rootfiles_configured/bash/shared.sh index 7aefb5505df7..f96ea4f4efde 100644 --- a/linux_os/guide/system/permissions/files/rootfiles/rootfiles_configured/bash/shared.sh +++ b/linux_os/guide/system/permissions/files/rootfiles/rootfiles_configured/bash/shared.sh @@ -7,6 +7,13 @@ {{%- set files = ['bash_logout', 'bash_profile', 'bashrc', 'cshrc', 'tcshrc', ] %}} {{%- set ns = namespace(contents="") %}} +mkdir -p /usr/share/rootfiles +{{%- for file in files %}} + {{% set dest_path = '/root/.' ~ file -%}} + {{% set source_path = '/usr/share/rootfiles/.' ~ file -%}} + [ -f "{{{ dest_path }}}" ] && [ ! -f "{{{ source_path }}}" ] && cp "{{{ dest_path }}}" "{{{ source_path }}}" +{{%- endfor %}} + {{%- for file in files %}} {{% set dest_path = '/root/.' ~ file -%}} {{% set source_path = '/usr/share/rootfiles/.' ~ file -%}}