mbr-bln/roles/common/tasks/root-systemfiles.yml

89 lines
2.0 KiB
YAML

---
# ---
# Check if local template directories exists
# ---
# root
- name: (root-systemfiles.yml) Check if local template directory exists for root
local_action: stat path={{ role_path }}/files/root
register: local_template_dir_root
# --
# Copy .bashrc
# ---
- name: (root-systemfiles.yml) Check if file '/root/.bashrc.ORIG' exists
stat:
path: /root/.bashrc.ORIG
register: bashrc_root_orig_exists
tags:
- bash
- name: (root-systemfiles.yml) Backup /root/.bashrc file
command: cp /root/.bashrc /root/.bashrc.ORIG
when: bashrc_root_orig_exists.stat.exists == False
tags:
- bash
- name: (root-systemfiles.yml) copy .bashrc for user root
copy:
src: "{{ role_path + '/files/root/_bashrc' }}"
dest: "/root/.bashrc"
owner: root
group: root
mode: 0644
when:
- local_template_dir_root.stat.exists
- lookup('fileglob', role_path + '/files/root/_bashrc')
tags:
- bash
# --
# Copy .profile
# ---
- name: (root-systemfiles.yml) Check if file '/root/.profile.ORIG' exists
stat:
path: /root/.profile.ORIG
register: profile_root_orig_exists
tags:
- profile
- name: (root-systemfiles.yml) Backup existing users .profile file
command: cp -a /root/.profile /root/.profile.ORIG
when: profile_root_orig_exists.stat.exists == False
tags:
- profile
- name: (root-systemfiles.yml) copy .profile for user root
copy:
src: "{{ role_path + '/files/root/_profile' }}"
dest: "/root/.profile"
owner: root
group: root
mode: 0644
when:
- local_template_dir_root.stat.exists
- lookup('fileglob', role_path + '/files/root/_profile')
tags:
- profile
# --
# Copy .vimrc
# ---
- name: (root-systemfiles.yml) copy .vimrc for user root
copy:
src: "{{ role_path + '/files/root/_vimrc' }}"
dest: "/root/.vimrc"
owner: root
group: root
mode: 0644
when:
- local_template_dir_root.stat.exists
- lookup('fileglob', role_path + '/files/root/_vimrc')
tags:
- vim