ansible: improve setup.yml playbook, formatting

pull/6/head
bretello 2022-01-12 10:06:54 +01:00
parent 4bf6198638
commit 66ca1af8b7
Signed by: brethil
GPG Key ID: 876AAC6290170FE7
2 changed files with 29 additions and 23 deletions

View File

@ -4,26 +4,26 @@
vars_files:
- ../ansible-packages.yml
vars:
DOTFILES: "$HOME/.dotfiles"
DOTFILES: '$HOME/.dotfiles'
tasks:
- name: Install required system packages (debian)
apt:
install_recommends: no
update_cache: yes
pkg: "{{ packages + packages_debian }}"
pkg: '{{ packages + packages_debian }}'
when: ansible_facts['os_family'] == "Debian"
- name: Install required system packages (debian)
pacman:
update_cache: yes
name: "{{ packages + packages_archlinux }}"
name: '{{ packages + packages_archlinux }}'
when: ansible_facts['os_family'] == "Archlinux"
- name: dotfiles repo
git:
repo: https://git.decapod.one/brethil/dotfiles
dest: "{{ DOTFILES }}"
dest: '{{ DOTFILES }}'
version: master
when: local_development is not defined
@ -38,7 +38,7 @@
- name: zsh as default shell
user:
name: "{{ ansible_user }}"
name: '{{ ansible_user }}'
shell: /usr/bin/zsh
- name: zsh config
@ -46,21 +46,21 @@
echo "export DOTFILES={{ DOTFILES }}" >> "$HOME/.zshrc"
echo 'source $DOTFILES/brethil_dotfile.sh' >> "$HOME/.zshrc"
args:
creates: "~{{ ansible_user }}/.zshrc"
creates: '~{{ ansible_user }}/.zshrc'
- name: dotfiles symlink
file:
src: "{{ DOTFILES }}/{{ item.key }}"
dest: "{{ item.value }}"
src: '{{ DOTFILES }}/{{ item.key }}'
dest: '{{ item.value }}'
state: link
force: yes
loop: "{{ files | dict2items }}"
loop: '{{ files | dict2items }}'
vars:
files:
"vim/vimrc": "~/.vimrc"
"pdbrc.py": "~/.pdbrc.py"
'vim/vimrc': '~/.vimrc'
'pdbrc.py': '~/.pdbrc.py'
# "ipython": "~/.ipython" # FIXME: ipython config is more complex
"ansible/ansible.cfg": "~/.ansible.cfg"
'ansible/ansible.cfg': '~/.ansible.cfg'
- name: check undodir_migration
stat: path=${HOME}/.vim_runtime/temp_dirs/undodir
@ -71,20 +71,21 @@
when: undodir.stat.exists
- name: vim plugins install
command: DOTFILES={{ DOTFILES }} vim -c 'PlugInstall|qa!'
# Open vim once so that the plugins are installed
command: echo | env DOTFILES={{ DOTFILES }} vim
- name: git config facts
community.general.git_config:
name: "include.path"
name: 'include.path'
scope: global
register: config_value
- debug:
msg: "Git config include.path={{ config_value }}"
msg: 'Git config include.path={{ config_value }}'
- name: git config
community.general.git_config:
name: "include.path"
value: "{{ DOTFILES }}/gitconfig"
name: 'include.path'
value: '{{ DOTFILES }}/gitconfig'
scope: global
when: config_value is not defined
@ -94,7 +95,7 @@
dest: ~/.gitignore
owner: root
group: root
mode: "0600"
mode: '0600'
backup: yes
- name: annoyances
@ -112,12 +113,12 @@
- name: directories
file:
dest: "{{ item }}"
dest: '{{ item }}'
state: directory
mode: 0700
loop: "{{ directories }}"
loop: '{{ directories }}'
vars:
directories:
- "$HOME/bin"
- "$HOME/projects"
- "$HOME/git"
- '$HOME/bin'
- '$HOME/projects'
- '$HOME/git'

View File

@ -79,3 +79,8 @@ if isdirectory(vim_razer)
Plug vim_razer
endif
call plug#end()
" Install plugins if missing
if ! isdirectory(expand('~/.vim/vim-plug'))
PlugInstall
endif