diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..271d404 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +inventory = inventories/hosts.ini diff --git a/deploy-laptop b/deploy-laptop index da624ec..757e317 100755 --- a/deploy-laptop +++ b/deploy-laptop @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# ansible-playbook -i inventories/hosts playbook.yml -l laptop-local --ask-vault-pass --ask-become-pass --check --diff +# ansible-playbook -l laptop-local --ask-vault-pass --ask-become-pass --check --diff -ansible-playbook -i inventories/hosts playbook.yml -l laptop-local --ask-vault-pass --ask-become-pass --diff "$@" \ No newline at end of file +ansible-playbook playbook.yml -l laptop-local --ask-vault-pass --ask-become-pass --diff "$@" \ No newline at end of file diff --git a/deploy-vm b/deploy-vm index 9be78a5..de89ff1 100755 --- a/deploy-vm +++ b/deploy-vm @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# ansible-playbook -i inventories/hosts playbook.yml -l testing-remote --ask-vault-pass --ask-become-pass --check --diff +# ansible-playbook playbook.yml -l testing-remote --ask-vault-pass --ask-become-pass --check --diff -ansible-playbook -i inventories/hosts playbook.yml -l testing-remote --ask-vault-pass --ask-become-pass --diff "$@" +ansible-playbook playbook.yml -l testing-remote --ask-vault-pass --ask-become-pass --diff "$@" diff --git a/deploy-workstation b/deploy-workstation index 7891b38..8f00b3b 100755 --- a/deploy-workstation +++ b/deploy-workstation @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# ansible-playbook -i inventories/hosts playbook.yml -l workstation-local --ask-vault-pass --ask-become-pass --check --diff +# ansible-playbook playbook.yml -l workstation-local --ask-vault-pass --ask-become-pass --check --diff -ansible-playbook -i inventories/hosts playbook.yml -l workstation-local --ask-vault-pass --ask-become-pass --diff "$@" \ No newline at end of file +ansible-playbook playbook.yml -l workstation-local --ask-vault-pass --ask-become-pass --diff "$@" \ No newline at end of file diff --git a/dotfiles/common/.config/aichat/config.yaml.j2 b/dotfiles/common/home/.config/aichat/config.yaml.j2 similarity index 100% rename from dotfiles/common/.config/aichat/config.yaml.j2 rename to dotfiles/common/home/.config/aichat/config.yaml.j2 diff --git a/dotfiles/common/.env.j2 b/dotfiles/common/home/.env.j2 similarity index 100% rename from dotfiles/common/.env.j2 rename to dotfiles/common/home/.env.j2 diff --git a/dotfiles/common/.gitconfig b/dotfiles/common/home/.gitconfig similarity index 100% rename from dotfiles/common/.gitconfig rename to dotfiles/common/home/.gitconfig diff --git a/dotfiles/common/.local/share/nautilus/scripts/share-link b/dotfiles/common/home/.local/share/nautilus/scripts/share-link similarity index 100% rename from dotfiles/common/.local/share/nautilus/scripts/share-link rename to dotfiles/common/home/.local/share/nautilus/scripts/share-link diff --git a/dotfiles/common/.ssh/authorized_keys.j2 b/dotfiles/common/home/.ssh/authorized_keys.j2 similarity index 100% rename from dotfiles/common/.ssh/authorized_keys.j2 rename to dotfiles/common/home/.ssh/authorized_keys.j2 diff --git a/dotfiles/common/.ssh/config b/dotfiles/common/home/.ssh/config similarity index 100% rename from dotfiles/common/.ssh/config rename to dotfiles/common/home/.ssh/config diff --git a/dotfiles/common/.tmux.conf b/dotfiles/common/home/.tmux.conf similarity index 100% rename from dotfiles/common/.tmux.conf rename to dotfiles/common/home/.tmux.conf diff --git a/dotfiles/common/.vimrc b/dotfiles/common/home/.vimrc similarity index 100% rename from dotfiles/common/.vimrc rename to dotfiles/common/home/.vimrc diff --git a/dotfiles/common/.zshrc b/dotfiles/common/home/.zshrc similarity index 100% rename from dotfiles/common/.zshrc rename to dotfiles/common/home/.zshrc diff --git a/dotfiles/laptop/.config/btrbk/btrbk.conf b/dotfiles/laptop/home/.config/btrbk/btrbk.conf similarity index 100% rename from dotfiles/laptop/.config/btrbk/btrbk.conf rename to dotfiles/laptop/home/.config/btrbk/btrbk.conf diff --git a/dotfiles/laptop/root/etc/keyd/default.conf b/dotfiles/laptop/root/etc/keyd/default.conf new file mode 100644 index 0000000..1c61ce6 --- /dev/null +++ b/dotfiles/laptop/root/etc/keyd/default.conf @@ -0,0 +1,5 @@ +[ids] +0001:0001:09b4e68d + +[main] +leftmeta+leftshift+f23 = rightcontrol \ No newline at end of file diff --git a/dotfiles/workstation/.config/btrbk/btrbk.conf b/dotfiles/workstation/home/.config/btrbk/btrbk.conf similarity index 100% rename from dotfiles/workstation/.config/btrbk/btrbk.conf rename to dotfiles/workstation/home/.config/btrbk/btrbk.conf diff --git a/inventories/hosts b/inventories/hosts.ini similarity index 100% rename from inventories/hosts rename to inventories/hosts.ini diff --git a/roles/dotfiles/tasks/main.yml b/roles/dotfiles/tasks/main.yml index 31d3f85..ee68b13 100644 --- a/roles/dotfiles/tasks/main.yml +++ b/roles/dotfiles/tasks/main.yml @@ -1,96 +1,202 @@ --- -- name: Find common dotfiles (excluding templates) +- name: Find common home dotfiles (excluding templates) ansible.builtin.find: - paths: "{{ playbook_dir }}/dotfiles/common" + paths: "{{ playbook_dir }}/dotfiles/common/home" recurse: true file_type: file hidden: true excludes: "*.j2" delegate_to: localhost - register: dotfiles_common_files + register: dotfiles_common_home_files run_once: true + ignore_errors: true -- name: Find group dotfiles (excluding templates) +- name: Find common root dotfiles (excluding templates) ansible.builtin.find: - paths: "{{ playbook_dir }}/dotfiles/{{ item }}" + paths: "{{ playbook_dir }}/dotfiles/common/root" + recurse: true + file_type: file + hidden: true + excludes: "*.j2" + delegate_to: localhost + register: dotfiles_common_root_files + run_once: true + ignore_errors: true + +- name: Find group home dotfiles (excluding templates) + ansible.builtin.find: + paths: "{{ playbook_dir }}/dotfiles/{{ item }}/home" recurse: true file_type: file hidden: true excludes: "*.j2" loop: "{{ group_names | default([]) }}" delegate_to: localhost - register: dotfiles_group_files + register: dotfiles_group_home_files run_once: true ignore_errors: true -- name: Deploy common dotfiles (remote) - ansible.builtin.copy: - src: "{{ item.path }}" - dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.path | replace(playbook_dir + '/dotfiles/common/', '') }}" - mode: preserve - loop: "{{ dotfiles_common_files.files }}" - when: ansible_connection not in ['local', 'localhost'] - -- name: Deploy group dotfiles (remote) - ansible.builtin.copy: - src: "{{ item.1.path }}" - dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.1.path | replace(playbook_dir + '/dotfiles/' + item.0.item + '/', '') }}" - mode: preserve - loop: "{{ dotfiles_group_files.results | subelements('files', skip_missing=True) }}" - when: ansible_connection not in ['local', 'localhost'] - -- name: Symlink common dotfiles (local) - ansible.builtin.file: - src: "{{ item.path }}" - dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.path | replace((playbook_dir + '/dotfiles/common/'), '') }}" - state: link - force: true - loop: "{{ dotfiles_common_files.files }}" - when: ansible_connection in ['local', 'localhost'] - -- name: Symlink group dotfiles (local) - ansible.builtin.file: - src: "{{ item.1.path }}" - dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.1.path | replace((playbook_dir + '/dotfiles/' + item.0.item + '/'), '') }}" - state: link - force: true - loop: "{{ dotfiles_group_files.results | subelements('files') }}" - when: ansible_connection in ['local', 'localhost'] - -- name: Find template files in common dotfiles +- name: Find group root dotfiles (excluding templates) ansible.builtin.find: - paths: "{{ playbook_dir }}/dotfiles/common" + paths: "{{ playbook_dir }}/dotfiles/{{ item }}/root" + recurse: true + file_type: file + hidden: true + excludes: "*.j2" + loop: "{{ group_names | default([]) }}" + delegate_to: localhost + register: dotfiles_group_root_files + run_once: true + ignore_errors: true + +- name: Deploy common home dotfiles (remote) + ansible.builtin.copy: + src: "{{ item.path }}" + dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.path | replace(playbook_dir + '/dotfiles/common/home/', '') }}" + mode: preserve + loop: "{{ dotfiles_common_home_files.files }}" + when: ansible_connection not in ['local', 'localhost'] + +- name: Deploy common root dotfiles (remote) + ansible.builtin.copy: + src: "{{ item.path }}" + dest: "/{{ item.path | replace(playbook_dir + '/dotfiles/common/root/', '') }}" + mode: preserve + loop: "{{ dotfiles_common_root_files.files }}" + when: ansible_connection not in ['local', 'localhost'] + become: true + +- name: Deploy group home dotfiles (remote) + ansible.builtin.copy: + src: "{{ item.1.path }}" + dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.1.path | replace(playbook_dir + '/dotfiles/' + item.0.item + '/home/', '') }}" + mode: preserve + loop: "{{ dotfiles_group_home_files.results | subelements('files', skip_missing=True) }}" + when: ansible_connection not in ['local', 'localhost'] + +- name: Deploy group root dotfiles (remote) + ansible.builtin.copy: + src: "{{ item.1.path }}" + dest: "/{{ item.1.path | replace(playbook_dir + '/dotfiles/' + item.0.item + '/root/', '') }}" + mode: preserve + loop: "{{ dotfiles_group_root_files.results | subelements('files', skip_missing=True) }}" + when: ansible_connection not in ['local', 'localhost'] + become: true + +- name: Symlink common home dotfiles (local) + ansible.builtin.file: + src: "{{ item.path }}" + dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.path | replace((playbook_dir + '/dotfiles/common/home/'), '') }}" + state: link + force: true + loop: "{{ dotfiles_common_home_files.files }}" + when: ansible_connection in ['local', 'localhost'] + +- name: Symlink common root dotfiles (local) + ansible.builtin.file: + src: "{{ item.path }}" + dest: "/{{ item.path | replace((playbook_dir + '/dotfiles/common/root/'), '') }}" + state: link + force: true + loop: "{{ dotfiles_common_root_files.files }}" + when: ansible_connection in ['local', 'localhost'] + become: true + +- name: Symlink group home dotfiles (local) + ansible.builtin.file: + src: "{{ item.1.path }}" + dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.1.path | replace((playbook_dir + '/dotfiles/' + item.0.item + '/home/'), '') }}" + state: link + force: true + loop: "{{ dotfiles_group_home_files.results | subelements('files', skip_missing=True) }}" + when: ansible_connection in ['local', 'localhost'] + +- name: Symlink group root dotfiles (local) + ansible.builtin.file: + src: "{{ item.1.path }}" + dest: "/{{ item.1.path | replace((playbook_dir + '/dotfiles/' + item.0.item + '/root/'), '') }}" + state: link + force: true + loop: "{{ dotfiles_group_root_files.results | subelements('files', skip_missing=True) }}" + when: ansible_connection in ['local', 'localhost'] + become: true + +- name: Find template files in common home dotfiles + ansible.builtin.find: + paths: "{{ playbook_dir }}/dotfiles/common/home" recurse: true file_type: file hidden: true patterns: "*.j2" delegate_to: localhost - register: dotfiles_common_templates + register: dotfiles_common_home_templates run_once: true + ignore_errors: true -- name: Find template files in group dotfiles +- name: Find template files in common root dotfiles ansible.builtin.find: - paths: "{{ playbook_dir }}/dotfiles/{{ item }}" + paths: "{{ playbook_dir }}/dotfiles/common/root" + recurse: true + file_type: file + hidden: true + patterns: "*.j2" + delegate_to: localhost + register: dotfiles_common_root_templates + run_once: true + ignore_errors: true + +- name: Find template files in group home dotfiles + ansible.builtin.find: + paths: "{{ playbook_dir }}/dotfiles/{{ item }}/home" recurse: true file_type: file hidden: true patterns: "*.j2" loop: "{{ group_names | default([]) }}" delegate_to: localhost - register: dotfiles_group_templates + register: dotfiles_group_home_templates run_once: true ignore_errors: true -- name: Template common dotfiles +- name: Find template files in group root dotfiles + ansible.builtin.find: + paths: "{{ playbook_dir }}/dotfiles/{{ item }}/root" + recurse: true + file_type: file + hidden: true + patterns: "*.j2" + loop: "{{ group_names | default([]) }}" + delegate_to: localhost + register: dotfiles_group_root_templates + run_once: true + ignore_errors: true + +- name: Template common home dotfiles ansible.builtin.template: src: "{{ item.path }}" - dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.path | replace(playbook_dir + '/dotfiles/common/', '') | replace('.j2', '') }}" + dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.path | replace(playbook_dir + '/dotfiles/common/home/', '') | replace('.j2', '') }}" mode: '0600' - loop: "{{ dotfiles_common_templates.files }}" + loop: "{{ dotfiles_common_home_templates.files }}" -- name: Template group dotfiles +- name: Template common root dotfiles + ansible.builtin.template: + src: "{{ item.path }}" + dest: "/{{ item.path | replace(playbook_dir + '/dotfiles/common/root/', '') | replace('.j2', '') }}" + mode: '0600' + loop: "{{ dotfiles_common_root_templates.files }}" + become: true + +- name: Template group home dotfiles ansible.builtin.template: src: "{{ item.1.path }}" - dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.1.path | replace(playbook_dir + '/dotfiles/' + item.0.item + '/', '') | replace('.j2', '') }}" + dest: "{{ ansible_facts['env']['HOME'] }}/{{ item.1.path | replace(playbook_dir + '/dotfiles/' + item.0.item + '/home/', '') | replace('.j2', '') }}" mode: '0600' - loop: "{{ dotfiles_group_templates.results | subelements('files', skip_missing=True) }}" + loop: "{{ dotfiles_group_home_templates.results | subelements('files', skip_missing=True) }}" + +- name: Template group root dotfiles + ansible.builtin.template: + src: "{{ item.1.path }}" + dest: "/{{ item.1.path | replace(playbook_dir + '/dotfiles/' + item.0.item + '/root/', '') | replace('.j2', '') }}" + mode: '0600' + loop: "{{ dotfiles_group_root_templates.results | subelements('files', skip_missing=True) }}" + become: true