From c4ed7b9b9ba42236dd7cbdd5d6ce28dd904859ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Sat, 9 Nov 2024 18:01:19 +0100 Subject: [PATCH] Always copy files and directories, never symlink --- dotfiles.yml | 3 +++ user.yml | 48 +++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/dotfiles.yml b/dotfiles.yml index f465524..19f1253 100644 --- a/dotfiles.yml +++ b/dotfiles.yml @@ -43,6 +43,7 @@ dotfiles: to: .config/i3status-rust/icons/awesome.toml - from: i3/scripts to: .config/i3/scripts + dir: true - from: tmux/tmux.conf to: .config/tmux/tmux.conf - from: vim/vimrc @@ -75,6 +76,7 @@ dotfiles: template: true - from: alacritty/themes to: .config/alacritty/themes + dir: true - from: rofi/config to: .config/rofi/config - from: gtk/gtk-3.0.ini @@ -90,6 +92,7 @@ dotfiles: to: .config/qt5ct/qt5ct.conf - from: scripts to: scripts + dir: true - from: helix/config.toml to: .config/helix/config.toml - from: helix/languages.toml diff --git a/user.yml b/user.yml index 6e180d7..dbcfc72 100644 --- a/user.yml +++ b/user.yml @@ -123,14 +123,14 @@ loop_control: label: "{{ item.to }}" - - name: remove invalid copy target (directories) + - name: remove invalid copy target (symlinks) file: path: "{{ item.stat.path }}" state: absent when: - not item.skipped is defined or not item.skipped - item.stat.exists - - item.stat.isdir + - item.stat.islnk with_items: "{{ copy_stat.results }}" loop_control: label: "{{ item.item.from }}" @@ -147,16 +147,46 @@ loop_control: label: "{{ item.to }}" - - name: link dotfiles - file: - state: link - force: true - follow: false - path: "/home/{{ user.name }}/{{ item.to }}" + - name: copy dotfiles + copy: + dest: "/home/{{ user.name }}/{{ item.to }}" src: /var/lib/dotfiles/{{ item.from }} owner: "{{ user.name }}" group: "{{ user.name }}" - when: not item.template|default(false) + when: not item.template|default(false) and not item.dir|default(false) + with_items: "{{ dotfiles }}" + become: true + become_user: root + loop_control: + label: "{{ item.to }}" + + - name: copy directories + synchronize: + dest: "/home/{{ user.name }}/{{ item.to }}/" + src: /var/lib/dotfiles/{{ item.from }}/ + archive: false + owner: false + group: false + links: true + perms: false + times: false + recursive: true + checksum: true + delete: true + when: item.dir|default(false) + with_items: "{{ dotfiles }}" + become: true + become_user: root + loop_control: + label: "{{ item.to }}" + + - name: apply directory permissions + file: + dest: "/home/{{ user.name }}/{{ item.to }}/" + owner: "{{ user.name }}" + group: "{{ user.name }}" + recurse: true + when: item.dir|default(false) with_items: "{{ dotfiles }}" become: true become_user: root