diff --git a/README.md b/README.md index ecce272..62475a5 100644 --- a/README.md +++ b/README.md @@ -57,14 +57,14 @@ curl -o PKGBUILD https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=packer- ### Role list -- package-common +- packages-common - screen - ssh-agent - authorized_keys - terminfo - vim - zsh -- package-desktop +- packages-desktop - compton - cursor - gtk @@ -114,7 +114,7 @@ To use dark theme, go to graphical configuration and click ``Use GTK+ Theme`` ### Role list -- package-common +- packages-common - screen - terminfo - vim diff --git a/TODO b/TODO index 7d2df89..3ecca45 100644 --- a/TODO +++ b/TODO @@ -6,6 +6,8 @@ - powerline: check best install method all distrib - zsh: check neon specific alias and others - playbook: update all vagrant specific task to match docker hosts +- playbook: test if tag limit exists +- playbook: for vim and zsh-syntax, change [distribution] tasks to test|include_tasks in by_os # TOFIX @@ -13,6 +15,7 @@ - powerline: not working with centos|debian|freebsd - playbook: add {{ tag }} to fail module to print in "limit to distrib" task - vagrant: tty in qwerty for debian keyboard +- playbook: {{playbook_dir}} -> {{role_path}} # TOTEST diff --git a/roles/packages-common/README.md b/roles/packages-common/README.md new file mode 100644 index 0000000..9281b93 --- /dev/null +++ b/roles/packages-common/README.md @@ -0,0 +1,26 @@ +# Specific OS packages +Add a tasks file named with hostname of target +``` +echo <<\EOF > tasks/by_os//main.yml +--- +- name: Install packages + pacman: name={{item}} state=present + with_items: + - vim + become: True +EOF +``` + +# Specific hosts packages +Add a tasks file named with hostname of target +``` +mkdir tasks/by_host/$(hostname) +echo <<\EOF > tasks/by_host/$(hostname)/main.yml +--- +- name: Install $(hostname) packages + pacman: name={{item}} state=present + with_items: + - vim + become: True +EOF +``` diff --git a/roles/packages-common/tasks/archlinux.yml b/roles/packages-common/tasks/by_os/archlinux/main.yml similarity index 100% rename from roles/packages-common/tasks/archlinux.yml rename to roles/packages-common/tasks/by_os/archlinux/main.yml diff --git a/roles/packages-common/tasks/centos.yml b/roles/packages-common/tasks/by_os/centos/main.yml similarity index 100% rename from roles/packages-common/tasks/centos.yml rename to roles/packages-common/tasks/by_os/centos/main.yml diff --git a/roles/packages-common/tasks/main.yml b/roles/packages-common/tasks/main.yml index cea7c9c..ed0c1fc 100644 --- a/roles/packages-common/tasks/main.yml +++ b/roles/packages-common/tasks/main.yml @@ -6,10 +6,18 @@ - wget become: True -- name: Include CentOS packages [if CentOS] - include_tasks: centos.yml - when: ansible_distribution == "CentOS" +- name: Test host packages file + stat: path="{{ role_path }}/tasks/by_host/{{ ansible_hostname }}/main.yml" + register: host_file -- name: Include Archlinux packages [if Archlinux] - include_tasks: archlinux.yml - when: ansible_os_family == "Archlinux" +- name: Include host packages + include_tasks: "{{ role_path }}/tasks/by_host/{{ ansible_hostname }}/main.yml" + when: host_file.stat.exists + +- name: Test distribution packages file + stat: path="{{ role_path }}/tasks/by_os/{{ ansible_distribution|lower }}/main.yml" + register: distribution_file + +- name: Include distribution packages + include_tasks: "{{ role_path }}/tasks/by_os/{{ ansible_distribution|lower }}/main.yml" + when: distribution_file.stat.exists diff --git a/roles/packages-desktop/README.md b/roles/packages-desktop/README.md index 878863c..5f5ba3e 100644 --- a/roles/packages-desktop/README.md +++ b/roles/packages-desktop/README.md @@ -1,7 +1,21 @@ +# Specific OS packages +Add a tasks file named with hostname of target +``` +echo <<\EOF > tasks/by_os//main.yml +--- +- name: Install packages + pacman: name={{item}} state=present + with_items: + - vim + become: True +EOF +``` + # Specific hosts packages Add a tasks file named with hostname of target ``` -echo <<\EOF > tasks/$(hostname).yml +mkdir tasks/by_host/$(hostname) +echo <<\EOF > tasks/by_host/$(hostname)/main.yml --- - name: Install $(hostname) packages pacman: name={{item}} state=present @@ -10,4 +24,3 @@ echo <<\EOF > tasks/$(hostname).yml become: True EOF ``` - diff --git a/roles/packages-desktop/tasks/arch-itect.yml b/roles/packages-desktop/tasks/by_host/arch-itect/main.yml similarity index 100% rename from roles/packages-desktop/tasks/arch-itect.yml rename to roles/packages-desktop/tasks/by_host/arch-itect/main.yml diff --git a/roles/packages-desktop/tasks/osz.yml b/roles/packages-desktop/tasks/by_host/osz/main.yml similarity index 100% rename from roles/packages-desktop/tasks/osz.yml rename to roles/packages-desktop/tasks/by_host/osz/main.yml diff --git a/roles/packages-desktop/tasks/archlinux.yml b/roles/packages-desktop/tasks/by_os/archlinux/main.yml similarity index 100% rename from roles/packages-desktop/tasks/archlinux.yml rename to roles/packages-desktop/tasks/by_os/archlinux/main.yml diff --git a/roles/packages-desktop/tasks/main.yml b/roles/packages-desktop/tasks/main.yml index 3afb580..39069ba 100644 --- a/roles/packages-desktop/tasks/main.yml +++ b/roles/packages-desktop/tasks/main.yml @@ -15,14 +15,18 @@ - ttf-hack become: True -- name: Include Archlinux tasks [if Archlinux] - include_tasks: archlinux.yml - when: ansible_os_family == "Archlinux" +- name: Test host packages file + stat: path="{{ role_path }}/tasks/by_host/{{ ansible_hostname }}/main.yml" + register: host_file -- name: Test if hostname specific tasks exists - stat: path={{ playbook_dir }}roles/packages-desktop/tasks/{{ ansible_hostname }}.yml - register: hostname_packages_file +- name: Include distribution packages + include_tasks: "{{ role_path }}/tasks/by_host/{{ ansible_hostname }}/main.yml" + when: host_file.stat.exists -- name: Include node tasks [if exists] - include_tasks: "{{ playbook_dir }}roles/packages-desktop/tasks/{{ ansible_hostname }}.yml" - when: hostname_packages_file.stat.exists +- name: Test distribution packages file + stat: path="{{ role_path }}/tasks/by_os/{{ ansible_distribution|lower }}/main.yml" + register: distribution_file + +- name: Include distribution packages + include_tasks: "{{ role_path }}/tasks/by_os/{{ ansible_distribution|lower }}/main.yml" + when: distribution_file.stat.exists diff --git a/roles/polybar/tasks/main.yml b/roles/polybar/tasks/main.yml index 7388238..667c359 100644 --- a/roles/polybar/tasks/main.yml +++ b/roles/polybar/tasks/main.yml @@ -18,15 +18,15 @@ copy: src=files/pkg.sh dest=~/.config/polybar/pkg.sh mode=0755 - name: Test if node specific template exists for launch.sh - stat: path="{{ playbook_dir }}/roles/polybar/templates/by_host/{{ ansible_hostname }}/launch.j2" + stat: path="{{ role_path }}/templates/by_host/{{ ansible_hostname }}/launch.j2" register: launch_file - name: Test if node specific template exists for modules top - stat: path="{{ playbook_dir }}/roles/polybar/templates/by_host/{{ ansible_hostname }}/modules-top.j2" + stat: path="{{ role_path }}/templates/by_host/{{ ansible_hostname }}/modules-top.j2" register: polybar_top_file - name: Test if node specific template exists for modules bottom - stat: path="{{ playbook_dir }}/roles/polybar/templates/by_host/{{ ansible_hostname }}/modules-bottom.j2" + stat: path="{{ role_path }}/templates/by_host/{{ ansible_hostname }}/modules-bottom.j2" register: polybar_bottom_file - name: Template launch file diff --git a/roles/terminfo/tasks/by_os/archlinux/main.yml b/roles/terminfo/tasks/by_os/archlinux/main.yml new file mode 100644 index 0000000..f5147ab --- /dev/null +++ b/roles/terminfo/tasks/by_os/archlinux/main.yml @@ -0,0 +1,4 @@ +--- +- name: Install termite terminfo [Archlinux] + pacman: name=termite-terminfo state=present + become: True diff --git a/roles/terminfo/tasks/by_os/common/main.yml b/roles/terminfo/tasks/by_os/common/main.yml new file mode 100644 index 0000000..aa3c81c --- /dev/null +++ b/roles/terminfo/tasks/by_os/common/main.yml @@ -0,0 +1,8 @@ +--- +- name: Install termite terminfo [Common] + shell: creates={{ item.creates }} {{ item.cmd }} + with_items: + - { creates: '/root/termite.terminfo', cmd: 'wget "https://raw.githubusercontent.com/thestinger/termite/master/termite.terminfo" -O /root/termite.terminfo' } + - { creates: '/root/.termite.terminfo', cmd: 'tic -x /root/termite.terminfo' } + - { creates: '/root/.termite.terminfo', cmd: 'touch /root/.termite.terminfo' } + become: True diff --git a/roles/terminfo/tasks/by_os/freebsd/main.yml b/roles/terminfo/tasks/by_os/freebsd/main.yml new file mode 100644 index 0000000..076bacb --- /dev/null +++ b/roles/terminfo/tasks/by_os/freebsd/main.yml @@ -0,0 +1,10 @@ +--- +- name: Install termite termcap [FreeBSD] + # See: https://unix.stackexchange.com/questions/291412/how-can-i-use-terminfo-entries-on-freebsd + shell: creates=~/.termcap {{item}} + with_items: + - 'chmod 755 /usr/share/misc/termcap' + - 'cat {{ role_path }}/files/termite.termcap >> /usr/share/misc/termcap' + - 'cap_mkdb /usr/share/misc/termcap' + - 'touch ~/.termcap' + become: True diff --git a/roles/terminfo/tasks/main.yml b/roles/terminfo/tasks/main.yml index 8a513ce..74b31d3 100644 --- a/roles/terminfo/tasks/main.yml +++ b/roles/terminfo/tasks/main.yml @@ -1,25 +1,12 @@ --- -- name: Install termite termcap [FreeBSD] - # See: https://unix.stackexchange.com/questions/291412/how-can-i-use-terminfo-entries-on-freebsd - shell: creates=~/.termcap {{item}} - with_items: - - 'chmod 755 /usr/share/misc/termcap' - - 'cat {{ playbook_dir }}/roles/terminfo/files/termite.termcap >> /usr/share/misc/termcap' - - 'cap_mkdb /usr/share/misc/termcap' - - 'touch ~/.termcap' - become: True - when: ansible_os_family == "FreeBSD" +- name: Test distribution packages file + stat: path="{{ role_path }}/tasks/by_os/{{ ansible_distribution|lower }}/main.yml" + register: distribution_file -- name: Install termite terminfo [Archlinux] - pacman: name=termite-terminfo state=present - become: True - when: ansible_os_family == "Archlinux" +- name: Include distribution packages + include_tasks: "{{ role_path }}/tasks/by_os/{{ ansible_distribution|lower }}/main.yml" + when: distribution_file.stat.exists -- name: Install termite terminfo [Common] - shell: creates={{ item.creates }} {{ item.cmd }} - with_items: - - { creates: '/root/termite.terminfo', cmd: 'wget "https://raw.githubusercontent.com/thestinger/termite/master/termite.terminfo" -O /root/termite.terminfo' } - - { creates: '/root/.termite.terminfo', cmd: 'tic -x /root/termite.terminfo' } - - { creates: '/root/.termite.terminfo', cmd: 'touch /root/.termite.terminfo' } - become: True - when: ansible_os_family != "Archlinux" and ansible_os_family != "FreeBSD" +- name: Include common packages + include_tasks: "{{ role_path }}/tasks/by_os/common/main.yml" + when: not distribution_file.stat.exists