From fc4088d7959c51973fd7083efe27ce5661cae77a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <j.l.k@gmx.com>
Date: Mon, 26 Jul 2021 13:37:57 +0200
Subject: [PATCH] Added robots.txt for archmanweb

---
 roles/archmanweb/files/robots.txt          | 4 ++++
 roles/archmanweb/tasks/main.yml            | 3 +++
 roles/archmanweb/templates/nginx.d.conf.j2 | 4 ++++
 3 files changed, 11 insertions(+)
 create mode 100644 roles/archmanweb/files/robots.txt

diff --git a/roles/archmanweb/files/robots.txt b/roles/archmanweb/files/robots.txt
new file mode 100644
index 000000000..bd05d078b
--- /dev/null
+++ b/roles/archmanweb/files/robots.txt
@@ -0,0 +1,4 @@
+User-agent: *
+Disallow: /search?
+Disallow: /listing?
+Crawl-delay: 2
diff --git a/roles/archmanweb/tasks/main.yml b/roles/archmanweb/tasks/main.yml
index b4897d107..ed839eede 100644
--- a/roles/archmanweb/tasks/main.yml
+++ b/roles/archmanweb/tasks/main.yml
@@ -65,6 +65,9 @@
   register: config
   no_log: true
 
+- name: copy robots.txt
+  copy: src=robots.txt dest="{{ archmanweb_dir }}/repo/robots.txt" owner=root group=root mode=0644
+
 - name: create archmanweb db user
   postgresql_user: name={{ archmanweb_db_user }} password={{ vault_archmanweb_db_password }} login_host="{{ archmanweb_db_host }}" login_password="{{ vault_postgres_users.postgres }}" encrypted=yes
   no_log: true
diff --git a/roles/archmanweb/templates/nginx.d.conf.j2 b/roles/archmanweb/templates/nginx.d.conf.j2
index a85d2f576..35058a181 100644
--- a/roles/archmanweb/templates/nginx.d.conf.j2
+++ b/roles/archmanweb/templates/nginx.d.conf.j2
@@ -41,6 +41,10 @@ server {
         alias {{ archmanweb_dir }}/repo/collected_static/archlinux-common/favicon.ico;
     }
 
+    location = /robots.txt {
+        alias {{ archmanweb_dir }}/repo/robots.txt;
+    }
+
     # Client-cache for Django's static assets
     location /static/ {
         expires 30d;
-- 
GitLab