diff --git a/tasks/copy_skel_file.yml b/tasks/copy_skel_file.yml new file mode 100644 index 0000000..bfd9910 --- /dev/null +++ b/tasks/copy_skel_file.yml @@ -0,0 +1,17 @@ +--- + +- name: "Exist file {{ skel_file }}" + ansible.builtin.stat: + path: "{{ user_user_home }}/{{ skel_file }}" + register: _skel_file + +- name: Copy skel file + when: _skel_file.stat is defined and + _skel_file.stat.exist is defined and + not _skel_file.stat.exist + ansible.builtin.copy: + src: "/etc/skel/{{ _skel_file }}" + dest: "{{ user_user_home }}/{{ skel_file }}" + owner: "{{ unix_user.key }}" + group: "{{ unix_user.value.group | default('users') }}" + mode: "0600" diff --git a/tasks/create_unix_user.yml b/tasks/create_unix_user.yml index 8ae4841..659b705 100644 --- a/tasks/create_unix_user.yml +++ b/tasks/create_unix_user.yml @@ -75,14 +75,14 @@ when: unix_user.value.btrfs is defined and unix_user.value.btrfs block: - - name: "Copy skel dir" - ansible.builtin.copy: - src: /etc/skel/ - dest: "{{ user_user_home }}" - remote_src: true - owner: "{{ unix_user.key }}" - group: "{{ unix_user.value.group | default('users') }}" - mode: "0644" + - name: "Copy skel files" + ansible.builtin.include_tasks: copy_skel_file.yml + loop_control: + loop_var: skel_file + with_items: + - ".bash_logout" + - ".bash_profile" + - ".bashrc" - name: "Change permission unix users home dir: {{ unix_user.key }}" ansible.builtin.file: path: "{{ user_user_home }}"