ansible: simplify common role

This commit is contained in:
Fernando Schauenburg 2020-12-22 12:58:54 +01:00
parent 6e12627362
commit 6d415e7d0e
12 changed files with 98 additions and 216 deletions

View file

@ -1,30 +0,0 @@
---
- name: bash | remove pre-installed profile
file:
path: "{{ item }}"
state: absent
loop:
- ~/.bash_logout
- ~/.profile
- name: bash | ensure existence of directories used in bashrc
file:
path: "{{ item }}"
state: directory
loop:
- ~/.local/share/bash # for bash history
- ~/.local/share/bash-completion/completions # for custom completions
- ~/.local/share/less # for less history
- name: bash | deploy bash profile
file:
src: "{{ role_path }}/files/bashrc"
dest: "{{ item }}"
state: link
force: yes
loop:
- ~/.bash_profile # executed for login shells
- ~/.bashrc # executed for interactve shells

View file

@ -1,16 +0,0 @@
---
- name: bin | create ~/.local/bin
file:
path: ~/.local/bin
state: directory
- name: bin | deploy local commands
file:
src: "{{ item }}"
dest: ~/.local/bin/{{ item | basename }}
state: link
force: yes
with_fileglob:
- "{{ role_path }}/files/bin/*"

View file

@ -1,16 +0,0 @@
---
- name: dircolors | create config directory
file:
path: ~/.config/dircolors
state: directory
- name: Deploy dircolors
file:
src: "{{ item }}"
dest: ~/.config/dircolors/{{ item | basename }}
state: link
force: yes
with_fileglob:
- "{{ role_path }}/files/dircolors/*"

View file

@ -1,26 +0,0 @@
---
- name: git | create config directories
file:
path: "{{ item }}"
state: directory
loop:
- ~/.config/git
- ~/.local/etc/git
- name: git | deploy config
file:
src: "{{ role_path }}/files/{{ item.src }}"
dest: ~/.config/git/{{ item.dest }}
state: link
force: yes
loop:
- { src: gitconfig, dest: config }
- { src: gitignore, dest: ignore }
- name: git | deploy host-specific config
template:
src: gitconfig.host.j2
dest: ~/.local/etc/git/config.host

View file

@ -1,13 +0,0 @@
---
- name: hushlogin | exists?
stat:
path: ~/.hushlogin
register: hush
- name: hushlogin | create
when: hush.stat.exists == false
file:
path: ~/.hushlogin
state: touch

View file

@ -1,15 +1,100 @@
---
- block:
# - import_tasks: bash.yml
# - import_tasks: bin.yml
# - import_tasks: dircolors.yml
# - import_tasks: git.yml
# - import_tasks: hushlogin.yml
# - import_tasks: mintty.yml
- import_tasks: packages.yml # TODO
# - import_tasks: python.yml
# - import_tasks: readline.yml
# - import_tasks: ssh.yml
# - import_tasks: tmux.yml
# - import_tasks: vim.yml
- name: remove pre-installed bash profile
file:
path: "{{ item }}"
state: absent
loop:
- ~/.bash_logout
- ~/.profile
- name: ensure existence of directories used by dotfiles
file:
path: "{{ item }}"
state: directory
loop:
- ~/.config/dircolors
- ~/.config/git
- ~/.config/mintty
- ~/.config/python
- ~/.config/readline
- ~/.config/tmux
- ~/.config/vim
- ~/.config/vim/autoload # vim plugin manager
- ~/.local/bin # local commands
- ~/.local/etc/git # local git config
- ~/.local/share/bash # for bash history
- ~/.local/share/bash-completion/completions # custom bash completions
- ~/.local/share/less # less history
- ~/.local/share/python # python history
- ~/.local/share/vim # viminfo
- ~/.local/share/vim/plugged # vim plugins
- ~/.ssh
- name: link dotfiles
file:
src: "{{ role_path }}/files/{{ item.src }}"
dest: "{{ item.dest }}"
state: link
force: yes
loop:
- { src: bashrc, dest: ~/.bash_profile }
- { src: bashrc, dest: ~/.bashrc }
- { src: gitconfig, dest: ~/.config/git/config }
- { src: gitignore, dest: ~/.config/git/ignore }
- { src: inputrc, dest: ~/.config/readline/inputrc }
- { src: minttyrc, dest: ~/.config/mintty/config }
- { src: plug.vim, dest: ~/.config/vim/autoload/plug.vim }
- { src: python-startup.py, dest: ~/.config/python/startup.py }
- { src: ssh_config, dest: ~/.ssh/config }
- { src: tmux-colors.conf, dest: ~/.config/tmux/tmux-colors.conf }
- { src: tmux.conf, dest: ~/.config/tmux/tmux.conf }
- { src: vimrc, dest: ~/.config/vim/vimrc }
- name: deploy templates
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
loop:
- src: gitconfig.host.j2
dest: ~/.local/etc/git/config.host
- name: link local commands
file:
src: "{{ item }}"
dest: ~/.local/bin/{{ item | basename }}
state: link
force: yes
with_fileglob:
- "{{ role_path }}/files/bin/*"
- name: link dircolors
file:
src: "{{ item }}"
dest: ~/.config/dircolors/{{ item | basename }}
state: link
force: yes
with_fileglob:
- "{{ role_path }}/files/dircolors/*"
- block:
- name: hushlogin exists?
stat:
path: ~/.hushlogin
register: hush
- name: create hushlogin
when: hush.stat.exists == false
file:
path: ~/.hushlogin
state: touch
- name: install vim plugins
shell: vim -es -u ~/.config/vim/vimrc +PlugInstall +qall

View file

@ -1,14 +0,0 @@
---
- name: mintty | create config directory
file:
path: ~/.config/mintty
state: directory
- name: mintty | deploy config
file:
src: "{{ role_path }}/files/minttyrc"
dest: ~/.config/mintty/config
state: link
force: yes

View file

@ -1,17 +0,0 @@
---
- name: python | create config and data directories
file:
path: "{{ item }}"
state: directory
loop:
- ~/.config/python
- ~/.local/share/python # for this history file
- name: python | deploy startup file
file:
src: "{{ role_path }}/files/python-startup.py"
dest: ~/.config/python/startup.py
state: link
force: yes

View file

@ -1,14 +0,0 @@
---
- name: readline | create config directory
file:
path: ~/.config/readline
state: directory
- name: readline | deploy inputrc
file:
src: "{{ role_path }}/files/inputrc"
dest: ~/.config/readline/inputrc
state: link
force: yes

View file

@ -1,14 +0,0 @@
---
- name: ssh | create config diretory
file:
path: ~/.ssh
state: directory
- name: ssh | deploy config
file:
src: "{{ role_path }}/files/ssh_config"
dest: ~/.ssh/config
state: link
force: yes

View file

@ -1,17 +0,0 @@
---
- name: tmux | create config directory
file:
path: ~/.config/tmux
state: directory
- name: tmux | deploy config
file:
src: "{{ role_path }}/files/{{ item }}"
dest: ~/.config/tmux/{{ item }}
state: link
force: yes
loop:
- tmux.conf
- tmux-colors.conf

View file

@ -1,26 +0,0 @@
---
- name: vim | create directories
file:
path: "{{ item }}"
state: directory
loop:
- ~/.config/vim # for vimrc
- ~/.config/vim/autoload # for plugin manager
- ~/.local/share/vim # for viminfo
- ~/.local/share/vim/plugged # for installing uplugins
- name: vim | deploy configuration
file:
src: "{{ role_path }}/files/{{ item.src }}"
dest: "{{ item.dest }}"
state: link
force: yes
loop:
- { src: vimrc, dest: ~/.config/vim/vimrc }
- { src: plug.vim, dest: ~/.config/vim/autoload/plug.vim }
- name: vim | install plugins
shell: vim -es -u ~/.config/vim/vimrc +PlugInstall +qall