Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
frankenstein91 committed Apr 24, 2021
2 parents e0741f5 + 1646429 commit 0ff91cb
Show file tree
Hide file tree
Showing 19 changed files with 369 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Documentation:
- Documentation/**/*
- readme.md

role/arch2disk:
- roles/arch2disk/**
role/pipewire:
- roles/pipewire/**

# More specific task file changes
feature/boot_setup:
- roles/arch2disk/tasks/boot_setup.yml
Expand Down
70 changes: 70 additions & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,73 @@
- hosts: all
roles:
- arch2disk
- pipewire
- gnome_shell
- multimedia
tasks:
# These things would not make sense in separate roles...
# Some not even in separate taskfiles...
- include_tasks: tasks/wallpaper.yml
- include_tasks: tasks/cups.yml
tags:
- cups
- name: Install JRE (OpenJDK)
# Install explicitely to prevent pacman from asking which java to install
pacman:
state: present
name: jre-openjdk
- name: Install applications
aur:
state: present
use: pikaur
name:
- seahorse
- qalculate-gtk
- geogebra
- evince
- geany
- geany-plugins
- geany-themes
- gnome-terminal
- glances
- firefox
- firefox-ublock-origin
- gimp
- gimp-plugin-gmic
- libreoffice-fresh
- libreoffice-extension-languagetool
- hunspell
- hyphen
- libmythes
tags:
- applications
- include_tasks: tasks/kara.yml
tags:
- kara
- applications
- name: Find out language if not set
set_fact:
locales:
- "{{ lookup('env', 'LANG') }}"
when: locales|default('', true)|length == 0
tags:
- language_packages
- applications
- name: Install language packages
include_tasks:
file: tasks/try-install.yml
apply:
tags:
- language_packages
vars:
lang: "{{ locales[0].split('_')[0] }}"
loop:
- "firefox-i18n-{{ lang }}"
- "libreoffice-fresh-{{ lang }}"
- "hunspell-{{ lang }}"
- "hyphen-{{ lang }}"
- "mythes-{{ lang }}"
- "gimp-help-{{ lang }}"
tags:
- language_packages
- applications
4 changes: 3 additions & 1 deletion roles/arch2disk/tasks/boot_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
dest: /mnt/etc/mkinitcpio.conf
regexp: ^HOOKS
line: HOOKS=(base systemd autodetect modconf block filesystems keyboard sd-vconsole btrfs)
register: mkinitcpio_hooks_adjust
tags:
- initramfs

- name: Re-generate initframfs
- name: Re-generate initframfs # noqa no-handler
command: arch-chroot /mnt mkinitcpio -p linux
when: mkinitcpio_hooks_adjust.changed
tags:
- initramfs

Expand Down
3 changes: 1 addition & 2 deletions roles/arch2disk/tasks/bootloader/systemd-boot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- name: Install systemd-boot
command: arch-chroot /mnt bootctl install
# TODO add creates arg for the systemd-bootx64.efi this will create

# We let sytemd-boot load the linux kernel from the efi partition
# That way we avoid lots of problems
Expand Down Expand Up @@ -39,5 +40,3 @@
mode: 0644
group: root
owner: root

# TODO add the AUR package that includes the bootctl update pacman hook
9 changes: 6 additions & 3 deletions roles/arch2disk/tasks/derive_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- name: Verify UEFI boot mode
fail:
msg: System is required to boot with efi
when: efivars_stat.stat.exists == False
when: not efivars_stat.stat.exists
tags:
- arch2disk
- efi_vars_check
Expand Down Expand Up @@ -91,7 +91,7 @@

# Hostname ....................................................................

- name: Generate default hostname if not set
- name: Generate default hostname if not set # noqa risky-shell-pipe
shell: cat /sys/class/net/*/address | sha512sum | head -c 10
when: hostname | default('', true) | length == 0
register: default_hostname
Expand All @@ -114,21 +114,24 @@
# TODO maybe this is doable with ansible facts?

# What we do here is to query the route to the control machine (ssh client IP)
- name: Currently used network interface
- name: Currently used network interface # noqa command-instead-of-shell
shell: "ip route get {{ ansible_env.SSH_CONNECTION | regex_search('^([^ ]+) ', '\\1') | first }}"
changed_when: false
register: network_interface
tags:
- arch2disk

# This is needed, because $SSH_CONNECTION does not display the subnet prefix
- name: Get current network address information
command: "ip a"
changed_when: false
register: network_address
tags:
- arch2disk

- name: Get current route
command: "ip r"
changed_when: false
register: network_routes
tags:
- arch2disk
Expand Down
2 changes: 2 additions & 0 deletions roles/arch2disk/tasks/fonts.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
- name: Install fonts needed
command: arch-chroot /mnt pacman -S ttf-joypixels ttf-hannom opendesktop-fonts ttf-liberation wqy-zenhei otf-ipafont noto-fonts noto-fonts-emoji --noconfirm
args:
creates: /usr/share/fonts/noto/*
tags:
- arch2disk
- fonts
6 changes: 4 additions & 2 deletions roles/arch2disk/tasks/localization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

- name: Set timezone
command: arch-chroot /mnt ln -sf /usr/share/zoneinfo/{{ timezone }} /etc/localtime
args:
creates: /etc/localtime
tags:
- set_time

- name: Set hardware clock
- name: Set hardware clock # noqa no-changed-when
command: arch-chroot /mnt hwclock --systohc
tags:
- set_time
Expand All @@ -20,7 +22,7 @@
tags:
- locales

- name: Generate locales, step 2/2
- name: Generate locales, step 2/2 # noqa no-changed-when
command: arch-chroot /mnt locale-gen
tags:
- locales
Expand Down
41 changes: 25 additions & 16 deletions roles/arch2disk/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- boot_check
- quick_exit

- name: Synchronize clock via NTP
- name: Synchronize clock via NTP # noqa no-changed-when
command: timedatectl set-ntp true
tags:
- arch2disk
Expand Down Expand Up @@ -50,7 +50,7 @@

# Would be nice to have a script doing this without a country code
# AUR pkg rate-arch-mirrors takes too long to compile+install...
- name: Use rankmirrors to filter the fastest mirrors that support HTTPS
- name: Use rankmirrors to filter the fastest mirrors that support HTTPS # noqa risky-shell-pipe no-changed-when
shell: >
curl -s "https://archlinux.org/mirrorlist/?protocol=https&use_mirror_status=on&country={{ locale_country|upper }}"
| sed -e 's/^#Server/Server/' -e '/^#/d'
Expand All @@ -72,30 +72,42 @@
efibootmgr efitools
linux linux-firmware sudo
openssh networkmanager
python pyalpm
python pyalpm python-psutil
dosfstools btrfs-progs
--noprogressbar
args:
creates: /mnt/usr/bin/nano # Among others of course...
tags:
- arch2disk
- pacstrap

- name: Install base development tools
- name: Install base development tools # noqa risky-shell-pipe
# pacstrap doesn't like groups
shell: arch-chroot /mnt bash -c "yes '' | pacman -S base-devel --noconfirm"
args:
creates: /mnt/usr/bin/make # One of the things installed...
tags:
- arch2disk
- pacstrap
- base_devel

# I now about the Ansible module to do this
# But that would need about a thousands lines more, and is more error-prone
# TODO this didn't work in test...
- name: Generate fstab
shell: genfstab -U /mnt >> /mnt/etc/fstab
# TODO this task doesn't warrant idempotency
tags:
- arch2disk
- fstab

# Make sure the hook dir exists
- name: Ensure pacman hook dir existance
file:
path: /etc/pacman.d/hooks/
state: directory
tags:
- arch2disk

- name: System localization
include_tasks:
file: localization.yml
Expand All @@ -113,17 +125,6 @@
- arch2disk
- fonts

- name: Install pikaur
# Install pikaur using pikaur
shell: |
cd /tmp
git clone https://github.com/actionless/pikaur.git
cd pikaur
python3 ./pikaur.py -S pikaur --noconfirm
tags:
- arch2disk
- pikaur

- name: Networking
include_tasks:
file: networking.yml
Expand Down Expand Up @@ -163,3 +164,11 @@
- arch2disk
- boot_setup
- reboot

- name: Post reboot tasks
include_tasks:
file: post_reboot.yml
apply:
tags:
- arch2disk
- post_reboot
7 changes: 7 additions & 0 deletions roles/arch2disk/tasks/networking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@
wifi.scan-rand-mac-address=yes
[connection-mac-randomization]
wifi.cloned-mac-address=stable
mode: 0644
owner: root
group: root
tags:
- networkmanager
- wifi

# Enable NetworkManager
- name: Enable NetworkManager
command: arch-chroot /mnt systemctl enable NetworkManager.service
args:
creates: /mnt/etc/systemd/system/multi-user.target.wants/NetworkManager.service
tags:
- networkmanager

Expand All @@ -54,5 +59,7 @@
# Enable SSH server
- name: Enable sshd
command: arch-chroot /mnt systemctl enable sshd
args:
creates: /mnt/etc/systemd/system/multi-user.target.wants/sshd.service
tags:
- sshd
1 change: 1 addition & 0 deletions roles/arch2disk/tasks/partitioning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
umount /mnt
- name: Mount everything
# TODO this task may also have a problem with idempotency
shell: >
mount -o subvol=root,compress-force=zstd:{{ btrfs_compression_level }},space_cache,noatime,X-mount.mkdir,defaults
{{ root_partition }} /mnt
Expand Down
20 changes: 20 additions & 0 deletions roles/arch2disk/tasks/post_reboot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#==============================================================================
# Post-reboot tasks
# These tasks can't run before reboot because of various reasons
#==============================================================================

- name: Install pikaur
# Install pikaur using pikaur
shell: |
cd /tmp
git clone https://github.com/actionless/pikaur.git
cd pikaur
python3 ./pikaur.py -S pikaur --noconfirm
args:
creates: /usr/bin/pikaur

- name: Install systemd-boot update transaction hook
aur:
name: systemd-boot-pacman-hook
use: pikaur
when: bootloader=="systemd-boot"
5 changes: 4 additions & 1 deletion roles/arch2disk/tasks/user_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
tags:
- root_passwd

- name: Set root password
- name: Set root password # noqa risky-shell-pipe no-changed-when
shell: echo "root:{{ rootpasswd }}" | chpasswd
tags:
- root_passwd
Expand Down Expand Up @@ -56,5 +56,8 @@
copy:
content: "%wheel ALL=(ALL) NOPASSWD: ALL"
dest: /mnt/etc/sudoers.d/wheel
mode: 0600
owner: root
group: root
tags:
- sudo
39 changes: 39 additions & 0 deletions roles/gnome_shell/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
###############################################################################
# Install Gnome shell on wayland
###############################################################################

- name: Install wayland, gnome-shell and gdm
pacman:
name:
- wayland
- gdm
- gnome-shell
tags:
- gnome_shell

- name: Disable gnome xsession
command: mv /usr/share/xsessions/gnome.desktop /usr/share/xsessions/gnome.desktop.disabled
args:
removes: /usr/share/xsessions/gnome.desktop
tags:
- gnome_shell

- name: Enable and start gdm
systemd:
name: gdm
state: started
enabled: yes
tags:
- gnome_shell

- name: Install useful gnome desktop applications
pacman:
name:
- gnome-shell-extension-appindicator
- xdg-desktop-portal-gtk
- xdg-user-dirs
- nautilus
- nautilus-sendto
tags:
- gnome_shell
- apps
Loading

0 comments on commit 0ff91cb

Please sign in to comment.