From 843ceed310feff298eecf8dffc34784fa6538700 Mon Sep 17 00:00:00 2001 From: shnee Date: Mon, 21 Mar 2022 11:14:03 -0400 Subject: [PATCH] Manjaro repos working. --- pkg-cache.yml | 36 +++++++++++++++++++++++++++++++++--- templates/mirrorlist.j2 | 6 ++++++ templates/nuster.cfg.j2 | 15 ++++++++++----- 3 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 templates/mirrorlist.j2 diff --git a/pkg-cache.yml b/pkg-cache.yml index 706ba52..ef837f0 100644 --- a/pkg-cache.yml +++ b/pkg-cache.yml @@ -5,6 +5,18 @@ vars: install_docker: false + # For arch distros just run `pacman-mirrors --fasttrack` to grab the fastest + # repos in your country. + repos: + - name: gigenet + url: mirrors.gigenet.com + port: 443 + - name: ialab + url: repo.ialab.dsu.edu + port: 443 + - name: princeton + url: mirror.math.princeton.edu + port: 443 # TODO remove this if unused. # This object represents the uid/gid for the haproxy user/group in the # haproxy container. @@ -16,6 +28,8 @@ persistent_data_directory: /media1/srv/pkg-cache host_cert_file: "{{ persistent_data_directory }}/{{ cert_name }}" host_config_file: "{{ persistent_data_directory }}/nuster.cfg" + host_mirrorlist_file: "{{ persistent_data_directory }}/mirrorlist" + local_mirrorlist_file: ~/dev/pkg-cache-ansible/mirrorlist permissions: &persistent_data_permissions # owner: gert # group: gert @@ -48,6 +62,21 @@ <<: *persistent_data_permissions become: true + # This is an example mirrorlist to used with this package cache. + - name: Create the mirrorlist example. + ansible.builtin.template: + src: templates/mirrorlist.j2 + dest: "{{ host_mirrorlist_file }}" + <<: *persistent_data_permissions + become: true + + - name: Copy the mirrorlist to localhost. + ansible.builtin.fetch: + src: "{{ host_mirrorlist_file }}" + dest: "{{ local_mirrorlist_file }}" + flat: true + become: true + - name: Copy over SSL cert. ansible.builtin.copy: dest: "{{ host_cert_file }}" @@ -62,6 +91,7 @@ name: pkg-cache state: started restart: true + # recreate: true network_mode: default # TODO REM this shouldn't be needed becuase of the proxy. # published_ports: @@ -71,7 +101,7 @@ - "{{ host_cert_file }}:{{ container_cert_file }}" - "{{ persistent_data_directory }}/cache:/cache" env: - VIRTUAL_HOST: pkg.shnee.net - VIRTAUL_PORT: "8080" - NETWORK_ACCESS: internal + VIRTUAL_HOST: pkg.shnee.net,*.pkg.shnee.net + VIRTUAL_PORT: "8080" + # NETWORK_ACCESS: internal restart_policy: unless-stopped diff --git a/templates/mirrorlist.j2 b/templates/mirrorlist.j2 new file mode 100644 index 0000000..71c8642 --- /dev/null +++ b/templates/mirrorlist.j2 @@ -0,0 +1,6 @@ +## This mirrorlist has been generated pkg-cache.yml playbook to use a cached +## proxy for package repos. + +{% for repo in repos %} +Server = http://{{ repo.name }}.pkg.shnee.net/manjaro/stable/$repo/$arch +{% endfor %} diff --git a/templates/nuster.cfg.j2 b/templates/nuster.cfg.j2 index 4aa0ac6..2ffbb2f 100644 --- a/templates/nuster.cfg.j2 +++ b/templates/nuster.cfg.j2 @@ -1,5 +1,6 @@ global log stdout format raw local0 + # TODO REM remove these and haproxy from the vars if unused. # uid {{ haproxy_user.uid }} # gid {{ haproxy_user.gid }} nuster cache on dir /cache @@ -16,11 +17,15 @@ defaults frontend http_frontend # bind *:4433 ssl crt {{ container_cert_file }} bind *:8080 - default_backend pkg_repo +{% for repo in repos %} + use_backend {{ repo.name }}_pkg_repo if { hdr_beg(host) -i {{ repo.name }} } +{% endfor %} -backend pkg_repo +{% for repo in repos %} + +backend {{ repo.name }}_pkg_repo nuster cache on - nuster rule r1 disk on memory off + nuster rule {{ repo.name }}_rule disk on memory off option forwardfor - server server1 mirrors.gigenet.com:443 ssl verify none - + server {{ repo.name }} {{ repo.url }}:{{ repo.port }} ssl verify none +{% endfor %}