Always copy files and directories, never symlink

This commit is contained in:
2024-11-09 18:01:19 +01:00
parent 81553524a6
commit c4ed7b9b9b
2 changed files with 42 additions and 9 deletions

View File

@@ -43,6 +43,7 @@ dotfiles:
to: .config/i3status-rust/icons/awesome.toml to: .config/i3status-rust/icons/awesome.toml
- from: i3/scripts - from: i3/scripts
to: .config/i3/scripts to: .config/i3/scripts
dir: true
- from: tmux/tmux.conf - from: tmux/tmux.conf
to: .config/tmux/tmux.conf to: .config/tmux/tmux.conf
- from: vim/vimrc - from: vim/vimrc
@@ -75,6 +76,7 @@ dotfiles:
template: true template: true
- from: alacritty/themes - from: alacritty/themes
to: .config/alacritty/themes to: .config/alacritty/themes
dir: true
- from: rofi/config - from: rofi/config
to: .config/rofi/config to: .config/rofi/config
- from: gtk/gtk-3.0.ini - from: gtk/gtk-3.0.ini
@@ -90,6 +92,7 @@ dotfiles:
to: .config/qt5ct/qt5ct.conf to: .config/qt5ct/qt5ct.conf
- from: scripts - from: scripts
to: scripts to: scripts
dir: true
- from: helix/config.toml - from: helix/config.toml
to: .config/helix/config.toml to: .config/helix/config.toml
- from: helix/languages.toml - from: helix/languages.toml

View File

@@ -123,14 +123,14 @@
loop_control: loop_control:
label: "{{ item.to }}" label: "{{ item.to }}"
- name: remove invalid copy target (directories) - name: remove invalid copy target (symlinks)
file: file:
path: "{{ item.stat.path }}" path: "{{ item.stat.path }}"
state: absent state: absent
when: when:
- not item.skipped is defined or not item.skipped - not item.skipped is defined or not item.skipped
- item.stat.exists - item.stat.exists
- item.stat.isdir - item.stat.islnk
with_items: "{{ copy_stat.results }}" with_items: "{{ copy_stat.results }}"
loop_control: loop_control:
label: "{{ item.item.from }}" label: "{{ item.item.from }}"
@@ -147,16 +147,46 @@
loop_control: loop_control:
label: "{{ item.to }}" label: "{{ item.to }}"
- name: link dotfiles - name: copy dotfiles
file: copy:
state: link dest: "/home/{{ user.name }}/{{ item.to }}"
force: true
follow: false
path: "/home/{{ user.name }}/{{ item.to }}"
src: /var/lib/dotfiles/{{ item.from }} src: /var/lib/dotfiles/{{ item.from }}
owner: "{{ user.name }}" owner: "{{ user.name }}"
group: "{{ 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 }}" with_items: "{{ dotfiles }}"
become: true become: true
become_user: root become_user: root