From 0df8312cfc30493cb8acb4c946e2f9b6cacfacc5 Mon Sep 17 00:00:00 2001 From: mg Date: Mon, 7 Jun 2021 08:40:01 +0200 Subject: [PATCH] laptop eingebaut (#105) inv vm-test2 bugfix reboot invfentory vim polybar gruppe polybar i3 vim extra programme eigenes playbook inventar Co-authored-by: Michael Grote Reviewed-on: https://git.mgrote.net/mg/ansible/pulls/105 Co-Authored-By: mg Co-Committed-By: mg --- group_vars/laptop.yml | 9 +++++++ inventory | 5 +++- playbooks/base/0_master.yml | 1 + playbooks/base/1_bootstrap.yml | 17 ++++++------ playbooks/base/83_vim.yml | 4 +++ playbooks/laptop/0_master.yml | 16 +++++++++++ playbooks/laptop/i3.yml | 4 +++ playbooks/laptop/polybar.yml | 4 +++ roles/mgrote.i3/tasks/main.yml | 10 +++++++ roles/mgrote.polybar/tasks/main.yml | 41 +++++++++++++++++++++++++++++ roles/mgrote.vim/tasks/main.yml | 34 ++++++++++++++++++++++++ 11 files changed, 136 insertions(+), 9 deletions(-) create mode 100644 playbooks/base/83_vim.yml create mode 100644 playbooks/laptop/0_master.yml create mode 100644 playbooks/laptop/i3.yml create mode 100644 playbooks/laptop/polybar.yml create mode 100644 roles/mgrote.i3/tasks/main.yml create mode 100644 roles/mgrote.polybar/tasks/main.yml create mode 100644 roles/mgrote.vim/tasks/main.yml diff --git a/group_vars/laptop.yml b/group_vars/laptop.yml index c96714fa..a4e7f044 100644 --- a/group_vars/laptop.yml +++ b/group_vars/laptop.yml @@ -17,3 +17,12 @@ - path: /home/mg/.config/i3 - path: /home/mg/.config/polybar dotfiles_owner: mg + ### mgrote.apt_install_packages + programs_extra: + - ifupdown2 + - bmon + - hddtemp + - s-tui + - smartmontools + - lm-sensors + - ethtool diff --git a/inventory b/inventory index 5be6053e..f36858e0 100644 --- a/inventory +++ b/inventory @@ -4,6 +4,9 @@ all: hosts: dokuwiki2.grote.lan: dokuwiki-test.grote.lan: + laptop: + hosts: + irantu.grote.lan: fileserver: hosts: fileserver2.grote.lan: @@ -77,7 +80,7 @@ all: acng-test.grote.lan: ansible-test.grote.lan: docker-test.grote.lan: - vm-test.grote.lan: + vm-test2.grote.lan: pve2-test.grote.lan: pve3-test.grote.lan: pve4-test.grote.lan: diff --git a/playbooks/base/0_master.yml b/playbooks/base/0_master.yml index 18fb004a..2a2517e0 100644 --- a/playbooks/base/0_master.yml +++ b/playbooks/base/0_master.yml @@ -10,6 +10,7 @@ - import_playbook: 90_tmux.yml - import_playbook: 91_motd.yml - import_playbook: 92_dotfiles.yml + - import_playbook: 83_vim.yml - import_playbook: 93_postfix.yml - import_playbook: 94_ufw.yml - import_playbook: 95_ssh_pass_login.yml diff --git a/playbooks/base/1_bootstrap.yml b/playbooks/base/1_bootstrap.yml index ffb39e59..827fb6e8 100644 --- a/playbooks/base/1_bootstrap.yml +++ b/playbooks/base/1_bootstrap.yml @@ -10,7 +10,14 @@ - name: reboot für qemu-guest-agent (dauert bis zu 2min!) become: true reboot: - reboot_timeout: 120 + reboot_timeout: 120 + - name: Change user password + become: true + user: + name: mg + update_password: always + password: "{{ lookup('keepass', 'mg_linux_password_hash', 'password') }}" + vars: ### reobertdebock.bootstrap bootstrap_user: mg @@ -22,12 +29,6 @@ ansible_become_password: hallowelt ansible_ssh_common_args: "'-o StrictHostKeyChecking=no'" - tasks: - - name: Change user password - become: true - user: - name: mg - update_password: always - password: "{{ lookup('keepass', 'mg_linux_password_hash', 'password') }}" + # Nach dem ersten durchlaufen ist keine Anmeldung mehr per Passwort & ssh möglich. Damit scheitert auch der Versuch das Playbook ein zweites mal durchlaufen zu lassen. diff --git a/playbooks/base/83_vim.yml b/playbooks/base/83_vim.yml new file mode 100644 index 00000000..e9f821e3 --- /dev/null +++ b/playbooks/base/83_vim.yml @@ -0,0 +1,4 @@ +--- + - hosts: all + roles: + - { role: mgrote.vim, tags: "vim", become: true } diff --git a/playbooks/laptop/0_master.yml b/playbooks/laptop/0_master.yml new file mode 100644 index 00000000..499397fe --- /dev/null +++ b/playbooks/laptop/0_master.yml @@ -0,0 +1,16 @@ +--- + - hosts: laptop + gather_facts: false + - import_playbook: ../base/85_install_packages.yml + - import_playbook: ../base/88_restic.yml + - import_playbook: ../base/89_users.yml + - import_playbook: ../base/90_tmux.yml + - import_playbook: ../base/91_motd.yml + - import_playbook: ../base/92_dotfiles.yml + - import_playbook: ../base/93_postfix.yml + - import_playbook: ../base/94_ufw.yml + - import_playbook: ../base/95_ssh_pass_login.yml + - import_playbook: ../base/96_f2b.yml + - import_playbook: ../base/83_vim.yml + - import_playbook: i3.yml + - import_playbook: polybar.yml diff --git a/playbooks/laptop/i3.yml b/playbooks/laptop/i3.yml new file mode 100644 index 00000000..369650ea --- /dev/null +++ b/playbooks/laptop/i3.yml @@ -0,0 +1,4 @@ +--- + - hosts: laptop + roles: + - { role: mgrote.i3, tags: "i3" } diff --git a/playbooks/laptop/polybar.yml b/playbooks/laptop/polybar.yml new file mode 100644 index 00000000..aa857ddb --- /dev/null +++ b/playbooks/laptop/polybar.yml @@ -0,0 +1,4 @@ +--- + - hosts: laptop + roles: + - { role: mgrote.polybar, tags: "polybar" } diff --git a/roles/mgrote.i3/tasks/main.yml b/roles/mgrote.i3/tasks/main.yml new file mode 100644 index 00000000..d9f9f80f --- /dev/null +++ b/roles/mgrote.i3/tasks/main.yml @@ -0,0 +1,10 @@ +--- + - name: install packages + become: yes + ansible.builtin.package: + name: + - i3 + - i3lock + - xrandr + - arandr + state: present diff --git a/roles/mgrote.polybar/tasks/main.yml b/roles/mgrote.polybar/tasks/main.yml new file mode 100644 index 00000000..ea7d74ca --- /dev/null +++ b/roles/mgrote.polybar/tasks/main.yml @@ -0,0 +1,41 @@ +--- + - name: install packages + become: yes + ansible.builtin.package: + name: + - polybar + state: present + + - name: checkout siji font + ansible.builtin.git: + repo: https://github.com/stark/siji + dest: /home/mg/siji + register: gitcheckout + + - name: install siji-font + ansible.builtin.shell: /home/mg/siji/install.sh -d /home/mg/.fonts + args: + creates: /home/mg/.fonts + when: gitcheckout.changed + + - name: remove bitmap-file + ansible.builtin.file: + path: /etc/fonts/conf.d/70-no-bitmaps.conf + state: absent + when: gitcheckout.changed + register: rmbitmap + + - name: update fc-cache + ansible.builtin.shell: fc-cache + when: gitcheckout.rmbitmap + + - name: add user polybar to group video + # https://github.com/polybar/polybar/wiki/Module:-backlight + ansible.builtin.user: + name: polybar + group: video + + - name: change permission for /sys/class/backlight/ + ansible.builtin.file: + path: /sys/class/backlight/ + mode: '0666' diff --git a/roles/mgrote.vim/tasks/main.yml b/roles/mgrote.vim/tasks/main.yml new file mode 100644 index 00000000..c336e34d --- /dev/null +++ b/roles/mgrote.vim/tasks/main.yml @@ -0,0 +1,34 @@ +--- + - name: install packages + become: yes + ansible.builtin.package: + name: + - vim + - ripgrep + state: present + + - name: check if vundle is installed - folder + become: yes + stat: + path: "/home/mg/.vim/bundle/Vundle.vim" + register: folder_exists + + - name: Ensure repository is cloned locally. + git: + repo: https://github.com/VundleVim/Vundle.vim.git + dest: /home/mg/.vim/bundle/Vundle.vim + depth: 1 + + - name: set owner recursive for repo + file: + path: /home/mg/.vim + owner: mg + group: mg + recurse: yes + + - name: Vundle - PluginInstall + ansible.builtin.shell: yes | vim -c PluginInstall -c qall + args: + chdir: /home/mg + become_user: mg + # when: (folder_exists.stat.exists == False)