Restructure files into roles
This commit is contained in:
@@ -1,82 +1,18 @@
|
||||
---
|
||||
- name: Build file lists
|
||||
ansible.builtin.set_fact:
|
||||
dotfiles_files_home: "{{ lookup('community.general.filetree',
|
||||
playbook_dir ~ '/dotfiles/common/home',
|
||||
playbook_dir ~ '/dotfiles/' ~ group_names[0] ~ '/home') | selectattr('state', 'equalto', 'file') | rejectattr('path', 'match', '.*\\.j2$') | list }}"
|
||||
dotfiles_templates_home: "{{ lookup('community.general.filetree',
|
||||
playbook_dir ~ '/dotfiles/common/home',
|
||||
playbook_dir ~ '/dotfiles/' ~ group_names[0] ~ '/home') | selectattr('state', 'equalto', 'file') | selectattr('path', 'match', '.*\\.j2$') | list }}"
|
||||
dotfiles_files_root: "{{ lookup('community.general.filetree',
|
||||
playbook_dir ~ '/dotfiles/common/root',
|
||||
playbook_dir ~ '/dotfiles/' ~ group_names[0] ~ '/root') | selectattr('state', 'equalto', 'file') | rejectattr('path', 'match', '.*\\.j2$') | list }}"
|
||||
dotfiles_templates_root: "{{ lookup('community.general.filetree',
|
||||
playbook_dir ~ '/dotfiles/common/root',
|
||||
playbook_dir ~ '/dotfiles/' ~ group_names[0] ~ '/root') | selectattr('state', 'equalto', 'file') | selectattr('path', 'match', '.*\\.j2$') | list }}"
|
||||
- name: Deploy home dotfiles
|
||||
ansible.builtin.include_tasks: ../../deploy_files.yml
|
||||
vars:
|
||||
var_prefix: dotfiles_home
|
||||
subdir: home
|
||||
target_root: "{{ ansible_facts.env.HOME }}"
|
||||
use_symlinks: true
|
||||
become_root: false
|
||||
|
||||
- name: Ensure home directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ ansible_facts.env.HOME }}/{{ item.path | dirname }}"
|
||||
state: directory
|
||||
mode: "{{ '0700' if (item.path | dirname).startswith('.ssh') else '0755' }}"
|
||||
loop: "{{ dotfiles_files_home + dotfiles_templates_home }}"
|
||||
when: item.path | dirname != ''
|
||||
|
||||
- name: Deploy home files (local)
|
||||
ansible.builtin.file:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ ansible_facts.env.HOME }}/{{ item.path }}"
|
||||
state: link
|
||||
force: true
|
||||
loop: "{{ dotfiles_files_home }}"
|
||||
when: ansible_connection in ['local', 'localhost']
|
||||
|
||||
- name: Deploy home files (remote)
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ ansible_facts.env.HOME }}/{{ item.path }}"
|
||||
mode: preserve
|
||||
loop: "{{ dotfiles_files_home }}"
|
||||
when: ansible_connection not in ['local', 'localhost']
|
||||
|
||||
- name: Render home templates
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ ansible_facts.env.HOME }}/{{ item.path | replace('.j2', '') }}"
|
||||
mode: preserve
|
||||
loop: "{{ dotfiles_templates_home }}"
|
||||
|
||||
- name: Ensure root directories
|
||||
ansible.builtin.file:
|
||||
path: "/{{ item.path | dirname }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
loop: "{{ dotfiles_files_root + dotfiles_templates_root }}"
|
||||
become: true
|
||||
|
||||
- name: Deploy root files (local)
|
||||
ansible.builtin.file:
|
||||
src: "{{ item.src }}"
|
||||
dest: "/{{ item.path }}"
|
||||
state: link
|
||||
force: true
|
||||
loop: "{{ dotfiles_files_root }}"
|
||||
when: ansible_connection in ['local', 'localhost']
|
||||
become: true
|
||||
|
||||
- name: Deploy root files (remote)
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "/{{ item.path }}"
|
||||
mode: preserve
|
||||
loop: "{{ dotfiles_files_root }}"
|
||||
when: ansible_connection not in ['local', 'localhost']
|
||||
become: true
|
||||
|
||||
- name: Render root templates
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "/{{ item.path | replace('.j2', '') }}"
|
||||
mode: preserve
|
||||
loop: "{{ dotfiles_templates_root }}"
|
||||
become: true
|
||||
- name: Deploy root dotfiles
|
||||
ansible.builtin.include_tasks: ../../deploy_files.yml
|
||||
vars:
|
||||
var_prefix: dotfiles_root
|
||||
subdir: root
|
||||
target_root: "/"
|
||||
use_symlinks: true
|
||||
become_root: true
|
||||
|
||||
Reference in New Issue
Block a user