279 lines
7.9 KiB
YAML
279 lines
7.9 KiB
YAML
---
|
|
|
|
# ---
|
|
# Check if local template directories exists
|
|
# ---
|
|
|
|
# system_user
|
|
- name: (system-user-systemfiles.yml) Check if local template directory exists for default users
|
|
local_action: stat path={{ inventory_dir }}/files/homedirs/{{ item.name }}
|
|
with_items: "{{ system_users }}"
|
|
loop_control:
|
|
label: '{{ item.name }}'
|
|
register: local_template_dir_system_users
|
|
|
|
# root
|
|
- name: (system-user-systemfiles.yml) Check if local template directory exists for root
|
|
local_action: stat path={{ inventory_dir }}/files/homedirs/root
|
|
register: local_template_dir_root
|
|
|
|
|
|
# --
|
|
# Copy .profile
|
|
# ---
|
|
|
|
- name: (user-systemfiles.yml) Check if users file '.profile.ORIG' exists
|
|
stat:
|
|
path: "~{{ item.name }}/.profile.ORIG"
|
|
register: profile_user_orig_exists
|
|
loop: "{{ system_users }}"
|
|
loop_control:
|
|
label: '{{ item.name }}'
|
|
tags:
|
|
- profile
|
|
|
|
- name: (user-systemfiles.yml) Backup existing users .profile file
|
|
command: cp -a ~{{ item.item.name }}/.profile ~{{ item.item.name }}/.profile.ORIG
|
|
loop: "{{ profile_user_orig_exists.results }}"
|
|
loop_control:
|
|
label: '{{ item.item.name }}'
|
|
when:
|
|
- item.stat.exists == False
|
|
tags:
|
|
- profile
|
|
|
|
- name: (system-user-systemfiles.yml) copy .profile if it exists
|
|
copy:
|
|
src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_profile') }}"
|
|
dest: "~{{ item.item.name }}/.profile"
|
|
owner: "{{ item.item.name }}"
|
|
group: "{{ item.item.name }}"
|
|
mode: 0644
|
|
loop: "{{ local_template_dir_system_users.results }}"
|
|
loop_control:
|
|
label: '{{ item.item.name }}'
|
|
when:
|
|
- item.stat.exists
|
|
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_profile')
|
|
tags:
|
|
- profile
|
|
|
|
- name: (system-user-systemfiles.yml) copy default .profile if it exists
|
|
template:
|
|
src: files/homedirs/DEFAULT/_profile
|
|
dest: "~{{ item.item.name }}/.profile"
|
|
owner: "{{ item.item.name }}"
|
|
group: "{{ item.item.name }}"
|
|
mode: 0644
|
|
loop: "{{ local_template_dir_system_users.results }}"
|
|
loop_control:
|
|
label: '{{ item.item.name }}'
|
|
when:
|
|
- item.stat.exists == false
|
|
- lookup('fileglob', inventory_dir + '/files/homedirs/DEFAULT/_profile')
|
|
tags:
|
|
- profile
|
|
|
|
# -- root user
|
|
- name: (system-user-systemfiles.yml) Check if file '/root/.profile.ORIG' exists
|
|
stat:
|
|
path: /root/.profile.ORIG
|
|
register: profile_root_orig_exists
|
|
tags:
|
|
- profile
|
|
|
|
- name: (system-user-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: (system-user-systemfiles.yml) copy .profile for user root
|
|
copy:
|
|
src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/root/_profile') }}"
|
|
dest: "/root/.profile"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
when:
|
|
- local_template_dir_root.stat.exists
|
|
- lookup('fileglob', inventory_dir + '/files/homedirs/root/_profile')
|
|
tags:
|
|
- profile
|
|
|
|
# --
|
|
# Copy .bashrc
|
|
# ---
|
|
|
|
- name: (system-user-systemfiles.yml) Check if users file '.bashrc.ORIG' exists
|
|
stat:
|
|
path: "~{{ item.name }}/.bashrc.ORIG"
|
|
register: bashrc_user_orig_exists
|
|
loop: "{{ system_users }}"
|
|
loop_control:
|
|
label: '{{ item.name }}'
|
|
tags:
|
|
- bashrc
|
|
|
|
- name: (system-user-systemfiles.yml) Backup existing users .bashrc file
|
|
command: cp -a ~{{ item.item.name }}/.bashrc ~{{ item.item.name }}/.bashrc.ORIG
|
|
loop: "{{ bashrc_user_orig_exists.results }}"
|
|
loop_control:
|
|
label: '{{ item.item.name }}'
|
|
when: item.stat.exists == False
|
|
tags:
|
|
- bashrc
|
|
|
|
- name: (system-user-systemfiles.yml) copy .bashrc if it exists
|
|
copy:
|
|
src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_bashrc') }}"
|
|
dest: "~{{ item.item.name }}/.bashrc"
|
|
owner: "{{ item.item.name }}"
|
|
group: "{{ item.item.name }}"
|
|
mode: 0644
|
|
loop: "{{ local_template_dir_system_users.results }}"
|
|
loop_control:
|
|
label: '{{ item.item.name }}'
|
|
when:
|
|
- item.stat.exists
|
|
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_bashrc')
|
|
tags:
|
|
- bashrc
|
|
|
|
- name: (system-user-systemfiles.yml) copy default .bashrc if it exists
|
|
copy:
|
|
src: files/homedirs/DEFAULT/_bashrc
|
|
dest: "~{{ item.item.name }}/.bashrc"
|
|
owner: "{{ item.item.name }}"
|
|
group: "{{ item.item.name }}"
|
|
mode: 0644
|
|
loop: "{{ local_template_dir_system_users.results }}"
|
|
loop_control:
|
|
label: '{{ item.item.name }}'
|
|
when:
|
|
- item.stat.exists == false
|
|
tags:
|
|
- bashrc
|
|
|
|
# -- root user
|
|
- name: (system-user-systemfiles.yml) Check if file '/root/.bashrc.ORIG' exists
|
|
stat:
|
|
path: /root/.bashrc.ORIG
|
|
register: bashrc_root_orig_exists
|
|
tags:
|
|
- bash
|
|
|
|
- name: (system-user-systemfiles.yml) Backup /root/.bashrc file
|
|
command: cp /root/.bashrc /root/.bashrc.ORIG
|
|
when: bashrc_root_orig_exists.stat.exists == False
|
|
tags:
|
|
- bash
|
|
|
|
- name: (system-user-systemfiles.yml) copy .bashrc for user root
|
|
copy:
|
|
src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/root/_bashrc') }}"
|
|
dest: "/root/.bashrc"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
when:
|
|
- local_template_dir_root.stat.exists
|
|
- lookup('fileglob', inventory_dir + '/files/homedirs/root/_bashrc')
|
|
tags:
|
|
- bash
|
|
|
|
# --
|
|
# Copy .vimrc
|
|
# ---
|
|
|
|
- name: (system-user-systemfiles.yml) copy .vimrc if it exists
|
|
copy:
|
|
src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_vimrc') }}"
|
|
dest: "~{{ item.item.name }}/.vimrc"
|
|
owner: "{{ item.item.name }}"
|
|
group: "{{ item.item.name }}"
|
|
mode: 0644
|
|
loop: "{{ local_template_dir_system_users.results }}"
|
|
loop_control:
|
|
label: '{{ item.item.name }}'
|
|
when:
|
|
- item.stat.exists
|
|
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_vimrc')
|
|
tags:
|
|
- vimrc
|
|
|
|
- name: (system-user-systemfiles.yml) Check if .vim directory exists for default users
|
|
local_action: stat path={{ inventory_dir }}/files/homedirs/{{ item.name }}/.vim
|
|
with_items: "{{ system_users }}"
|
|
loop_control:
|
|
label: '{{ item.name }}'
|
|
register: local_template_dir_dotvim_default_user
|
|
|
|
- name: (system-user-systemfiles.yml) copy .vim directory if it exists
|
|
copy:
|
|
src: "{{ inventory_dir + '/files/homedirs/' + item.item.name + '/.vim' }}"
|
|
dest: "~{{ item.item.name }}"
|
|
owner: "{{ item.item.name }}"
|
|
group: "{{ item.item.name }}"
|
|
mode: 0644
|
|
with_items: "{{ local_template_dir_dotvim_default_user.results }}"
|
|
loop_control:
|
|
label: '{{ item.item.name }}'
|
|
when:
|
|
- item.stat.exists
|
|
tags:
|
|
- vimrc
|
|
|
|
- name: (system-user-systemfiles.yml) copy default .vimrc if it exists
|
|
copy:
|
|
src: files/homedirs/DEFAULT/_vimrc
|
|
dest: "~{{ item.item.name }}/.vimrc"
|
|
owner: "{{ item.item.name }}"
|
|
group: "{{ item.item.name }}"
|
|
mode: 0644
|
|
loop: "{{ local_template_dir_system_users.results }}"
|
|
loop_control:
|
|
label: '{{ item.item.name }}'
|
|
when:
|
|
- item.stat.exists == false
|
|
tags:
|
|
- vimrc
|
|
|
|
|
|
- name: (system-user-systemfiles.yml) copy .vimrc for user root
|
|
copy:
|
|
src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/root/_vimrc') }}"
|
|
dest: "/root/.vimrc"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
when:
|
|
- local_template_dir_root.stat.exists
|
|
- lookup('fileglob', inventory_dir + '/files/homedirs/root/_vimrc')
|
|
tags:
|
|
- vimrc
|
|
|
|
- name: (system-user-systemfiles.yml) Check if local template directory .vim exists for user root
|
|
local_action: stat path={{ inventory_dir }}/files/homedirs/root/.vim
|
|
register: local_template_dir_vim_root
|
|
with_items: 'root'
|
|
loop_control:
|
|
label: 'root'
|
|
|
|
- name: (system-user-systemfiles.yml) copy .vim directory for user root if it exists
|
|
copy:
|
|
src: "{{ inventory_dir + '/files/homedirs/root/.vim' }}"
|
|
dest: "/root"
|
|
owner: "root"
|
|
group: "root"
|
|
mode: 0644
|
|
with_items: "{{ local_template_dir_vim_root.results }}"
|
|
loop_control:
|
|
label: 'root'
|
|
when:
|
|
- item.stat.exists
|
|
tags:
|
|
- vim
|
|
|
|
|