Create deb.http.realraum.at apt-cacher instance
authornicoo <nicoo@realraum.at>
Fri, 7 Feb 2020 11:54:08 +0000 (12:54 +0100)
committernicoo <nicoo@realraum.at>
Fri, 7 Feb 2020 12:24:46 +0000 (13:24 +0100)
ansible/host_playbooks/deb.yml [new file with mode: 0644]
ansible/host_vars/alfred/main.yml
ansible/host_vars/deb/main.yml [new file with mode: 0644]
ansible/hosts.ini

diff --git a/ansible/host_playbooks/deb.yml b/ansible/host_playbooks/deb.yml
new file mode 100644 (file)
index 0000000..d8dd046
--- /dev/null
@@ -0,0 +1,97 @@
+---
+- name: Basic Setup for deb.realraum.at
+  hosts: deb
+  roles:
+  - role: base
+  
+- name: Set up data volume for apt-cacher-ng
+  hosts: deb
+  tasks:
+    - name: Format the data volume
+      filesystem:
+        dev: /dev/vdb
+        fstype: ext4
+        resizefs: yes
+
+    - name: Setup mountpoint
+      mount:
+        path:   /var/cache/apt-cacher-ng
+        src:    /dev/vdb
+        state:  mounted
+        fstype: ext4
+
+    - name: Create user/group apt-cacher-ng
+      user:
+        name: apt-cacher-ng
+        system: yes
+        shell: /usr/sbin/nologin
+        home: /var/cache/apt-cacher-ng
+        create_home: no
+
+    - name: Set up permissions on /var/cache/apt-cacher-ng
+      file:
+        path: /var/cache/apt-cacher-ng
+        owner: apt-cacher-ng
+        group: apt-cacher-ng
+
+- name: Set up apt-cacher-ng
+  hosts: deb
+  handlers:
+    - name: restart acng
+      service:
+        name: apt-cacher-ng
+        state: restarted
+
+  tasks:
+    - name: Install acng
+      apt:
+        name: apt-cacher-ng
+        state: present
+
+    - name: Configure acng
+      notify: restart acng
+      lineinfile:
+        path: /etc/apt-cacher-ng/acng.conf
+        line: "{{ item.key }}: {{ item.value }}"
+        regexp: "^(#\\s*)?{{ item.key }}:"
+
+      loop_control:
+        label: "{{ item.key }}"
+      with_dict:
+        BindAddress: deb.http.realraum.at
+        Port: 8080
+        ForceManaged: 1
+        Remap-debsec: /debian-security ; file:backends_debian_security
+        Remap-grml: /grml ; file:backends_grml
+        Remap-pi: /pi ; file:backends_pi
+        Remap-raspbian: /raspbian ; file:backends_raspbian
+
+
+    - name: Configure's acng's backends
+      notify: restart acng
+      copy:
+        dest: /etc/apt-cacher-ng/backends_{{ item.key }}
+        content: |
+          {% for backend in item.value %}
+          {{ backend }}
+          {% endfor %}
+        mode: 0644
+
+      loop_control:
+        label: "{{ item.key }}"
+      with_dict:
+        debian:
+          - https://debian.ffgraz.net/debian
+          - http://cdn-fastly.deb.debian.org/debian
+
+        debian_security:
+          - https://debian.ffgraz.net/debian-security
+          - http://cdn-fastly.deb.debian.org/debian-security
+
+        pi:
+          - https://debian.ffgraz.net/pi
+          - https://archive.raspberrypi.org/debian
+
+        raspbian:
+          - https://debian.ffgraz.net/raspbian
+          - https://archive.raspbian.org/raspbian
index ed73d0c..f171f2a 100644 (file)
@@ -10,4 +10,5 @@ vm_host:
     nameservers: "{{ net.mgmt.dns }}"
     indices:
       metrics: 74
+      deb: 75
       testvm: 99
diff --git a/ansible/host_vars/deb/main.yml b/ansible/host_vars/deb/main.yml
new file mode 100644 (file)
index 0000000..0986fa7
--- /dev/null
@@ -0,0 +1,42 @@
+---
+localconfig_ssh_config_user: root
+
+vm_host: alfred
+
+install:
+  host: "{{ vm_host }}"
+  mem: 1024
+  numcpu: 2
+  disks:
+    primary: /dev/vda
+    virtio:
+      vda:
+        vg: "{{ vm_host }}"
+        lv: "{{ inventory_hostname }}"
+        size: 5g
+      vdb:
+        vg: "{{ vm_host }}"
+        lv: "{{ inventory_hostname }}-data"
+        size: 20g
+
+  interfaces:
+  - bridge: "{{ hostvars[vm_host].vm_host.network.interface }}"
+    name: mgmt0
+  - bridge: "br-svc"
+    name: svc0
+  autostart: True
+
+network:
+  nameservers: "{{ hostvars[vm_host].vm_host.network.nameservers }}"
+  domain: realraum.at
+  systemd_link:
+    interfaces: "{{ install.interfaces }}"
+  primary:
+    interface: mgmt0
+    ip: "{{ (hostvars[vm_host].vm_host.network.ip+'/'+hostvars[vm_host].vm_host.network.mask) | ipaddr(hostvars[vm_host].vm_host.network.indices[inventory_hostname]) | ipaddr('address') }}"
+    mask: "{{ hostvars[vm_host].vm_host.network.mask }}"
+    gateway: "{{ hostvars[vm_host].vm_host.network.gateway | default(hostvars[vm_host].vm_host.network.ip) }}"
+  secondary:
+    svc0:
+      ip:   192.168.34.75
+      mask: 255.255.255.0
index 26bb727..c8ea0db 100644 (file)
@@ -14,6 +14,7 @@ hacksch
 r3home
 tickets
 gnocchi[0:1]
+deb
 
 ## TODO: remove the variable once https://github.com/ansible/ansible/issues/39119 is fixed
 metrics localconfig_ssh_config_user=root
@@ -46,6 +47,7 @@ virtualservers-alfred
 athsdisc
 calendar
 ctf
+deb
 entrance
 galley
 hacksch