From abf009338bea69fb78e1b14a7274cfb216278ffe Mon Sep 17 00:00:00 2001 From: Mira Kuntz Date: Wed, 8 Jan 2025 15:23:06 +0100 Subject: [PATCH 1/6] add dnbd3 playbook --- dnbd3.yml | 55 +++++++++++++++++++++++++++++++ group_vars/dnbd3/vars.yml | 37 +++++++++++++++++++++ group_vars/dnbd3_primary/vars.yml | 8 +++++ group_vars/dnbd3_proxy/vars.yml | 3 ++ hosts | 10 ++++++ requirements.yaml | 8 +++++ 6 files changed, 121 insertions(+) create mode 100644 dnbd3.yml create mode 100644 group_vars/dnbd3/vars.yml create mode 100644 group_vars/dnbd3_primary/vars.yml create mode 100644 group_vars/dnbd3_proxy/vars.yml diff --git a/dnbd3.yml b/dnbd3.yml new file mode 100644 index 000000000..3bf98ddc4 --- /dev/null +++ b/dnbd3.yml @@ -0,0 +1,55 @@ +--- +- hosts: + - dnbd3-primary + - dnbd3-proxy + become: true + pre_tasks: + - name: Create dnbd3 user + ansible.builtin.group: + name: "{{ dnbd3_group }}" + state: present + - name: Create dnbd3 user + ansible.builtin.user: + name: "{{ dnbd3_user }}" + group: "{{ dnbd3_group }}" + shell: /bin/false + create_home: false + - name: Grant access to dnbd3 root directory + ansible.builtin.file: + mode: "770" + path: "{{ dnbd3_base_path }}" + state: directory + owner: "{{ dnbd3_user }}" + group: "{{ dnbd3_group }}" + - name: Grant access to http directory + ansible.builtin.file: + mode: "770" + state: directory + path: "{{ tftpboot_path }}" + owner: "{{ dnbd3_user }}" + group: "{{ dnbd3_group }}" + when: "'dndb3_primary' in group_names" + roles: + # - role: usegalaxy_eu.handy.os_setup + # become: true + # vars: + # hostname: "{{ inventory_hostname }}" + # enable_hostname: true + # enable_powertools: true + # when: "'dndb3_primary' in group_names" + - role: usegalaxy_eu.dnbd3 + - role: usegalaxy_eu.tftp + when: "'dndb3_primary' in group_names" + - role: geerlingguy.apache + when: "'dndb3_primary' in group_names" + + + post_tasks: + - name: Grant access to http directory + ansible.builtin.file: + mode: "770" + path: "{{ apache_vhosts[0].documentroot }}" + state: directory + owner: "www-data" + group: "www-data" + when: "'dndb3_primary' in group_names" diff --git a/group_vars/dnbd3/vars.yml b/group_vars/dnbd3/vars.yml new file mode 100644 index 000000000..708c9fba1 --- /dev/null +++ b/group_vars/dnbd3/vars.yml @@ -0,0 +1,37 @@ +--- +# --- dnbd3 setup vars --- +#dnbd3_base_path: "/mnt/s3/dnbd3" +dnbd3_log_file: "/tmp/dnbd3-server.log" +dnbd3_config_path: "/usr/local/etc/dnbd3-server" +dnbd3_user: "dnbd3" +dnbd3_group: "dnbd3" +dnbd3_server_conf: "{{ dnbd3_base_path }}/server.conf" +dnbd3_alt_servers_conf: "{{ dnbd3_base_path }}/alt-servers" +# --- dnbd3 repo vars --- +dnbd3_git_tag: "master" +dnbd3_git_repo: "git://git.openslx.org/dnbd3.git" +# --- dnbd3 config vars --- +dnbd3_listen_port: "5003" +dnbd3_client_penalty: "100000" +dnbd3_primary: "{{ hostvars[dnbd3_primary]['ansible_default_ipv4']['address'] }}" +dnbd3_primary_comment: "Primary DNBD3 server, which replicates S3FS mounted QCOW2 images." +# dnbd3_primary_backup: "10.20.56.174" +# dnbd3_primary_backup_comment: "Secondary/backup DNBD3 server, which replicates S3FS mounted QCOW2 images." +dnbd3_poxys: + - ip: "{{ hostvars[dnbd3_proxy]['ansible_default_ipv4']['address'] }}" + comment: "1st DNBD3 Proxy" + + +# --- dnbd3 build vars --- +dnbd3_src_dir: "/usr/local/src/dnbd3" +dnbd3_build_dir: "{{ dnbd3_src_dir }}/build" +dnbd3_server_binary: "/usr/local/sbin/dnbd3-server" +dnbd3_new_binary: "{{ dnbd3_src_dir }}/dnbd3-server.new" +dnbd3_old_binary: "{{ dnbd3_src_dir }}/dnbd3-server.old" + +# --- dnbd3 systemd vars --- +dnbd3_systemd_dir: "/etc/systemd/system" +dnbd3_service_dir: "{{ dnbd3_systemd_dir }}/dnbd3-server.service.d" +dnbd3_service_file: "{{ dnbd3_systemd_dir }}/dnbd3-server.service" +dnbd3_limits_file: "{{ dnbd3_service_dir }}/limits.conf" +dnbd3_srv_mount_file: "{{ dnbd3_systemd_dir }}/srv.mount" diff --git a/group_vars/dnbd3_primary/vars.yml b/group_vars/dnbd3_primary/vars.yml new file mode 100644 index 000000000..81ec927bf --- /dev/null +++ b/group_vars/dnbd3_primary/vars.yml @@ -0,0 +1,8 @@ +--- +dnbd3_is_proxy: false +dnbd3_base_path: "/export/dnbd3-cache/images" +tftpboot_path: "/export/dnbd3-cache/boot" +apache_listen_port: 80 +apache_vhosts: + - servername: "example.com" + documentroot: "/export/dnbd3-cache/http" diff --git a/group_vars/dnbd3_proxy/vars.yml b/group_vars/dnbd3_proxy/vars.yml new file mode 100644 index 000000000..c758024c4 --- /dev/null +++ b/group_vars/dnbd3_proxy/vars.yml @@ -0,0 +1,3 @@ +--- +dnbd3_is_proxy: true +dnbd3_base_path: "/mnt/dnbd3" diff --git a/hosts b/hosts index 83b2a1ed1..9233eb2d2 100644 --- a/hosts +++ b/hosts @@ -94,3 +94,13 @@ ansible_group_priority=4 [dokku] apps.galaxyproject.eu ansible_ssh_user=ubuntu + +[dnbd3:children] +dnbd3-primary +dnbd3-proxy + +[dnbd3_primary] +dnbd3-primary.galaxyproject.eu + +[dnbd3_proxy] +dnbd3-proxy.galaxyproject.eu ansible_ssh_user=ubuntu diff --git a/requirements.yaml b/requirements.yaml index 293c1766e..5902750f3 100644 --- a/requirements.yaml +++ b/requirements.yaml @@ -157,3 +157,11 @@ roles: - src: https://github.com/usegalaxy-eu/ansible-fw-glxeu-generic name: usegalaxy_eu.firewall version: 1.0.1 + - name: usegalaxy_eu.dndb3 + src: https://github.com/usegalaxy-eu/ansible-dnbd3 + version: main + - name: usegalaxy_eu.tftp + src: https://github.com/usegalaxy-eu/ansible-tftp + version: main + - name: geerlingguy.apache + version: 4.0.0 From 2c47c7237b2ce8d43c71dcf31c228587fd1f027b Mon Sep 17 00:00:00 2001 From: Mira Kuntz Date: Wed, 8 Jan 2025 17:17:29 +0100 Subject: [PATCH 2/6] dndb3 primary ssh user --- hosts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hosts b/hosts index 9233eb2d2..abcff2434 100644 --- a/hosts +++ b/hosts @@ -100,7 +100,7 @@ dnbd3-primary dnbd3-proxy [dnbd3_primary] -dnbd3-primary.galaxyproject.eu +dnbd3-primary.galaxyproject.eu ansible_ssh_user=root [dnbd3_proxy] -dnbd3-proxy.galaxyproject.eu ansible_ssh_user=ubuntu +dnbd3-proxy.galaxyproject.eu From fc31485f1f63e9b8a597efd5ae94a3c877e9bd5d Mon Sep 17 00:00:00 2001 From: Mira Kuntz Date: Wed, 8 Jan 2025 17:58:08 +0100 Subject: [PATCH 3/6] more dndb typos --- dnbd3.yml | 10 +++++----- requirements.yaml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dnbd3.yml b/dnbd3.yml index 3bf98ddc4..6167dfe20 100644 --- a/dnbd3.yml +++ b/dnbd3.yml @@ -28,7 +28,7 @@ path: "{{ tftpboot_path }}" owner: "{{ dnbd3_user }}" group: "{{ dnbd3_group }}" - when: "'dndb3_primary' in group_names" + when: "'dnbd3_primary' in group_names" roles: # - role: usegalaxy_eu.handy.os_setup # become: true @@ -36,12 +36,12 @@ # hostname: "{{ inventory_hostname }}" # enable_hostname: true # enable_powertools: true - # when: "'dndb3_primary' in group_names" + # when: "'dnbd3_primary' in group_names" - role: usegalaxy_eu.dnbd3 - role: usegalaxy_eu.tftp - when: "'dndb3_primary' in group_names" + when: "'dnbd3_primary' in group_names" - role: geerlingguy.apache - when: "'dndb3_primary' in group_names" + when: "'dnbd3_primary' in group_names" post_tasks: @@ -52,4 +52,4 @@ state: directory owner: "www-data" group: "www-data" - when: "'dndb3_primary' in group_names" + when: "'dnbd3_primary' in group_names" diff --git a/requirements.yaml b/requirements.yaml index 5902750f3..67d0f1bd6 100644 --- a/requirements.yaml +++ b/requirements.yaml @@ -157,7 +157,7 @@ roles: - src: https://github.com/usegalaxy-eu/ansible-fw-glxeu-generic name: usegalaxy_eu.firewall version: 1.0.1 - - name: usegalaxy_eu.dndb3 + - name: usegalaxy_eu.dnbd3 src: https://github.com/usegalaxy-eu/ansible-dnbd3 version: main - name: usegalaxy_eu.tftp From b320cb7eb43fdf8b82a0fa8bbc70f4a0386e5c0c Mon Sep 17 00:00:00 2001 From: Mira Kuntz Date: Wed, 8 Jan 2025 18:05:16 +0100 Subject: [PATCH 4/6] fix hosts --- dnbd3.yml | 4 +--- hosts | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dnbd3.yml b/dnbd3.yml index 6167dfe20..874fb79bb 100644 --- a/dnbd3.yml +++ b/dnbd3.yml @@ -1,7 +1,5 @@ --- -- hosts: - - dnbd3-primary - - dnbd3-proxy +- hosts: dnbd3-primary,dnbd3-proxy become: true pre_tasks: - name: Create dnbd3 user diff --git a/hosts b/hosts index abcff2434..96a074438 100644 --- a/hosts +++ b/hosts @@ -99,8 +99,8 @@ apps.galaxyproject.eu ansible_ssh_user=ubuntu dnbd3-primary dnbd3-proxy -[dnbd3_primary] +[dnbd3-primary] dnbd3-primary.galaxyproject.eu ansible_ssh_user=root -[dnbd3_proxy] +[dnbd3-proxy] dnbd3-proxy.galaxyproject.eu From 91af54dd0d7fc920d96efbb25ddb0f4820597cf2 Mon Sep 17 00:00:00 2001 From: Mira Kuntz Date: Wed, 8 Jan 2025 18:10:17 +0100 Subject: [PATCH 5/6] add git --- dnbd3.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dnbd3.yml b/dnbd3.yml index 874fb79bb..7c2f69200 100644 --- a/dnbd3.yml +++ b/dnbd3.yml @@ -2,6 +2,12 @@ - hosts: dnbd3-primary,dnbd3-proxy become: true pre_tasks: + - name: Install dependencies + ansible.builtin.package: + name: + - git + state: present + - name: Create dnbd3 user ansible.builtin.group: name: "{{ dnbd3_group }}" From 92332548ee17f4f94443c6c3e2c34a3d956d3c14 Mon Sep 17 00:00:00 2001 From: Mira Kuntz Date: Wed, 15 Jan 2025 16:35:00 +0100 Subject: [PATCH 6/6] dndb3 tftp and http running on debian/zfs0f --- dnbd3.yml | 19 +++++++------- group_vars/dnbd3/vars.yml | 26 ++----------------- .../{dnbd3_primary => dnbd3primary}/vars.yml | 4 ++- .../{dnbd3_proxy => dnbd3proxy}/vars.yml | 0 hosts | 8 +++--- 5 files changed, 19 insertions(+), 38 deletions(-) rename group_vars/{dnbd3_primary => dnbd3primary}/vars.yml (51%) rename group_vars/{dnbd3_proxy => dnbd3proxy}/vars.yml (100%) diff --git a/dnbd3.yml b/dnbd3.yml index 7c2f69200..c94f4ca90 100644 --- a/dnbd3.yml +++ b/dnbd3.yml @@ -1,5 +1,6 @@ --- -- hosts: dnbd3-primary,dnbd3-proxy +- name: DNBD3 Infrastructure + hosts: dnbd3primary,dnbd3proxy become: true pre_tasks: - name: Install dependencies @@ -25,14 +26,14 @@ state: directory owner: "{{ dnbd3_user }}" group: "{{ dnbd3_group }}" - - name: Grant access to http directory + - name: Grant access to tftp root directory ansible.builtin.file: mode: "770" - state: directory path: "{{ tftpboot_path }}" - owner: "{{ dnbd3_user }}" - group: "{{ dnbd3_group }}" - when: "'dnbd3_primary' in group_names" + state: directory + owner: "{{ tftp_user }}" + group: "{{ tftp_group }}" + when: "'dnbd3primary' in group_names" roles: # - role: usegalaxy_eu.handy.os_setup # become: true @@ -43,9 +44,9 @@ # when: "'dnbd3_primary' in group_names" - role: usegalaxy_eu.dnbd3 - role: usegalaxy_eu.tftp - when: "'dnbd3_primary' in group_names" + when: "'dnbd3primary' in group_names" - role: geerlingguy.apache - when: "'dnbd3_primary' in group_names" + when: "'dnbd3primary' in group_names" post_tasks: @@ -56,4 +57,4 @@ state: directory owner: "www-data" group: "www-data" - when: "'dnbd3_primary' in group_names" + when: "'dnbd3primary' in group_names" diff --git a/group_vars/dnbd3/vars.yml b/group_vars/dnbd3/vars.yml index 708c9fba1..b01be7d0a 100644 --- a/group_vars/dnbd3/vars.yml +++ b/group_vars/dnbd3/vars.yml @@ -1,37 +1,15 @@ --- # --- dnbd3 setup vars --- #dnbd3_base_path: "/mnt/s3/dnbd3" -dnbd3_log_file: "/tmp/dnbd3-server.log" -dnbd3_config_path: "/usr/local/etc/dnbd3-server" -dnbd3_user: "dnbd3" -dnbd3_group: "dnbd3" -dnbd3_server_conf: "{{ dnbd3_base_path }}/server.conf" -dnbd3_alt_servers_conf: "{{ dnbd3_base_path }}/alt-servers" -# --- dnbd3 repo vars --- dnbd3_git_tag: "master" dnbd3_git_repo: "git://git.openslx.org/dnbd3.git" # --- dnbd3 config vars --- dnbd3_listen_port: "5003" dnbd3_client_penalty: "100000" -dnbd3_primary: "{{ hostvars[dnbd3_primary]['ansible_default_ipv4']['address'] }}" +dnbd3_primary: "{{ hostvars['dnbd3-primary.galaxyproject.eu']['ansible_default_ipv4']['address'] }}" dnbd3_primary_comment: "Primary DNBD3 server, which replicates S3FS mounted QCOW2 images." # dnbd3_primary_backup: "10.20.56.174" # dnbd3_primary_backup_comment: "Secondary/backup DNBD3 server, which replicates S3FS mounted QCOW2 images." dnbd3_poxys: - - ip: "{{ hostvars[dnbd3_proxy]['ansible_default_ipv4']['address'] }}" + - ip: "{{ hostvars[dnbd3-proxy]['ansible_default_ipv4']['address'] }}" comment: "1st DNBD3 Proxy" - - -# --- dnbd3 build vars --- -dnbd3_src_dir: "/usr/local/src/dnbd3" -dnbd3_build_dir: "{{ dnbd3_src_dir }}/build" -dnbd3_server_binary: "/usr/local/sbin/dnbd3-server" -dnbd3_new_binary: "{{ dnbd3_src_dir }}/dnbd3-server.new" -dnbd3_old_binary: "{{ dnbd3_src_dir }}/dnbd3-server.old" - -# --- dnbd3 systemd vars --- -dnbd3_systemd_dir: "/etc/systemd/system" -dnbd3_service_dir: "{{ dnbd3_systemd_dir }}/dnbd3-server.service.d" -dnbd3_service_file: "{{ dnbd3_systemd_dir }}/dnbd3-server.service" -dnbd3_limits_file: "{{ dnbd3_service_dir }}/limits.conf" -dnbd3_srv_mount_file: "{{ dnbd3_systemd_dir }}/srv.mount" diff --git a/group_vars/dnbd3_primary/vars.yml b/group_vars/dnbd3primary/vars.yml similarity index 51% rename from group_vars/dnbd3_primary/vars.yml rename to group_vars/dnbd3primary/vars.yml index 81ec927bf..16e9f1a93 100644 --- a/group_vars/dnbd3_primary/vars.yml +++ b/group_vars/dnbd3primary/vars.yml @@ -3,6 +3,8 @@ dnbd3_is_proxy: false dnbd3_base_path: "/export/dnbd3-cache/images" tftpboot_path: "/export/dnbd3-cache/boot" apache_listen_port: 80 +apache_remove_default_vhost: true apache_vhosts: - - servername: "example.com" + - servername: "dnbd3-primary.galaxyproject.eu" + serveralias: "{{ hostvars['dnbd3-primary.galaxyproject.eu']['ansible_default_ipv4']['address'] }}" documentroot: "/export/dnbd3-cache/http" diff --git a/group_vars/dnbd3_proxy/vars.yml b/group_vars/dnbd3proxy/vars.yml similarity index 100% rename from group_vars/dnbd3_proxy/vars.yml rename to group_vars/dnbd3proxy/vars.yml diff --git a/hosts b/hosts index 96a074438..b5d7c8e13 100644 --- a/hosts +++ b/hosts @@ -96,11 +96,11 @@ ansible_group_priority=4 apps.galaxyproject.eu ansible_ssh_user=ubuntu [dnbd3:children] -dnbd3-primary -dnbd3-proxy +dnbd3primary +dnbd3proxy -[dnbd3-primary] +[dnbd3primary] dnbd3-primary.galaxyproject.eu ansible_ssh_user=root -[dnbd3-proxy] +[dnbd3proxy] dnbd3-proxy.galaxyproject.eu