diff --git a/host_vars/ger.mirror.pkgbuild.com b/host_vars/ger.mirror.pkgbuild.com index 7d257fb6af29457a38e982ca139e17ce1188b65e..10389b3a7a970bb92847c4ff70d5fda788230cee 100644 --- a/host_vars/ger.mirror.pkgbuild.com +++ b/host_vars/ger.mirror.pkgbuild.com @@ -3,6 +3,7 @@ mirror_domain: ger.mirror.pkgbuild.com archweb_mirrorcheck_locations: [11] arch32_mirror_domain: ger.mirror.archlinux32.org network_interface: "eno2" +archive_domain: archive.ger.mirror.pkgbuild.com ipv4_address: "159.122.70.8" ipv4_netmask: "/26" ipv4_gateway: "159.122.70.1" diff --git a/playbooks/archive-mirrors.yml b/playbooks/archive-mirrors.yml index 8c6bd87b2061ebcb9602463d3c9c867f637f3c3f..b6035470b5bb3bf9382041e3e07efe4cd1428f88 100644 --- a/playbooks/archive-mirrors.yml +++ b/playbooks/archive-mirrors.yml @@ -12,3 +12,4 @@ - { role: unbound } - { role: syncarchive, tags: ['nginx'] } - { role: zabbix-agent, tags: ["zabbix"] } + - { role: archive, archive_nginx_only: true, archive_dir: "/srv/archive"} diff --git a/roles/archive/defaults/main.yml b/roles/archive/defaults/main.yml index f6b29d25981916936a5153635f5c3d41f2932e18..66214ef9ae977a297ad0261fbba7e30dd7ff6758 100644 --- a/roles/archive/defaults/main.yml +++ b/roles/archive/defaults/main.yml @@ -4,3 +4,4 @@ archive_user_name: 'archive' archive_user_home: '/home/archive' archive_repo: '{{ archive_user_home }}/archive-uploader' archive_uploader_version: 'v0.15.3' +archive_nginx_only: false diff --git a/roles/archive/tasks/main.yml b/roles/archive/tasks/main.yml index f68a86f08f75ec819506f5c988b0935ce8cdf7b6..3ec1b1a9c0133e8ecf4c931a6730f2cc6562e195 100644 --- a/roles/archive/tasks/main.yml +++ b/roles/archive/tasks/main.yml @@ -10,6 +10,7 @@ owner: archive group: archive mode: 0755 + when: not archive_nginx_only - name: setup archive configuration template: @@ -18,12 +19,15 @@ owner: root group: root mode: 0644 + when: not archive_nginx_only - name: setup archive timer systemd: name=archive.timer enabled=yes state=started + when: not archive_nginx_only - name: setup archive-hardlink timer systemd: name=archive-hardlink.timer enabled=yes state=started + when: not archive_nginx_only - name: set up nginx template: @@ -46,19 +50,23 @@ - name: install internet archive packages pacman: name=python-internetarchive state=present + when: not archive_nginx_only - name: create archive user user: name={{ archive_user_name }} shell=/bin/false home="{{ archive_user_home }}" createhome=yes + when: not archive_nginx_only - name: configure archive.org client command: ia configure --username={{ vault_archive_username }} --password={{ vault_archive_password }} creates={{ archive_user_home }}/.config/ia.ini become: yes become_user: "{{ archive_user_name }}" + when: not archive_nginx_only - name: clone archive uploader code git: repo=https://github.com/archlinux/arch-historical-archive.git dest="{{ archive_repo }}" version="{{ archive_uploader_version }}" become: yes become_user: "{{ archive_user_name }}" + when: not archive_nginx_only - name: install system service template: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644 @@ -67,6 +75,8 @@ - archive-uploader.timer notify: - daemon reload + when: not archive_nginx_only - name: start uploader timer service: name=archive-uploader.timer state=started enabled=yes + when: not archive_nginx_only diff --git a/roles/archive/templates/nginx.d.conf.j2 b/roles/archive/templates/nginx.d.conf.j2 index 62539b8e83c3c0004c4c342bfe6453ea6a57bed4..a24a5956dffe9e234f39221a5451e32f2efd240a 100644 --- a/roles/archive/templates/nginx.d.conf.j2 +++ b/roles/archive/templates/nginx.d.conf.j2 @@ -31,13 +31,15 @@ server { location /.all/ { # XXX: This regex is reused for /repos/ below! Change both if you change this! location ~ ^/.all/(?<filename>(?<pkgname>(?<pkgname_first_char>[^/])[^/]*)-(?<pkgver>[^-/]+)-(?<pkgrel>[0-9.]+)-(?<arch>[^-/]+)\.pkg\.tar(|\.(gz|bz2|xz|zst|lrz|lzo|Z|lz4|lz))(?<sig>\.sig)?)$ { - rewrite ^ /packages/$pkgname_first_char/$pkgname/$filename; + # https://stackoverflow.com/questions/22512112/nginx-rewrite-proxy-if-file-not-exists + try_files $uri @archive1; } } # XXX: This regex is the same as for .all above. Change both if you change this! location ~ ^/(?:repos/\d+/.*|packages/.*)/(?<filename>(?<pkgname>(?<pkgname_first_char>[^/])[^/]*)-(?<pkgver>[^-/]+)-(?<pkgrel>[0-9.]+)-(?<arch>[^-/]+)\.pkg\.tar(|\.(gz|bz2|xz|zst|lrz|lzo|Z|lz4|lz))(?<sig>\.sig)?)$ { - rewrite ^ /archive.org/archlinux_pkg_$pkgname/$filename last; + # https://stackoverflow.com/questions/22512112/nginx-rewrite-proxy-if-file-not-exists + try_files $uri @archive2; } # archive.org download URLs look like: # https://archive.org/download/archlinux_pkg_lucene__/lucene++-1.4.2-3-i686.pkg.tar.xz @@ -54,6 +56,14 @@ server { rewrite ^/archive\.org/([^@\+\.]*/.*)$ https://archive.org/download/$1 redirect; } + location @archive1 { + rewrite ^ /packages/$pkgname_first_char/$pkgname/$filename; + } + + location @archive2 { + rewrite ^ /archive.org/archlinux_pkg_$pkgname/$filename last; + } + autoindex on; autoindex_exact_size off; }