diff options
Diffstat (limited to 'roles/dotfiles')
| -rw-r--r-- | roles/dotfiles/defaults/main.yml | 7 | ||||
| -rw-r--r-- | roles/dotfiles/tasks/main.yml | 162 |
2 files changed, 107 insertions, 62 deletions
diff --git a/roles/dotfiles/defaults/main.yml b/roles/dotfiles/defaults/main.yml index d791c8b..cec3b6e 100644 --- a/roles/dotfiles/defaults/main.yml +++ b/roles/dotfiles/defaults/main.yml @@ -1,3 +1,4 @@ -user: d -homedir: /home/{{ user }} -jumphost: false +dotfiles_user: d +dotfiles_group: d +dotfiles_homedir: /home/{{ dotfiles_user }} +dotfiles_jumphost: false diff --git a/roles/dotfiles/tasks/main.yml b/roles/dotfiles/tasks/main.yml index 17228a5..73c9a90 100644 --- a/roles/dotfiles/tasks/main.yml +++ b/roles/dotfiles/tasks/main.yml @@ -13,16 +13,12 @@ failed_when: false register: has_bash - - name: Copy bash_profile to home directory - ansible.builtin.copy: - src: misc/dotfiles/bash_profile - dest: '{{ homedir }}/.bash_profile' - when: has_bash.rc == 0 - - - name: Template bashrc to home directory - ansible.builtin.template: - src: misc/dotfiles/bashrc.j2 - dest: '{{ homedir }}/.bashrc' + - ansible.builtin.include_role: + name: bashrc + vars: + bashrc_user: '{{ dotfiles_user }}' + bashrc_group: '{{ dotfiles_group }}' + bashrc_homedir: '{{ dotfiles_homedir }}' when: has_bash.rc == 0 - name: Configure vim if installed @@ -34,10 +30,12 @@ failed_when: false register: has_vim - - name: Copy vimrc to home directory - ansible.builtin.copy: - src: misc/dotfiles/vimrc - dest: '{{ homedir }}/.vimrc' + - ansible.builtin.include_role: + name: vimrc + vars: + vimrc_user: '{{ dotfiles_user }}' + vimrc_group: '{{ dotfiles_group }}' + vimrc_homedir: '{{ dotfiles_homedir }}' when: has_vim.rc == 0 - name: Configure screen if installed @@ -49,10 +47,13 @@ failed_when: false register: has_screen - - name: Template screenrc to home directory - ansible.builtin.template: - src: misc/dotfiles/screenrc.j2 - dest: '{{ homedir }}/.screenrc' + - ansible.builtin.include_role: + name: screenrc + vars: + screenrc_user: '{{ dotfiles_user }}' + screenrc_group: '{{ dotfiles_group }}' + screenrc_homedir: '{{ dotfiles_homedir }}' + screenrc_jumphost: '{{ dotfiles_jumphost }}' when: has_screen.rc == 0 - name: Configure ssh if installed @@ -64,31 +65,37 @@ failed_when: false register: has_ssh - - name: Setup ssh directory - ansible.builtin.file: - path: '{{ user }}/.ssh' - state: directory - owner: '{{ user }}' - mode: u+rw,g-rw,o-rw + - ansible.builtin.include_role: + name: sshconfig + vars: + sshconfig_user: '{{ dotfiles_user }}' + sshconfig_group: '{{ dotfiles_group }}' + sshconfig_homedir: '{{ dotfiles_homedir }}' + sshconfig_jumphost: '{{ dotfiles_jumphost }}' when: has_ssh.rc == 0 - - name: Template ssh config to home directory - ansible.builtin.template: - src: misc/dotfiles/ssh/config.j2 - dest: '{{ homedir }}/.ssh/config' - owner: '{{ user }}' - mode: u+rw,g-rw,o-rw - when: has_ssh.rc == 0 +- name: Configure wireguard if installed + tags: wireguard + block: + - name: Check if wireguard is installed + ansible.builtin.command: wg --version + changed_when: false + failed_when: false + register: has_wireguard - - name: Copy ssh rc to home directory - ansible.builtin.copy: - src: misc/dotfiles/ssh/rc - dest: '{{ homedir }}/.ssh/rc' - owner: '{{ user }}' - mode: u+rwx,g-rw,o-rw - when: - - has_ssh.rc == 0 - - jumphost + - name: Get actual hostname + ansible.builtin.command: hostname + changed_when: false + failed_when: false + register: hostname + + - ansible.builtin.include_role: + name: wgconfig + vars: + wgconfig_user: '{{ dotfiles_user }}' + wgconfig_group: '{{ dotfiles_group }}' + wgconfig_homedir: '{{ dotfiles_homedir }}' + when: has_wireguard.rc == 0 and hostname.stdout == "silver" - name: Configure git if installed tags: git @@ -99,13 +106,12 @@ failed_when: false register: has_git - - name: Copy git config files to home directory - ansible.builtin.copy: - src: misc/dotfiles/{{ item }} - dest: '{{ homedir }}/.{{ item }}' - loop: - - gitconfig - - gitignore + - ansible.builtin.include_role: + name: gitconfig + vars: + gitconfig_user: '{{ dotfiles_user }}' + gitconfig_group: '{{ dotfiles_group }}' + gitconfig_homedir: '{{ dotfiles_homedir }}' when: has_git.rc == 0 - name: Configure gdb if installed @@ -117,10 +123,12 @@ failed_when: false register: has_gdb - - name: Copy gdbinit to home directory - ansible.builtin.copy: - src: misc/dotfiles/gdbinit - dest: '{{ homedir }}/.gdbinit' + - ansible.builtin.include_role: + name: gdbinit + vars: + gdbinit_user: '{{ dotfiles_user }}' + gdbinit_group: '{{ dotfiles_group }}' + gdbinit_homedir: '{{ dotfiles_homedir }}' when: has_gdb.rc == 0 - name: Configure mutt if installed @@ -132,12 +140,31 @@ failed_when: false register: has_mutt - - name: Copy muttrc to home directory - ansible.builtin.copy: - src: misc/dotfiles/muttrc - dest: '{{ homedir }}/.muttrc' + - ansible.builtin.include_role: + name: muttrc + vars: + muttrc_user: '{{ dotfiles_user }}' + muttrc_group: '{{ dotfiles_group }}' + muttrc_homedir: '{{ dotfiles_homedir }}' when: has_mutt.rc == 0 +- name: Configure go if installed + tags: go + block: + - name: Check if go is installed + ansible.builtin.command: go version + changed_when: false + failed_when: false + register: has_go + + - ansible.builtin.include_role: + name: goenv + vars: + goenv_user: '{{ dotfiles_user }}' + goenv_group: '{{ dotfiles_group }}' + goenv_homedir: '{{ dotfiles_homedir }}' + when: has_go.rc == 0 + - name: Copy templates files if necessary tags: templates block: @@ -155,19 +182,36 @@ - name: Setup templates directory ansible.builtin.file: - path: '{{ homedir }}/.templates' + path: '{{ dotfiles_homedir }}/.templates' state: directory - owner: '{{ user }}' + owner: '{{ dotfiles_user }}' + group: '{{ dotfiles_group }}' + mode: u+rw,g+r,o+r when: has_cpp.rc == 0 or has_python.rc == 0 - name: Copy template.cpp to home directory ansible.builtin.copy: src: misc/dotfiles/templates/template.cpp - dest: '{{ homedir }}/.templates/template.cpp' + dest: '{{ dotfiles_homedir }}/.templates/template.cpp' + owner: '{{ dotfiles_user }}' + group: '{{ dotfiles_group }}' + mode: u+rw,g+r,o+r + when: has_cpp.rc == 0 + + - name: Copy benchmark.cpp to home directory + ansible.builtin.copy: + src: misc/dotfiles/templates/benchmark.cpp + dest: '{{ dotfiles_homedir }}/.templates/benchmark.cpp' + owner: '{{ dotfiles_user }}' + group: '{{ dotfiles_group }}' + mode: u+rw,g+r,o+r when: has_cpp.rc == 0 - name: Copy template.py to home directory ansible.builtin.copy: src: misc/dotfiles/templates/template.py - dest: '{{ homedir }}/.templates/template.py' + dest: '{{ dotfiles_homedir }}/.templates/template.py' + owner: '{{ dotfiles_user }}' + group: '{{ dotfiles_group }}' + mode: u+rw,g+r,o+r when: has_python.rc == 0 |