Unify everything into one config playbook. Handle some more stuff

This commit is contained in:
exu 2024-10-09 21:40:52 +02:00
parent 9a00a664fe
commit 916b0d41eb
5 changed files with 308 additions and 269 deletions

View File

@ -197,7 +197,6 @@ sudo cp -r "$tempdir/arch-config/etc" /
# Copy pacman config depending on system architecture
# This is required due to differences in available repos between Arch on x86_64 and ALARM for aarch64
# TODO
if [ "$(uname --machine)" == "x86_64" ]; then
sudo cp "/etc/pacman-x86_64.conf" "/etc/pacman.conf"
fi
@ -231,7 +230,6 @@ EOF
systemctl --user daemon-reload
# set systemd services for vmware (only if installed)
# TODO
if [[ $(pacman -Q | grep vmware-workstation) ]]; then
sudo systemctl enable --now vmware-networks.service || echo "Service failed, continuing"
sudo systemctl enable --now vmware-usbarbitrator.service || echo "Service failed, continuing"
@ -247,7 +245,6 @@ fi
sudo systemctl enable fstrim.timer
# enable btrfs maintenance timers
# TODO
if [[ $(pacman -Q | grep btrfsmaintenance) ]]; then
sudo systemctl restart btrfsmaintenance-refresh.service
sudo systemctl enable btrfs-balance.timer
@ -261,7 +258,6 @@ sudo timedatectl set-ntp true
systemctl --user enable --now ssh-agent
# enable reflector timer
# TODO
if [[ $(pacman -Q | grep reflector) ]]; then
sudo systemctl enable reflector.timer
fi
@ -277,7 +273,6 @@ cat <<EOF
EOF
# set systemd and group for vmware (only if installed)
# TODO
if [[ $(pacman -Q | grep vmware-workstation) ]]; then
echo "Setting up group for vmware"
sudo groupadd -f vmware

View File

@ -1,66 +0,0 @@
---
- name: Copy new files and directories
ansible.builtin.copy:
src: "files/{{ item }}"
dest: "~/{{ item }}"
loop:
- ".config"
- ".face"
- ".gitconfig"
- ".gtkrc-2.0"
- ".local"
- ".ssh"
- "scripts"
- name: Copy new files and directories (root)
ansible.builtin.copy:
src: "files/{{ item }}"
dest: "~/{{ item }}"
loop:
- "etc"
become: true
- name: Symlink xdg environment variables
ansible.builtin.file:
src: "~/.config/user-dirs.dirs"
dest: "~/.config/environment.d/user-dirs.dirs.conf"
state: "link"
- name: Download bash cat
ansible.builtin.git:
repo: https://github.com/exu-g/bash-cat-with-cat.git
dest: "/tmp/bash-cat-with-cat"
- name: Copy bash cat to scripts
ansible.builtin.copy:
src: "/tmp/bash-cat-with-cat/cat.sh"
dest: "~/scripts/pieces/cat.sh"
mode: "0755"
- name: Reload user systemd services
ansible.builtin.systemd_service:
daemon_reload: true
- name: Enable fstrim
ansible.builtin.systemd_service:
name: fstrim.timer
state: "started"
enabled: true
become: true
- name: Enable NTP
ansible.builtin.command: timedatectl set-ntp true
become: true
- name: Enable ssh-agent
ansible.builtin.systemd_service:
name: ssh-agent
state: "restarted"
enabled: true
- name: Enable vnstat
ansible.builtin.systemd_service:
name: vnstat
state: "started"
enabled: true
become: true

View File

@ -1,8 +1,143 @@
---
- name: Include tasks from preparation.yml
ansible.builtin.include_tasks:
file: preparation.yml
# - name: Include tasks from preparation.yml
# ansible.builtin.include_tasks:
# file: preparation.yml
- name: Include tasks from copy_new.yml
ansible.builtin.include_tasks:
file: copy_new.yml
- name: Gather the package facts
ansible.builtin.package_facts:
- name: Create backup structure
ansible.builtin.file:
path: "~/old_dat"
state: "directory"
- name: Copy files to backup
ansible.builtin.copy:
src: "~/{{ item }}"
dest: "~/old_dat/{{ item }}"
loop:
- ".config"
- ".ssh"
- ".local/share/applications"
- ".mozilla"
- "scripts"
- name: Remove old files and directories
ansible.builtin.file:
path: "{{ item }}"
state: "absent"
loop:
- "~/.config/Vorlagen"
- "~/scripts/in_path"
- "~/scripts/pieces"
- "~/scripts/polybar"
- "~/scripts/archive"
# - name: Include tasks from copy_new.yml
# ansible.builtin.include_tasks:
# file: copy_new.yml
- name: Copy new files and directories
ansible.builtin.copy:
#src: "files/{{ item }}"
src: "{{ item }}"
dest: "~/{{ item }}"
loop:
- ".config"
- ".face"
- ".gitconfig"
- ".gtkrc-2.0"
- ".local"
- ".ssh"
- "scripts"
- name: Copy new files and directories (root)
ansible.builtin.copy:
#src: "files/{{ item }}"
src: "{{ item }}"
dest: "~/{{ item }}"
loop:
- "etc"
become: true
- name: x86_64 | Copy files (root)
ansible.builtin.copy:
src: "{{ item }}"
dest: "/etc/pacman.conf"
loop:
- "/etc/pacman-x86_64.conf"
when: ansible_architecture == "x86_64"
become: true
- name: Symlink xdg environment variables
ansible.builtin.file:
src: "~/.config/user-dirs.dirs"
dest: "~/.config/environment.d/user-dirs.dirs.conf"
state: "link"
- name: Bash cat | Download
ansible.builtin.git:
repo: https://github.com/exu-g/bash-cat-with-cat.git
dest: "/tmp/bash-cat-with-cat"
- name: Bash cat | Copy to scripts
ansible.builtin.copy:
src: "/tmp/bash-cat-with-cat/cat.sh"
dest: "~/scripts/pieces/cat.sh"
mode: "0755"
- name: Reload user systemd services
ansible.builtin.systemd_service:
daemon_reload: true
- name: Enable fstrim
ansible.builtin.systemd_service:
name: fstrim.timer
state: "started"
enabled: true
become: true
- name: Enable btrfsmaintenance timers
ansible.builtin.systemd_service:
name: "{{ item }}"
enabled: true
loop:
- "btrfs-balance.timer"
- "btrfs-scrub.timer"
when: ('btrfsmaintenance' in ansible_facts.packages)
become: true
- name: Enable btrfsmaintenance services
ansible.builtin.systemd_service:
name: "{{ item }}"
state: "restarted"
loop:
- "btrfsmaintenance-refresh.service"
when: ('btrfsmaintenance' in ansible_facts.packages)
become: true
- name: Enable reflector
ansible.builtin.systemd_service:
name: "{{ item }}"
enabled: true
loop:
- "reflector.timer"
when: ('reflector' in ansible_facts.packages)
become: true
- name: Enable NTP
ansible.builtin.command: timedatectl set-ntp true
become: true
- name: Enable ssh-agent
ansible.builtin.systemd_service:
name: ssh-agent
state: "restarted"
enabled: true
- name: Enable vnstat
ansible.builtin.systemd_service:
name: vnstat
state: "started"
enabled: true
become: true

View File

@ -1,26 +0,0 @@
- name: Create backup structure
ansible.builtin.file:
path: "~/old_dat"
state: "directory"
- name: Copy files to backup
ansible.builtin.copy:
src: "~/{{ item }}"
dest: "~/old_dat/{{ item }}"
loop:
- ".config"
- ".ssh"
- ".local/share/applications"
- ".mozilla"
- "scripts"
- name: Remove old files and directories
ansible.builtin.file:
path: "{{ item }}"
state: "absent"
loop:
- "~/.config/Vorlagen"
- "~/scripts/in_path"
- "~/scripts/pieces"
- "~/scripts/polybar"
- "~/scripts/archive"

View File

@ -9,7 +9,8 @@
community.general.pacman:
state: present
# select the lines and use 'M-x sort-lines'
name:
name: "{{ item }}"
loop:
#- gnome-keyring
#- hdparm
#- libaacs