2020-04-11 14:07:51 +02:00
|
|
|
- name: configure system
|
|
|
|
|
hosts: localhost
|
2018-02-05 20:09:05 +01:00
|
|
|
connection: local
|
|
|
|
|
become: false
|
|
|
|
|
tasks:
|
2018-08-17 19:44:31 +02:00
|
|
|
- name: read machine-specific variables
|
|
|
|
|
include_vars:
|
|
|
|
|
file: _machines/{{ ansible_hostname }}.yml
|
|
|
|
|
name: machine
|
|
|
|
|
tags:
|
|
|
|
|
- always
|
|
|
|
|
|
2018-02-08 21:45:02 +01:00
|
|
|
- set_fact:
|
|
|
|
|
distro: "{{ ansible_distribution|lower }}"
|
2018-08-17 19:44:31 +02:00
|
|
|
tags:
|
|
|
|
|
- always
|
2018-02-08 21:45:02 +01:00
|
|
|
|
2021-10-06 21:21:09 +02:00
|
|
|
- name: check for valid distro
|
2020-03-02 11:52:45 +01:00
|
|
|
assert:
|
2024-04-10 15:57:38 +02:00
|
|
|
that: distro in ('archlinux')
|
2020-03-02 11:52:45 +01:00
|
|
|
|
2024-04-10 15:57:38 +02:00
|
|
|
- block:
|
|
|
|
|
- name: install ansible requirements
|
|
|
|
|
package:
|
|
|
|
|
name: "{{ packages[distro] }}"
|
|
|
|
|
state: present
|
|
|
|
|
become: true
|
|
|
|
|
vars:
|
|
|
|
|
packages:
|
|
|
|
|
archlinux:
|
|
|
|
|
- python-jmespath
|
2020-03-02 11:52:45 +01:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: pacman
|
|
|
|
|
tags:
|
|
|
|
|
- pacman
|
|
|
|
|
block:
|
|
|
|
|
- name: enable multilib repository
|
|
|
|
|
blockinfile:
|
|
|
|
|
path: /etc/pacman.conf
|
|
|
|
|
block: |
|
|
|
|
|
[multilib]
|
|
|
|
|
Include = /etc/pacman.d/mirrorlist
|
|
|
|
|
marker: "# {mark} ANSIBLE MANAGED multilib"
|
|
|
|
|
become: true
|
2022-06-30 20:41:40 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: enable parallel download
|
|
|
|
|
blockinfile:
|
|
|
|
|
path: /etc/pacman.conf
|
|
|
|
|
insertafter: '\[options\]'
|
|
|
|
|
block: |
|
|
|
|
|
ParallelDownloads = 5
|
|
|
|
|
marker: "# {mark} ANSIBLE MANAGED parallel_download"
|
2024-04-10 19:55:21 +02:00
|
|
|
become: true
|
|
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- block:
|
|
|
|
|
- name: upgrade system
|
|
|
|
|
pacman:
|
|
|
|
|
upgrade: true
|
|
|
|
|
update_cache: true
|
|
|
|
|
become: true
|
|
|
|
|
changed_when: false
|
2024-04-10 19:55:21 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
tags: [system-update]
|
2021-08-13 18:53:01 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: install pacman-contrib for paccache
|
|
|
|
|
package:
|
|
|
|
|
name: pacman-contrib
|
|
|
|
|
state: present
|
2020-12-08 22:00:44 +01:00
|
|
|
become: true
|
|
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- block:
|
|
|
|
|
- name: install pacman cache clean service
|
|
|
|
|
copy:
|
|
|
|
|
dest: /etc/systemd/system/pacman-cache-cleanup.service
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: '0644'
|
|
|
|
|
content: |
|
|
|
|
|
[Service]
|
|
|
|
|
Type=oneshot
|
|
|
|
|
ExecStart=/bin/sh -c '/usr/bin/paccache -rk1 && /usr/bin/paccache -ruk0'
|
|
|
|
|
RemainAfterExit=true
|
|
|
|
|
become: true
|
|
|
|
|
|
|
|
|
|
- name: install pacman cache clean timer
|
|
|
|
|
copy:
|
|
|
|
|
dest: /etc/systemd/system/pacman-cache-cleanup.timer
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: '0644'
|
|
|
|
|
content: |
|
|
|
|
|
[Timer]
|
|
|
|
|
OnCalendar=daily
|
2024-05-29 23:20:16 +02:00
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
|
WantedBy=multi-user.target
|
2024-04-26 12:04:12 +02:00
|
|
|
become: true
|
|
|
|
|
|
|
|
|
|
- name: enable pacman cache clean timer
|
|
|
|
|
systemd:
|
|
|
|
|
name: pacman-cache-cleanup.timer
|
|
|
|
|
enabled: true
|
|
|
|
|
state: started
|
|
|
|
|
daemon_reload: true
|
|
|
|
|
become: true
|
|
|
|
|
|
|
|
|
|
- name: dotfiles directory
|
|
|
|
|
tags:
|
|
|
|
|
- dotfiles-directory
|
|
|
|
|
block:
|
|
|
|
|
- name: create dotfiles group
|
|
|
|
|
group:
|
|
|
|
|
name: dotfiles
|
|
|
|
|
state: present
|
2020-12-08 22:00:44 +01:00
|
|
|
become: true
|
2024-04-26 12:04:12 +02:00
|
|
|
become_user: root
|
|
|
|
|
|
|
|
|
|
- name: create dotfiles user
|
|
|
|
|
user:
|
|
|
|
|
name: dotfiles
|
|
|
|
|
group: dotfiles
|
|
|
|
|
home: /var/lib/dotfiles
|
|
|
|
|
create_home: false
|
|
|
|
|
shell: /bin/bash
|
|
|
|
|
system: true
|
2020-12-08 22:00:44 +01:00
|
|
|
become: true
|
2024-04-26 12:04:12 +02:00
|
|
|
become_user: root
|
|
|
|
|
|
|
|
|
|
- name: create dotfiles directory
|
|
|
|
|
file:
|
|
|
|
|
state: directory
|
|
|
|
|
path: /var/lib/dotfiles
|
|
|
|
|
owner: dotfiles
|
|
|
|
|
group: dotfiles
|
|
|
|
|
mode: '0775' # group needs write access!
|
|
|
|
|
become: true
|
|
|
|
|
become_user: root
|
|
|
|
|
|
|
|
|
|
- name: fix permissions for dotfiles directory
|
|
|
|
|
shell: |
|
|
|
|
|
chown --changes --recursive dotfiles:dotfiles .
|
|
|
|
|
chmod --changes --recursive g+rwX .
|
|
|
|
|
args:
|
|
|
|
|
executable: /bin/bash
|
|
|
|
|
chdir: /var/lib/dotfiles
|
|
|
|
|
register: dotfiles_permission_change
|
|
|
|
|
become: true
|
|
|
|
|
become_user: root
|
|
|
|
|
changed_when: dotfiles_permission_change.stdout_lines|length > 0
|
2024-04-20 12:09:28 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: packages
|
|
|
|
|
tags:
|
|
|
|
|
- packages
|
|
|
|
|
block:
|
|
|
|
|
- name: load package list
|
|
|
|
|
include_vars:
|
|
|
|
|
file: packages.yml
|
2024-05-08 11:52:10 +02:00
|
|
|
name: defined_packages
|
2024-04-26 12:04:12 +02:00
|
|
|
|
2024-05-11 10:47:02 +02:00
|
|
|
- name: force-update iptables to iptables-nft on arch
|
|
|
|
|
shell: |
|
|
|
|
|
if ! pacman -Qi iptables | grep '^Name.*iptables-nft' ; then
|
|
|
|
|
# --noconfirm does not cut it
|
|
|
|
|
yes | pacman -S iptables-nft
|
|
|
|
|
exit 100
|
|
|
|
|
fi
|
|
|
|
|
exit 0
|
|
|
|
|
become: true
|
|
|
|
|
register: force_install_iptables
|
|
|
|
|
changed_when: force_install_iptables.rc == 100
|
|
|
|
|
failed_when: force_install_iptables.rc not in (0, 100)
|
|
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- set_fact:
|
2024-05-08 11:52:10 +02:00
|
|
|
distro_packages: "{{ defined_packages|json_query('*.%s'|format(distro)) }}"
|
2024-04-20 12:09:28 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: check list
|
|
|
|
|
assert:
|
|
|
|
|
that: "defined_packages|length == distro_packages|length"
|
2024-04-20 12:09:28 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: install packages
|
|
|
|
|
package:
|
2024-05-08 11:52:10 +02:00
|
|
|
name: "{{ defined_packages|json_query(query) }}"
|
2024-04-26 12:04:12 +02:00
|
|
|
state: present
|
|
|
|
|
become: true
|
|
|
|
|
vars:
|
2024-05-10 17:43:07 +02:00
|
|
|
query: "{{ '*.%s[]'|format(distro) }}"
|
2024-04-26 12:04:12 +02:00
|
|
|
|
2024-05-06 11:18:56 +02:00
|
|
|
- name: remove unconfigured packages
|
|
|
|
|
script:
|
|
|
|
|
cmd: ./remove-unconfigured-packages.sh --noconfirm
|
|
|
|
|
register: unconfigured_packages_cmd
|
|
|
|
|
failed_when: unconfigured_packages_cmd.rc not in (0, 123)
|
|
|
|
|
changed_when: unconfigured_packages_cmd.rc == 123
|
|
|
|
|
become: true
|
|
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: aur
|
|
|
|
|
tags:
|
|
|
|
|
- aur
|
|
|
|
|
block:
|
|
|
|
|
- name: create build user on arch
|
|
|
|
|
user:
|
|
|
|
|
name: makepkg
|
|
|
|
|
home: /var/lib/makepkg
|
|
|
|
|
create_home: true
|
|
|
|
|
shell: /bin/bash
|
|
|
|
|
system: true
|
|
|
|
|
become: true
|
2024-04-20 12:09:28 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- set_fact:
|
|
|
|
|
aur_packages:
|
|
|
|
|
- name: portfolio-performance-bin
|
|
|
|
|
preexec: |
|
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
source ./env
|
|
|
|
|
curl -sSf --proto '=https' https://keys.openpgp.org/vks/v1/by-fingerprint/E46E6F8FF02E4C83569084589239277F560C95AC | gpg --import -
|
2024-04-20 12:09:28 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: spotify
|
|
|
|
|
preexec: |
|
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
source ./env
|
|
|
|
|
curl -sSf --proto '=https' https://download.spotify.com/debian/pubkey_6224F9941A8AA6D1.gpg | gpg --import -
|
2024-04-14 00:06:57 +02:00
|
|
|
|
2024-05-07 18:47:47 +02:00
|
|
|
- name: nodejs-intelephense
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: vim-plug
|
2024-05-04 21:34:03 +02:00
|
|
|
- name: terraform-ls-bin
|
2024-05-07 17:04:00 +02:00
|
|
|
- name: grm-git
|
2024-05-07 18:47:47 +02:00
|
|
|
- name: screencfg-git
|
2024-05-07 17:04:00 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- set_fact:
|
|
|
|
|
aur_packages: "{{ aur_packages|map(attribute='dependencies', default=[]) | flatten + aur_packages }}"
|
2024-04-14 00:06:57 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: install dependencies
|
|
|
|
|
shell: |
|
|
|
|
|
aur_packages=({{ aur_packages | map(attribute='name') | join(' ') }})
|
2024-04-26 11:37:29 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
source pkgbuilds/{{ item.name }}/PKGBUILD
|
2024-04-14 18:43:52 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
installed=0
|
2024-04-14 18:43:52 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
dependencies=(${depends[@]} ${makedepends[@]})
|
|
|
|
|
for dep in "${dependencies[@]}" ; do
|
|
|
|
|
aur=0
|
|
|
|
|
for aur_pkg in "${aur_packages[@]}" ; do
|
|
|
|
|
if [[ "${aur_pkg}" == "${dep}" ]] ; then
|
|
|
|
|
aur=1
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
2024-04-14 18:43:52 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
if (( aur )) ; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
2024-04-14 18:43:52 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
if ! pacman -Qq "${dep}" >/dev/null 2>&1 ; then
|
|
|
|
|
installed=1
|
|
|
|
|
pacman -S --noconfirm --needed "${dep}"
|
2024-04-14 18:43:52 +02:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
if (( installed )) ; then
|
|
|
|
|
exit 123
|
|
|
|
|
else
|
|
|
|
|
exit 0
|
2024-04-14 18:43:52 +02:00
|
|
|
fi
|
2024-04-26 12:04:12 +02:00
|
|
|
args:
|
|
|
|
|
executable: /bin/bash
|
|
|
|
|
register: install_deps
|
|
|
|
|
failed_when: install_deps.rc not in (0, 123)
|
|
|
|
|
changed_when: install_deps.rc == 123
|
|
|
|
|
become: true
|
|
|
|
|
loop: "{{ aur_packages }}"
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item.name }}"
|
|
|
|
|
|
|
|
|
|
- name: create build root directory
|
|
|
|
|
file:
|
|
|
|
|
path: "/var/lib/makepkg/{{ item.name }}/"
|
|
|
|
|
state: directory
|
|
|
|
|
mode: '0700'
|
|
|
|
|
owner: makepkg
|
|
|
|
|
group: makepkg
|
|
|
|
|
become_user: makepkg
|
|
|
|
|
become: true
|
|
|
|
|
loop: "{{ aur_packages }}"
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item.name }}"
|
|
|
|
|
|
|
|
|
|
- name: create build gpg directory
|
|
|
|
|
file:
|
|
|
|
|
path: "/var/lib/makepkg/{{ item.name }}/gnupg"
|
|
|
|
|
state: directory
|
|
|
|
|
mode: '0700'
|
|
|
|
|
owner: makepkg
|
|
|
|
|
group: makepkg
|
|
|
|
|
become_user: makepkg
|
|
|
|
|
become: true
|
|
|
|
|
loop: "{{ aur_packages }}"
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item.name }}"
|
2021-10-03 15:44:48 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: create env file
|
|
|
|
|
copy:
|
|
|
|
|
dest: /var/lib/makepkg/{{ item.name }}/env
|
|
|
|
|
owner: makepkg
|
|
|
|
|
group: makepkg
|
|
|
|
|
mode: "0600"
|
|
|
|
|
content: |
|
|
|
|
|
export GNUPGHOME="/var/lib/makepkg/{{ item.name }}/gnupg"
|
|
|
|
|
become_user: makepkg
|
|
|
|
|
become: true
|
|
|
|
|
loop: "{{ aur_packages }}"
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item.name }}"
|
|
|
|
|
|
|
|
|
|
- name: check preexec script
|
|
|
|
|
stat:
|
|
|
|
|
path: /var/lib/makepkg/{{ item.name }}/preexec
|
|
|
|
|
become_user: makepkg
|
|
|
|
|
become: true
|
|
|
|
|
when: item.preexec is defined
|
|
|
|
|
loop: "{{ aur_packages }}"
|
|
|
|
|
register: preexec_before
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item.name }}"
|
2020-12-09 23:58:24 +01:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: install preexec script
|
|
|
|
|
copy:
|
|
|
|
|
dest: /var/lib/makepkg/{{ item.name }}/preexec
|
|
|
|
|
owner: makepkg
|
|
|
|
|
group: makepkg
|
|
|
|
|
mode: "0700"
|
|
|
|
|
content: "{{ item.preexec }}"
|
|
|
|
|
become_user: makepkg
|
|
|
|
|
become: true
|
|
|
|
|
when: item.preexec is defined
|
|
|
|
|
loop: "{{ aur_packages }}"
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item.name }}"
|
|
|
|
|
|
|
|
|
|
- name: check preexec script
|
|
|
|
|
stat:
|
|
|
|
|
path: /var/lib/makepkg/{{ item.name }}/preexec
|
|
|
|
|
become_user: makepkg
|
|
|
|
|
become: true
|
|
|
|
|
when: item.preexec is defined
|
|
|
|
|
loop: "{{ aur_packages }}"
|
|
|
|
|
register: preexec_after
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item.name }}"
|
|
|
|
|
|
|
|
|
|
- name: run preexec script
|
|
|
|
|
command:
|
|
|
|
|
cmd: "{{ item.1.stat.path }}"
|
|
|
|
|
chdir: "{{ item.1.stat.path | dirname }}"
|
|
|
|
|
become_user: makepkg
|
|
|
|
|
become: true
|
|
|
|
|
when:
|
|
|
|
|
- not item[0].stat.exists
|
|
|
|
|
- item[0].stat.checksum|default('') != item[1].stat.checksum
|
|
|
|
|
loop: "{{ preexec_before.results| reject('skipped')|zip(preexec_after.results| reject('skipped')) }}"
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item.1.stat.path }}"
|
|
|
|
|
|
|
|
|
|
- name: create build script
|
|
|
|
|
copy:
|
|
|
|
|
owner: makepkg
|
|
|
|
|
group: makepkg
|
|
|
|
|
mode: "0700"
|
|
|
|
|
dest: /var/lib/makepkg/{{ item.name }}/build.sh
|
|
|
|
|
content: |
|
|
|
|
|
#!/usr/bin/env bash
|
2024-04-22 15:15:51 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
source /var/lib/makepkg/{{ item.name }}/env
|
2024-04-22 14:01:53 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
export PKGEXT='.pkg.tar'
|
|
|
|
|
export BUILDDIR=/var/lib/makepkg/{{ item.name }}/build/
|
|
|
|
|
export SRCDEST=/var/lib/makepkg/{{ item.name }}/src/
|
|
|
|
|
export PKGDEST=/var/lib/makepkg/{{ item.name }}/
|
2024-04-22 15:15:51 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
cd /var/lib/dotfiles/pkgbuilds/{{ item.name }}/
|
2024-04-14 18:43:52 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
source ./PKGBUILD
|
2024-04-22 14:01:53 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
for arch in "${arch[@]}" ; do
|
|
|
|
|
if [[ "${arch}" == "any" ]] ; then
|
|
|
|
|
arch="any"
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
if [[ "${arch}" == "x86_64" ]] ; then
|
|
|
|
|
arch="x86_64"
|
|
|
|
|
fi
|
|
|
|
|
done
|
2024-04-14 18:43:52 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
if [[ ! "${arch}" ]] ; then
|
2024-05-27 12:36:34 +02:00
|
|
|
printf 'unsupported arch\n' >&2
|
2024-04-26 12:04:12 +02:00
|
|
|
exit 1
|
2024-04-14 18:43:52 +02:00
|
|
|
fi
|
|
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
if [[ "${epoch}" ]] ; then
|
|
|
|
|
version="${epoch}:${pkgver}-${pkgrel}"
|
|
|
|
|
else
|
|
|
|
|
version="${pkgver}-${pkgrel}"
|
|
|
|
|
fi
|
2024-04-22 14:01:53 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
filename="${PKGDEST%/}/${pkgname}-${version}-${arch}${PKGEXT}"
|
2024-04-22 14:01:53 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
needed_build=0
|
|
|
|
|
if [[ ! -e "${filename}" ]] ; then
|
|
|
|
|
needed_build=1
|
|
|
|
|
makepkg \
|
|
|
|
|
--clean \
|
|
|
|
|
--nosign || exit 1
|
|
|
|
|
fi
|
2020-12-09 23:58:24 +01:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
printf '%s' "${filename}" > /var/lib/makepkg/{{ item.name }}/pkgname
|
|
|
|
|
become: true
|
|
|
|
|
become_user: makepkg
|
|
|
|
|
loop: "{{ aur_packages }}"
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item.name }}"
|
2024-04-14 00:06:57 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: create install script
|
|
|
|
|
copy:
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "0700"
|
|
|
|
|
dest: /var/lib/makepkg/{{ item.name }}/install.sh
|
|
|
|
|
content: |
|
|
|
|
|
#!/usr/bin/env bash
|
2020-12-09 23:58:24 +01:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
sudo -u makepkg -g makepkg /var/lib/makepkg/{{ item.name }}/build.sh || exit 1
|
2020-12-09 21:43:57 +01:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
filename="$(</var/lib/makepkg/{{ item.name }}/pkgname)"
|
2020-12-09 21:43:57 +01:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
name=$(pacman -Qi --file "${filename}" | grep '^Name' | awk '{print $3}')
|
|
|
|
|
version=$(pacman -Qi --file "${filename}" | grep '^Version' | awk '{print $3}')
|
2020-12-08 22:00:44 +01:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
if [[ "$(pacman -Q "${name}")" == "${name} ${version}" ]] ; then
|
|
|
|
|
exit 0
|
|
|
|
|
else
|
|
|
|
|
pacman --upgrade --needed --noconfirm "$filename" || exit 1
|
|
|
|
|
exit 123
|
|
|
|
|
fi
|
|
|
|
|
become: true
|
|
|
|
|
loop: "{{ aur_packages }}"
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item.name }}"
|
|
|
|
|
|
|
|
|
|
- name: build and install aur package
|
|
|
|
|
command: /var/lib/makepkg/{{ item.name }}/install.sh
|
|
|
|
|
register: aur_install
|
|
|
|
|
changed_when: aur_install.rc == 123
|
|
|
|
|
failed_when: aur_install.rc not in (0, 123)
|
|
|
|
|
become: true
|
|
|
|
|
loop: "{{ aur_packages }}"
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item.name }}"
|
|
|
|
|
|
|
|
|
|
- name: clean up build leftovers
|
|
|
|
|
file:
|
|
|
|
|
path: /var/lib/makepkg/{{ item[0].name }}/{{ item[1] }}/
|
|
|
|
|
state: absent
|
|
|
|
|
become_user: makepkg
|
|
|
|
|
become: true
|
|
|
|
|
with_nested:
|
|
|
|
|
- "{{ aur_packages }}"
|
|
|
|
|
-
|
|
|
|
|
- build
|
|
|
|
|
- src
|
|
|
|
|
loop_control:
|
|
|
|
|
label: "{{ item[0].name }}/{{ item[1] }}"
|
|
|
|
|
|
|
|
|
|
- name: configure timesyncd on arch
|
|
|
|
|
copy:
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "0644"
|
|
|
|
|
dest: /etc/systemd/timesyncd.conf
|
|
|
|
|
content: |
|
|
|
|
|
[Time]
|
|
|
|
|
NTP=0.arch.pool.ntp.org 1.arch.pool.ntp.org 2.arch.pool.ntp.org 3.arch.pool.ntp.org
|
|
|
|
|
FallbackNTP=0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org
|
|
|
|
|
become: true
|
2019-05-20 21:29:26 +02:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: install lz4
|
|
|
|
|
package:
|
|
|
|
|
name: lz4
|
|
|
|
|
state: present
|
2018-02-09 17:56:43 +01:00
|
|
|
become: true
|
2020-12-08 22:00:44 +01:00
|
|
|
|
2024-04-26 12:04:12 +02:00
|
|
|
- name: use vz4 for mkinitcpio compression
|
|
|
|
|
lineinfile:
|
|
|
|
|
path: /etc/mkinitcpio.conf
|
|
|
|
|
regexp: '^#?COMPRESSION=.*$'
|
|
|
|
|
line: 'COMPRESSION="lz4"'
|
2020-02-23 14:56:14 +01:00
|
|
|
become: true
|
2024-04-26 12:04:12 +02:00
|
|
|
notify:
|
|
|
|
|
- rebuild initrd
|
|
|
|
|
|
|
|
|
|
- name: services
|
|
|
|
|
tags:
|
|
|
|
|
- services
|
|
|
|
|
block:
|
|
|
|
|
- set_fact:
|
|
|
|
|
disable_services:
|
|
|
|
|
- sshd.service
|
|
|
|
|
|
|
|
|
|
- name: disable services
|
|
|
|
|
service:
|
|
|
|
|
state: stopped
|
|
|
|
|
enabled: false
|
|
|
|
|
name: "{{ item }}"
|
|
|
|
|
with_items: "{{ disable_services }}"
|
|
|
|
|
become: true
|
|
|
|
|
when: manage_services|default(true)|bool
|
|
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
|
enable_services:
|
|
|
|
|
- NetworkManager
|
|
|
|
|
- docker
|
|
|
|
|
- libvirtd
|
|
|
|
|
- systemd-timesyncd
|
|
|
|
|
- pcscd
|
|
|
|
|
|
|
|
|
|
- name: enable services
|
|
|
|
|
service:
|
|
|
|
|
state: started
|
|
|
|
|
enabled: true
|
|
|
|
|
name: "{{ item }}"
|
|
|
|
|
with_items: "{{ enable_services }}"
|
|
|
|
|
become: true
|
|
|
|
|
when: manage_services|default(true)|bool
|
2020-02-23 14:56:14 +01:00
|
|
|
|
2018-02-09 17:56:43 +01:00
|
|
|
- name: get systemd boot target
|
|
|
|
|
command: systemctl get-default
|
|
|
|
|
register: systemd_target
|
|
|
|
|
changed_when: false
|
2020-04-01 10:15:58 +02:00
|
|
|
check_mode: false
|
2018-02-09 17:56:43 +01:00
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
|
default_target: multi-user.target
|
|
|
|
|
|
|
|
|
|
- name: set systemd boot target
|
|
|
|
|
command: systemctl set-default {{ default_target }}
|
|
|
|
|
when: systemd_target.stdout != default_target
|
|
|
|
|
become: true
|
|
|
|
|
|
|
|
|
|
- name: handle lid switch
|
|
|
|
|
lineinfile:
|
|
|
|
|
path: /etc/systemd/logind.conf
|
|
|
|
|
regexp: '^HandleLidSwitch='
|
|
|
|
|
line: 'HandleLidSwitch=ignore'
|
|
|
|
|
become: true
|
|
|
|
|
|
|
|
|
|
- name: handle power key
|
|
|
|
|
lineinfile:
|
|
|
|
|
path: /etc/systemd/logind.conf
|
|
|
|
|
regexp: '^HandlePowerKey='
|
|
|
|
|
line: 'HandlePowerKey=suspend'
|
|
|
|
|
become: true
|
|
|
|
|
|
2024-04-14 00:27:09 +02:00
|
|
|
- name: limit journald size
|
|
|
|
|
lineinfile:
|
|
|
|
|
path: /etc/systemd/journald.conf
|
|
|
|
|
regexp: '^#?SystemMaxUse=.*$'
|
|
|
|
|
line: 'SystemMaxUse=50M'
|
|
|
|
|
become: true
|
|
|
|
|
notify:
|
|
|
|
|
- restart journald
|
|
|
|
|
|
2024-04-10 15:57:38 +02:00
|
|
|
- name: create sudonopw group
|
|
|
|
|
group:
|
|
|
|
|
name: sudonopw
|
|
|
|
|
system: true
|
|
|
|
|
|
|
|
|
|
- name: configure passwordless sudo
|
|
|
|
|
copy:
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "0600"
|
|
|
|
|
dest: /etc/sudoers.d/sudonopw
|
|
|
|
|
content: |
|
|
|
|
|
%sudonopw ALL=(ALL) NOPASSWD: ALL
|
|
|
|
|
become: true
|
2020-12-08 22:00:44 +01:00
|
|
|
|
2024-04-20 11:52:43 +02:00
|
|
|
- name: configure passwordless doas
|
|
|
|
|
copy:
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "0400"
|
|
|
|
|
dest: /etc/doas.conf
|
|
|
|
|
content: |
|
|
|
|
|
permit nopass nolog setenv {PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin} :sudonopw
|
|
|
|
|
become: true
|
|
|
|
|
|
2024-05-10 18:52:51 +02:00
|
|
|
- name: hardware-specific configuration
|
2024-05-05 11:55:06 +02:00
|
|
|
tags:
|
2024-05-10 18:52:51 +02:00
|
|
|
- hardware
|
2024-05-05 11:55:06 +02:00
|
|
|
block:
|
2024-05-10 18:52:51 +02:00
|
|
|
- name: read driver variables
|
|
|
|
|
include_vars:
|
|
|
|
|
file: drivers.yml
|
|
|
|
|
name: drivers
|
|
|
|
|
tags:
|
|
|
|
|
- always
|
|
|
|
|
|
|
|
|
|
- name: gpu configuration
|
|
|
|
|
tags:
|
|
|
|
|
- hardware:gpu
|
2024-05-05 11:55:06 +02:00
|
|
|
block:
|
2024-05-10 18:52:51 +02:00
|
|
|
- name: install AMD cpu packages
|
2024-05-05 11:55:06 +02:00
|
|
|
package:
|
2024-05-10 18:52:51 +02:00
|
|
|
name: "{{ drivers.cpu.amd }}"
|
2024-05-05 11:55:06 +02:00
|
|
|
state: present
|
|
|
|
|
become: true
|
2024-05-10 18:52:51 +02:00
|
|
|
when: machine.cpu == 'amd'
|
2024-05-05 11:55:06 +02:00
|
|
|
|
2024-05-10 18:52:51 +02:00
|
|
|
- name: install Intel cpu packages
|
2024-05-05 11:55:06 +02:00
|
|
|
package:
|
2024-05-10 18:52:51 +02:00
|
|
|
name: "{{ drivers.cpu.intel }}"
|
2024-05-05 11:55:06 +02:00
|
|
|
state: present
|
|
|
|
|
become: true
|
2024-05-10 18:52:51 +02:00
|
|
|
when: machine.cpu == 'intel'
|
|
|
|
|
|
|
|
|
|
when:
|
|
|
|
|
- machine.cpu is defined
|
|
|
|
|
|
|
|
|
|
- name: gpu configuration
|
|
|
|
|
tags:
|
|
|
|
|
- hardware:gpu
|
|
|
|
|
block:
|
|
|
|
|
- name: AMD configuration
|
|
|
|
|
when: machine.gpu == 'amd'
|
|
|
|
|
block:
|
|
|
|
|
- name: install AMDGPU packages
|
|
|
|
|
package:
|
|
|
|
|
name: "{{ drivers.gpu.amd }}"
|
|
|
|
|
state: present
|
|
|
|
|
become: true
|
|
|
|
|
|
|
|
|
|
- name: set AMDGPU options
|
|
|
|
|
copy:
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: "0600"
|
|
|
|
|
dest: /etc/X11/xorg.conf.d/20-amdgpu.conf
|
|
|
|
|
content: |
|
|
|
|
|
Section "Device"
|
|
|
|
|
Identifier "AMD"
|
|
|
|
|
Driver "amdgpu"
|
|
|
|
|
Option "VariableRefresh" "true"
|
|
|
|
|
Option "TearFree" "true"
|
|
|
|
|
EndSection
|
|
|
|
|
become: true
|
|
|
|
|
|
|
|
|
|
- name: Nvidia configuration
|
|
|
|
|
when: machine.gpu == 'nvidia'
|
|
|
|
|
block:
|
|
|
|
|
- name: install nouveau packages
|
|
|
|
|
package:
|
2024-05-15 16:52:48 +02:00
|
|
|
name: "{{ drivers.gpu.nvidia }}"
|
2024-05-10 18:52:51 +02:00
|
|
|
state: present
|
|
|
|
|
become: true
|
|
|
|
|
when:
|
|
|
|
|
- machine.gpu is defined
|
2020-12-08 22:00:44 +01:00
|
|
|
|
2019-11-14 09:16:55 +01:00
|
|
|
- set_fact:
|
|
|
|
|
users: "{{ machine.users }}"
|
2018-08-17 21:16:54 +02:00
|
|
|
tags:
|
2019-11-14 09:16:55 +01:00
|
|
|
- always
|
2018-08-17 21:16:54 +02:00
|
|
|
|
2024-04-22 12:08:32 +02:00
|
|
|
# See https://bbs.archlinux.org/viewtopic.php?id=259764
|
|
|
|
|
- block:
|
|
|
|
|
- name: configure pacman to skip installing nextcloud dbus file
|
|
|
|
|
blockinfile:
|
|
|
|
|
path: /etc/pacman.conf
|
|
|
|
|
insertafter: '^#NoExtract'
|
|
|
|
|
block: |
|
|
|
|
|
NoExtract = usr/share/dbus-1/services/com.nextcloudgmbh.Nextcloud.service
|
|
|
|
|
marker: "# {mark} ANSIBLE MANAGED noextract nextcloud"
|
|
|
|
|
become: true
|
|
|
|
|
|
|
|
|
|
- name: remove nextcloud dbus file
|
|
|
|
|
file:
|
|
|
|
|
path: /usr/share/dbus-1/services/com.nextcloudgmbh.Nextcloud.service
|
|
|
|
|
state: absent
|
|
|
|
|
become: true
|
|
|
|
|
|
2024-05-15 16:53:01 +02:00
|
|
|
- name: try to make gpg agent behave
|
|
|
|
|
block:
|
|
|
|
|
- name: configure pacman to skip installing gpg user units
|
|
|
|
|
blockinfile:
|
|
|
|
|
path: /etc/pacman.conf
|
|
|
|
|
insertafter: '^#NoExtract'
|
|
|
|
|
block: |
|
|
|
|
|
NoExtract = usr/lib/systemd/user/gpg-agent*
|
|
|
|
|
marker: "# {mark} ANSIBLE MANAGED noextract gpg-agent"
|
|
|
|
|
become: true
|
|
|
|
|
|
2024-05-03 14:38:37 +02:00
|
|
|
- name: backlight configuration
|
|
|
|
|
tags:
|
|
|
|
|
- backlight
|
|
|
|
|
block:
|
|
|
|
|
# See https://wiki.archlinux.org/title/backlight#ACPI
|
|
|
|
|
- name: create udev rule to allow video group backlight access
|
|
|
|
|
copy:
|
|
|
|
|
dest: /etc/udev/rules.d/backlight.rules
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: '0644'
|
|
|
|
|
content: |
|
|
|
|
|
ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chgrp video $sys$devpath/brightness", RUN+="/bin/chmod g+w $sys$devpath/brightness"
|
|
|
|
|
become: true
|
|
|
|
|
|
2019-11-14 09:16:55 +01:00
|
|
|
- include_tasks: user.yml
|
2018-08-17 21:16:54 +02:00
|
|
|
args:
|
2019-11-14 09:16:55 +01:00
|
|
|
apply:
|
|
|
|
|
become: true
|
|
|
|
|
become_user: "{{ user.name }}"
|
2024-04-26 12:04:12 +02:00
|
|
|
tags:
|
|
|
|
|
- user
|
2019-11-14 09:16:55 +01:00
|
|
|
with_items: "{{ users }}"
|
2021-10-31 13:39:51 +01:00
|
|
|
no_log: True # less spam
|
2019-11-14 09:16:55 +01:00
|
|
|
loop_control:
|
|
|
|
|
loop_var: user
|
2020-03-03 17:31:48 +01:00
|
|
|
tags:
|
|
|
|
|
- always
|
2020-12-09 21:48:20 +01:00
|
|
|
|
|
|
|
|
handlers:
|
|
|
|
|
- name: rebuild initrd
|
|
|
|
|
command: mkinitcpio -P
|
|
|
|
|
become: true
|
2021-10-03 15:25:35 +02:00
|
|
|
register: mkinitcpio_cmd
|
|
|
|
|
failed_when: >
|
|
|
|
|
mkinitcpio_cmd.rc != 0
|
|
|
|
|
and
|
|
|
|
|
not (mkinitcpio_cmd.rc == 1 and "file not found: `fsck.overlay'" in mkinitcpio_cmd.stderr)
|
2024-04-14 00:27:09 +02:00
|
|
|
|
|
|
|
|
- name: restart journald
|
|
|
|
|
service:
|
|
|
|
|
name: systemd-journald
|
|
|
|
|
state: restarted
|
|
|
|
|
become: true
|