Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
843ceed310 | ||
|
|
0e3e3fcd8c | ||
|
|
da5fb4dc20 |
+42
-10
@@ -5,6 +5,19 @@
|
||||
|
||||
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.
|
||||
haproxy_user:
|
||||
@@ -14,7 +27,9 @@
|
||||
gid: &haproxy_gid 99
|
||||
persistent_data_directory: /media1/srv/pkg-cache
|
||||
host_cert_file: "{{ persistent_data_directory }}/{{ cert_name }}"
|
||||
host_config_file: "{{ persistent_data_directory }}/haproxy.cfg"
|
||||
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
|
||||
@@ -40,13 +55,28 @@
|
||||
mode: '0750'
|
||||
become: true
|
||||
|
||||
- name: Create haproxy config file.
|
||||
- name: Create nuster config file.
|
||||
ansible.builtin.template:
|
||||
src: templates/haproxy.cfg.j2
|
||||
src: templates/nuster.cfg.j2
|
||||
dest: "{{ host_config_file }}"
|
||||
<<: *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 }}"
|
||||
@@ -55,21 +85,23 @@
|
||||
mode: '0600'
|
||||
become: true
|
||||
|
||||
- name: Start the haproxy container.
|
||||
- name: Start the nuster container.
|
||||
community.docker.docker_container:
|
||||
image: haproxy
|
||||
image: nuster/nuster:5.3.0.23-alpine
|
||||
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:
|
||||
# - 4433:4433
|
||||
# - 4433:8080
|
||||
volumes:
|
||||
- "{{ host_config_file }}:/usr/local/etc/haproxy/haproxy.cfg"
|
||||
- "{{ host_config_file }}:/etc/nuster/nuster.cfg"
|
||||
- "{{ 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
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
# uid {{ haproxy_user.uid }}
|
||||
# gid {{ haproxy_user.gid }}
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
timeout client 10s
|
||||
timeout connect 5s
|
||||
timeout server 10s
|
||||
timeout http-request 10s
|
||||
|
||||
cache pkg_cache
|
||||
total-max-size 4095
|
||||
max-object-size 524288000
|
||||
|
||||
frontend http_frontend
|
||||
# bind *:4433 ssl crt {{ container_cert_file }}
|
||||
bind *:8080
|
||||
default_backend pkg_repo
|
||||
|
||||
backend pkg_repo
|
||||
http-request cache-use pkg_cache
|
||||
http-response cache-store pkg_cache
|
||||
option forwardfor
|
||||
server server1 mirrors.gigenet.com:443 ssl
|
||||
|
||||
@@ -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 %}
|
||||
@@ -0,0 +1,31 @@
|
||||
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
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
timeout client 10s
|
||||
timeout connect 5s
|
||||
timeout server 10s
|
||||
timeout http-request 10s
|
||||
|
||||
frontend http_frontend
|
||||
# bind *:4433 ssl crt {{ container_cert_file }}
|
||||
bind *:8080
|
||||
{% for repo in repos %}
|
||||
use_backend {{ repo.name }}_pkg_repo if { hdr_beg(host) -i {{ repo.name }} }
|
||||
{% endfor %}
|
||||
|
||||
{% for repo in repos %}
|
||||
|
||||
backend {{ repo.name }}_pkg_repo
|
||||
nuster cache on
|
||||
nuster rule {{ repo.name }}_rule disk on memory off
|
||||
option forwardfor
|
||||
server {{ repo.name }} {{ repo.url }}:{{ repo.port }} ssl verify none
|
||||
{% endfor %}
|
||||
Reference in New Issue
Block a user