Add tags for components and Makefile targets

This commit is contained in:
2020-03-03 17:31:48 +01:00
parent 458a41084e
commit 33244c9726
3 changed files with 254 additions and 263 deletions

View File

@@ -3,10 +3,23 @@ requirements = requirements.txt
activate = . $(venv)/bin/activate activate = . $(venv)/bin/activate
pip = pip pip = pip
ansible = venv/bin/ansible-playbook ansible = venv/bin/ansible-playbook
ansible_run = $(activate) && ansible-playbook --inventory localhost, --diff --verbose ./playbook.yml
.PHONY: all .PHONY: all
install: $(ansible) install: $(ansible)
$(activate) && ansible-playbook --inventory localhost, --diff --verbose ./playbook.yml $(ansible_run)
.PHONY: update
update: $(ansible)
$(ansible_run) --tags update_system
.PHONY: packages
packages: $(ansible)
$(ansible_run) --tags packages
.PHONY: dotfiles
dotfiles: $(ansible)
$(ansible_run) --tags dotfiles
.PHONY: clean .PHONY: clean
clean: clean:

View File

@@ -58,6 +58,7 @@
become: true become: true
when: distro == 'fedora' when: distro == 'fedora'
- block:
- name: load package list - name: load package list
include_vars: include_vars:
file: packages.yml file: packages.yml
@@ -86,6 +87,7 @@
become: true become: true
vars: vars:
query: "{{ 'list.*.%s[]'|format(distro) }}" query: "{{ 'list.*.%s[]'|format(distro) }}"
tags: [packages]
- set_fact: - set_fact:
disable_services: disable_services:
@@ -184,3 +186,5 @@
with_items: "{{ users }}" with_items: "{{ users }}"
loop_control: loop_control:
loop_var: user loop_var: user
tags:
- always

View File

@@ -25,6 +25,7 @@
- docker - docker
- libvirt - libvirt
when: distro == 'ubuntu' when: distro == 'ubuntu'
tags: [always]
- set_fact: - set_fact:
user_groups: user_groups:
@@ -34,9 +35,11 @@
- wireshark - wireshark
- docker - docker
when: distro == 'fedora' when: distro == 'fedora'
tags: [always]
- set_fact: - set_fact:
user_group_name: "{{ user.group|default(user.name) }}" user_group_name: "{{ user.group|default(user.name) }}"
tags: [always]
- name: create user group - name: create user group
group: group:
@@ -75,39 +78,32 @@
become: true become: true
become_user: root become_user: root
- name: load dotfile list - block:
- name: load dotfile list
include_vars: include_vars:
file: dotfiles.yml file: dotfiles.yml
tags:
- dotfiles
- name: get state of empty directories - name: get state of empty directories
stat: stat:
path: ~/{{ item.name }} path: ~/{{ item.name }}
register: empty_dir_stat register: empty_dir_stat
with_items: "{{ empty_directories }}" with_items: "{{ empty_directories }}"
tags:
- dotfiles
- name: remove sysmlinks - name: remove sysmlinks
file: file:
path: "{{ item.stat.path }}" path: "{{ item.stat.path }}"
state: absent state: absent
when: item.stat.exists and item.stat.islnk when: item.stat.exists and item.stat.islnk
with_items: "{{ empty_dir_stat.results }}" with_items: "{{ empty_dir_stat.results }}"
tags:
- dotfiles
- name: create empty directories for dotfiles - name: create empty directories for dotfiles
file: file:
state: directory state: directory
path: ~/{{ item.name }} path: ~/{{ item.name }}
mode: "{{ item.mode | default('0755') }}" mode: "{{ item.mode | default('0755') }}"
with_items: "{{ empty_directories }}" with_items: "{{ empty_directories }}"
tags:
- dotfiles
- name: link this folder to ~/.dotfiles - name: link this folder to ~/.dotfiles
file: file:
state: link state: link
force: true force: true
@@ -116,21 +112,17 @@
group: "{{ user_group_name }}" group: "{{ user_group_name }}"
path: "/home/{{ user.name }}/.dotfiles" path: "/home/{{ user.name }}/.dotfiles"
src: "{{ playbook_dir }}" src: "{{ playbook_dir }}"
tags:
- dotfiles
become: true become: true
become_user: root become_user: root
- name: get state of copy targets - name: get state of copy targets
stat: stat:
path: ~/{{ item.to }} path: ~/{{ item.to }}
register: copy_stat register: copy_stat
when: not item.template|default(false) when: not item.template|default(false)
with_items: "{{ dotfiles }}" with_items: "{{ dotfiles }}"
tags:
- dotfiles
- name: remove invalid copy target (directories) - name: remove invalid copy target (directories)
file: file:
path: "{{ item.stat.path }}" path: "{{ item.stat.path }}"
state: absent state: absent
@@ -139,10 +131,8 @@
- item.stat.exists - item.stat.exists
- item.stat.isdir - item.stat.isdir
with_items: "{{ copy_stat.results }}" with_items: "{{ copy_stat.results }}"
tags:
- dotfiles
- name: link dotfiles - name: link dotfiles
file: file:
state: link state: link
force: true force: true
@@ -156,19 +146,15 @@
with_items: "{{ dotfiles }}" with_items: "{{ dotfiles }}"
become: true become: true
become_user: root become_user: root
tags:
- dotfiles
- name: get state of template targets - name: get state of template targets
stat: stat:
path: ~/{{ item.to }} path: ~/{{ item.to }}
register: template_stat register: template_stat
when: item.template|default(false) when: item.template|default(false)
with_items: "{{ dotfiles }}" with_items: "{{ dotfiles }}"
tags:
- dotfiles
- name: remove invalid template target (directory or symlink) - name: remove invalid template target (directory or symlink)
file: file:
path: "{{ item.stat.path }}" path: "{{ item.stat.path }}"
state: absent state: absent
@@ -177,10 +163,8 @@
- item.stat.exists - item.stat.exists
- not item.stat.isreg - not item.stat.isreg
with_items: "{{ template_stat.results }}" with_items: "{{ template_stat.results }}"
tags:
- dotfiles
- name: deploy dotfiles templates - name: deploy dotfiles templates
template: template:
src: /home/{{ user.name }}/.dotfiles/{{ item.from }}.j2 src: /home/{{ user.name }}/.dotfiles/{{ item.from }}.j2
dest: "/home/{{ user.name }}/{{ item.to }}" dest: "/home/{{ user.name }}/{{ item.to }}"
@@ -191,10 +175,8 @@
become_user: root become_user: root
when: item.template|default(false) when: item.template|default(false)
with_items: "{{ dotfiles }}" with_items: "{{ dotfiles }}"
tags:
- dotfiles
- name: create directories - name: create directories
file: file:
state: directory state: directory
path: "{{ item }}" path: "{{ item }}"
@@ -204,31 +186,28 @@
- ~/.var/run - ~/.var/run
- ~/.usr/lib - ~/.usr/lib
- name: stat ~/bin - name: stat ~/bin
stat: stat:
path: "/home/{{ user.name }}/bin" path: "/home/{{ user.name }}/bin"
register: bin_stat register: bin_stat
tags: [bin]
- name: remove ~/bin if not a link - name: remove ~/bin if not a link
file: file:
state: absent state: absent
path: "/home/{{ user.name }}/bin" path: "/home/{{ user.name }}/bin"
when: when:
- bin_stat.stat.exists - bin_stat.stat.exists
- not bin_stat.stat.islnk - not bin_stat.stat.islnk
tags: [bin]
- name: create ~/.opt and ~/.optbin - name: create ~/.opt and ~/.optbin
file: file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
with_items: with_items:
- ~/.opt/ - ~/.opt/
- ~/.optbin/ - ~/.optbin/
tags: [bin]
- name: symlink opt programs - name: symlink opt programs
file: file:
state: link state: link
force: true force: true
@@ -246,9 +225,8 @@
optpath: hugo optpath: hugo
- name: drone - name: drone
optpath: drone optpath: drone
tags: [bin]
- name: link bin directory - name: link bin directory
file: file:
state: link state: link
force: true force: true
@@ -258,6 +236,8 @@
owner: "{{ user.name }}" owner: "{{ user.name }}"
group: "{{ user_group_name }}" group: "{{ user_group_name }}"
mode: "{{ item.mode | default('0644') }}" mode: "{{ item.mode | default('0644') }}"
tags:
- dotfiles
- name: create intermediate directories for vim-plug - name: create intermediate directories for vim-plug
file: file:
@@ -272,40 +252,34 @@
- ~/.vim/ - ~/.vim/
- ~/.vim/autoload - ~/.vim/autoload
- name: install vim-plug - block:
- name: install vim-plug
get_url: get_url:
dest: ~/.vim/autoload/plug.vim dest: ~/.vim/autoload/plug.vim
url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
tags:
- vim
- name: symlink vim-plug for neovim - name: symlink vim-plug for neovim
file: file:
state: link state: link
path: ~/.local/share/nvim/site/autoload/plug.vim path: ~/.local/share/nvim/site/autoload/plug.vim
src: ~/.vim/autoload/plug.vim src: ~/.vim/autoload/plug.vim
force: true force: true
tags:
- vim
- name: install vim plugins - name: install vim plugins
command: /usr/bin/nvim -f -E -s -c "source ~/.vimrc" +PlugInstall +qall command: /usr/bin/nvim -f -E -s -c "source ~/.vimrc" +PlugInstall +qall
register: vim_plugins_stdout register: vim_plugins_stdout
changed_when: vim_plugins_stdout.stdout_lines|length != 0 changed_when: vim_plugins_stdout.stdout_lines|length != 0
tags:
- vim
- name: compile youcompleteme - name: compile youcompleteme
shell: | shell: |
cd ~/.local/share/nvim/plugged/YouCompleteMe/ cd ~/.local/share/nvim/plugged/YouCompleteMe/
python3 ./install.py # --go-completer python3 ./install.py # --go-completer
args: args:
creates: ~/.local/share/nvim/plugged/YouCompleteMe/third_party/ycmd/ycm_core.so creates: ~/.local/share/nvim/plugged/YouCompleteMe/third_party/ycmd/ycm_core.so
when: vim_plugins_stdout.stdout_lines|length != 0 or true when: vim_plugins_stdout.stdout_lines|length != 0 or true
tags:
- vim
- name: firefox - create chrome directory - block:
- name: firefox - create chrome directory
file: file:
path: ~/.mozilla/firefox/{{ item.name }}/chrome/ path: ~/.mozilla/firefox/{{ item.name }}/chrome/
state: directory state: directory
@@ -315,7 +289,7 @@
tags: tags:
- firefox - firefox
- name: firefox - configure firefox custom css - name: firefox - configure firefox custom css
copy: copy:
dest: ~/.mozilla/firefox/{{ item.name }}/chrome/userChrome.css dest: ~/.mozilla/firefox/{{ item.name }}/chrome/userChrome.css
content: | content: |