From 80a23c8ee6e9393299119fe353ede3379ca916a4 Mon Sep 17 00:00:00 2001 From: Beth Parker Date: Mon, 7 Oct 2024 20:37:58 -0500 Subject: [PATCH 1/2] added pacman --- files/aur-local | 3 ++ files/build_mirrorlist.service | 10 ++++ files/build_mirrorlist.sh | 9 ++++ files/build_mirrorlist.timer | 13 +++++ files/pacman.conf | 98 ++++++++++++++++++++++++++++++++++ handlers/main.yml | 2 + tasks/directories.yml | 8 +++ tasks/main.yml | 6 +++ tasks/pacman.yml | 46 ++++++++++++++++ 9 files changed, 195 insertions(+) create mode 100644 files/aur-local create mode 100644 files/build_mirrorlist.service create mode 100644 files/build_mirrorlist.sh create mode 100644 files/build_mirrorlist.timer create mode 100644 files/pacman.conf create mode 100644 tasks/directories.yml create mode 100644 tasks/pacman.yml diff --git a/files/aur-local b/files/aur-local new file mode 100644 index 0000000..7b8486b --- /dev/null +++ b/files/aur-local @@ -0,0 +1,3 @@ +[aur-local] +SigLevel = Never +Server = http://pkg.actcur.com/archlinux/$repo/os/$arch diff --git a/files/build_mirrorlist.service b/files/build_mirrorlist.service new file mode 100644 index 0000000..5d25a4b --- /dev/null +++ b/files/build_mirrorlist.service @@ -0,0 +1,10 @@ +[Unit] +Description=Update mirrorlist with pkg server + top 10 mirrors + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart=/bin/bash /scripts/build_mirrorlist.sh + +[Install] +WantedBy=multi-user.target diff --git a/files/build_mirrorlist.sh b/files/build_mirrorlist.sh new file mode 100644 index 0000000..749cff6 --- /dev/null +++ b/files/build_mirrorlist.sh @@ -0,0 +1,9 @@ +curl 'https://archlinux.org/mirrorlist/?country=CA&country=US&protocol=http&protocol=https&ip_version=4&use_mirror_status=on)' > /tmp/tempMirrors.list +sleep 10 +sed -i 's/^#Server/Server/' /tmp/tempMirrors.list +cat /tmp/tempMirrors.list | grep -e "Server = .*\/[$]repo\/os\/[$]arch" > /tmp/tempMirrors2.list +mirrors=$(rankmirrors -n 10 /tmp/tempMirrors2.list | grep "Server = ") +echo "Server = http://pkg.actcur.com/archlinux/$repo/os/$arch" > /tmp/mirrors.list +echo "$mirrors" >> /tmp/mirrors.list +mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.old +mv /tmp/mirrors.list /etc/pacman.d/mirrorlist diff --git a/files/build_mirrorlist.timer b/files/build_mirrorlist.timer new file mode 100644 index 0000000..7d8ca3f --- /dev/null +++ b/files/build_mirrorlist.timer @@ -0,0 +1,13 @@ +[Unit] +Description=Runs build_mirrorlist.service every 36 hours + +[Timer] +# Time to wait after booting before we run first time +OnBootSec=10min +# Time between running each consecutive time +OnUnitActiveSec=36h +Unit=build_mirrorlist.service + +[Install] +WantedBy=multi-user.target + diff --git a/files/pacman.conf b/files/pacman.conf new file mode 100644 index 0000000..d67ca4a --- /dev/null +++ b/files/pacman.conf @@ -0,0 +1,98 @@ +# +# /etc/pacman.conf +# +# See the pacman.conf(5) manpage for option and repository directives + +# +# GENERAL OPTIONS +# +[options] +# The following paths are commented out with their default values listed. +# If you wish to use different paths, uncomment and update the paths. +#RootDir = / +#DBPath = /var/lib/pacman/ +#CacheDir = /var/cache/pacman/pkg/ +#LogFile = /var/log/pacman.log +#GPGDir = /etc/pacman.d/gnupg/ +#HookDir = /etc/pacman.d/hooks/ +HoldPkg = pacman glibc +#XferCommand = /usr/bin/curl -L -C - -f -o %o %u +#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u +#CleanMethod = KeepInstalled +Architecture = auto + +# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup +#IgnorePkg = +#IgnoreGroup = + +#NoUpgrade = +#NoExtract = + +# Misc options +#UseSyslog +#Color +#NoProgressBar +CheckSpace +#VerbosePkgLists +#ParallelDownloads = 5 + +# By default, pacman accepts packages signed by keys that its local keyring +# trusts (see pacman-key and its man page), as well as unsigned packages. +SigLevel = Required DatabaseOptional +LocalFileSigLevel = Optional +#RemoteFileSigLevel = Required + +# NOTE: You must run `pacman-key --init` before first using pacman; the local +# keyring can then be populated with the keys of all official Arch Linux +# packagers with `pacman-key --populate archlinux`. + +# +# REPOSITORIES +# - can be defined here or included from another file +# - pacman will search repositories in the order defined here +# - local/custom mirrors can be added here or in separate files +# - repositories listed first will take precedence when packages +# have identical names, regardless of version number +# - URLs will have $repo replaced by the name of the current repo +# - URLs will have $arch replaced by the name of the architecture +# +# Repository entries are of the format: +# [repo-name] +# Server = ServerName +# Include = IncludePath +# +# The header [repo-name] is crucial - it must be present and +# uncommented to enable the repo. +# + +# The testing repositories are disabled by default. To enable, uncomment the +# repo name header and Include lines. You can add preferred servers immediately +# after the header, and they will be used before the default mirrors. + +#[core-testing] +#Include = /etc/pacman.d/mirrorlist + +[core] +Include = /etc/pacman.d/mirrorlist + +#[extra-testing] +#Include = /etc/pacman.d/mirrorlist + +[extra] +Include = /etc/pacman.d/mirrorlist + +# If you want to run 32 bit applications on your x86_64 system, +# enable the multilib repositories as required here. + +#[multilib-testing] +#Include = /etc/pacman.d/mirrorlist + +#[multilib] +#Include = /etc/pacman.d/mirrorlist + +# An example of a custom package repository. See the pacman manpage for +# tips on creating your own repositories. +#[custom] +#SigLevel = Optional TrustAll +#Server = file:///home/custompkgs +Include = /etc/pacman.d/aur-local diff --git a/handlers/main.yml b/handlers/main.yml index 5a8863c..d621007 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,2 +1,4 @@ --- # handlers file for core +- name: build mirrorlist + ansible.builtin.shell: /scripts/build_mirrorlist.sh diff --git a/tasks/directories.yml b/tasks/directories.yml new file mode 100644 index 0000000..e7bc5ff --- /dev/null +++ b/tasks/directories.yml @@ -0,0 +1,8 @@ +--- +# tasks file for directories + +- name: ensure scripts exists + ansible.builtin.file: + path: /scripts + state: directory + diff --git a/tasks/main.yml b/tasks/main.yml index 702ad8a..e2c5c7f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,8 @@ --- # tasks file for core + +- include_tasks: directories.yml + +- include_tasks: pacman.yml + when: ansible_facts['distribution'] == "Archlinux" + diff --git a/tasks/pacman.yml b/tasks/pacman.yml new file mode 100644 index 0000000..399fa10 --- /dev/null +++ b/tasks/pacman.yml @@ -0,0 +1,46 @@ +--- +# tasks file for pacman + +- name: install pacman-contrib to allow use of rankmirrors + ansible.builtin.package: + name: pacman-contrib + state: present + +- name: create service for building mirrorlist + ansible.builtin.copy: + src: files/build_mirrorlist.service + dest: /usr/lib/systemd/system/build_mirrorlist.service + +- name: deploy timer for building mirrorlist + ansible.builtin.copy: + src: files/build_mirrorlist.timer + dest: /usr/lib/systemd/system/build_mirrorlist.timer + +- name: deploy mirrorlist script + ansible.builtin.copy: + src: files/build_mirrorlist.sh + dest: /scripts/build_mirrorlist.sh + owner: root + group: root + mode: 0744 + notify: + - build mirrorlist + +- name: ensure notify triggers + ansible.builtin.meta: flush_handlers + +- name: deploy pacman config + ansible.builtin.copy: + src: files/pacman.conf + dest: /etc/pacman.conf + +- name: deploy aur-local config + ansible.builtin.copy: + src: files/aur-local + dest: /etc/pacman.d/aur-local + +- name: ensure timer is running + service: + name: build_mirrorlist.timer + state: started + enabled: yes From afa797a55f77d9ee7963ec75815efbddbf7e5e7c Mon Sep 17 00:00:00 2001 From: Beth Date: Tue, 8 Oct 2024 00:09:52 -0500 Subject: [PATCH 2/2] added base pkgs --- tasks/main.yml | 1 + tasks/packages.yml | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 tasks/packages.yml diff --git a/tasks/main.yml b/tasks/main.yml index e2c5c7f..dd6c60a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,3 +6,4 @@ - include_tasks: pacman.yml when: ansible_facts['distribution'] == "Archlinux" +- include_tasks: directories.yml diff --git a/tasks/packages.yml b/tasks/packages.yml new file mode 100644 index 0000000..f46a017 --- /dev/null +++ b/tasks/packages.yml @@ -0,0 +1,9 @@ +- name: install core packages + ansible.builtin.package: + name: "{{ item }}" + state: present + with_items: + - nano + - vim + - vi + - net-tools \ No newline at end of file