diff --git a/tasks/Debian.yml b/tasks/Debian.yml index ba9c739..c871bd2 100644 --- a/tasks/Debian.yml +++ b/tasks/Debian.yml @@ -1,5 +1,15 @@ --- -- import_tasks: vim-Debian.yml +- import_tasks: vim.yml + +- name: Ensure vim will source a global configuration file + ansible.builtin.blockinfile: + path: /etc/vimrc + marker: '" {mark} ANSIBLE MANAGED BLOCK' + block: | + set runtimepath+=/var/lib/vim/addons + if filereadable("/etc/vimrc.local") + source /etc/vimrc.local + endif - name: Ensure Debian sources .bash_aliases ansible.builtin.lineinfile: diff --git a/tasks/RedHat-7.yml b/tasks/RedHat-7.yml index 1f266a1..080f569 100644 --- a/tasks/RedHat-7.yml +++ b/tasks/RedHat-7.yml @@ -1,32 +1,22 @@ --- - import_tasks: vim.yml - when: ansible_os_family != 'Debian' - -#- name: Ensure Arch Linux sources bash_aliases -# lineinfile: -# path: /root/.bashrc -# # regexp: '\.bash_aliases' -# line: '[ -f ~/.bash_aliases ] && source ~/.bash_aliases' -# create: yes -# when: ansible_os_family == 'Archlinux' - name: Copy shell configuration ansible.builtin.copy: src: inputrc - dest: "{{ item }}/.inputrc" + dest: "{{ dotfile_path }}/.inputrc" + loop_control: + loop_var: dotfile_path loop: - /etc/skel - /root - - "{{ ansible_env.HOME }}/" + - "{{ ansible_env.PWD }}/" -#- name: Copy bash aliases -# ansible.builtin.copy: -# src: bash_aliases -# dest: "{{ item }}/.bash_aliases" -# loop: -# - /etc/skel -# - /root -# - "{{ ansible_env.HOME }}/" +- name: Install global bash aliases + ansible.builtin.copy: + src: bash_aliases + dest: /etc/profile.d/zz_aliases.sh + mode: '0755' #- name: Add root bashrc shell history configuration # lineinfile: diff --git a/tasks/Ubuntu.yml b/tasks/Ubuntu.yml index d10e79a..54efa80 100644 --- a/tasks/Ubuntu.yml +++ b/tasks/Ubuntu.yml @@ -1,6 +1,16 @@ --- - import_tasks: vim-Debian.yml +- name: Ensure vim will source a global configuration file + ansible.builtin.blockinfile: + path: /etc/vimrc + marker: '" {mark} ANSIBLE MANAGED BLOCK' + block: | + set runtimepath+=/var/lib/vim/addons + if filereadable("/etc/vimrc.local") + source /etc/vimrc.local + endif + - name: Copy shell configuration ansible.builtin.copy: src: inputrc diff --git a/tasks/default.yml b/tasks/default.yml index e8eac5a..f2e2b64 100644 --- a/tasks/default.yml +++ b/tasks/default.yml @@ -1,24 +1,5 @@ --- -- import_tasks: vim-Debian.yml - when: ansible_os_family == 'Debian' - - import_tasks: vim.yml - when: ansible_os_family != 'Debian' - -- name: Ensure Arch Linux sources bash_aliases - lineinfile: - path: /root/.bashrc - # regexp: '\.bash_aliases' - line: '[ -f ~/.bash_aliases ] && source ~/.bash_aliases' - create: yes - when: ansible_os_family == 'Archlinux' - -- name: Ensure Debian sources .bash_aliases - ansible.builtin.lineinfile: - path: /root/.bashrc - # regexp: '\.bash_aliases' - line: 'source ~/.bash_aliases' - when: ansible_distribution == 'Debian' # Not Ubuntu, which should already have this - name: Copy shell configuration ansible.builtin.copy: @@ -45,21 +26,6 @@ line: 'HISTCONTROL=ignoreboth' state: present -- name: Add root bashrc and vim configuration. - lineinfile: - path: /root/.bashrc - regexp: "{{ item.regexp }}" - line: "{{ item.line }}" - state: present - with_items: - - regexp: '^(export )?VISUAL=' - line: 'export VISUAL=vim.basic' - - regexp: '^(export )?EDITOR=' - line: 'export EDITOR=vim.basic' - - regexp: '^(export )?SUDO_EDITOR=' - line: 'export SUDO_EDITOR=vim.basic' - when: ansible_os_family == 'Debian' - - name: Add root bashrc and vim configuration for RedHat lineinfile: path: /root/.bashrc @@ -73,7 +39,6 @@ line: 'export EDITOR=vim' - regexp: '^(export )?SUDO_EDITOR=' line: 'export SUDO_EDITOR=vim' - when: ansible_os_family != 'Debian' - name: Add functional alias to restart a service and show the log blockinfile: diff --git a/tasks/vim-Debian.yml b/tasks/vim-Debian.yml deleted file mode 100644 index 2b9c0fd..0000000 --- a/tasks/vim-Debian.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -- name: Ensure addon path for colors exists. - ansible.builtin.file: - path: /var/lib/vim/addons/colors - state: directory - -- name: Copy vim colorscheme to the addon path. - ansible.builtin.copy: - src: ir_black.vim - dest: /var/lib/vim/addons/colors/ - -- name: Apply global vim configuration - ansible.builtin.copy: - src: vimrc.local - dest: /etc/vim/ diff --git a/tasks/vim.yml b/tasks/vim.yml index 9f55267..8cf4a49 100644 --- a/tasks/vim.yml +++ b/tasks/vim.yml @@ -13,13 +13,3 @@ ansible.builtin.copy: src: vimrc.local dest: /etc/ - -- name: Ensure vim will source a global configuration file - ansible.builtin.blockinfile: - path: /etc/vimrc - marker: '" {mark} ANSIBLE MANAGED BLOCK' - block: | - set runtimepath+=/var/lib/vim/addons - if filereadable("/etc/vimrc.local") - source /etc/vimrc.local - endif