From bb6337251e6b1100a61f932677a54124672d4c97 Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Wed, 4 Sep 2019 02:19:50 +0200 Subject: Add first stage for getting the certificates generated Signed-off-by: Denis 'GNUtoo' Carikli --- README | 20 ++++++ ftp.replicant.us.scm | 8 +-- ftp.replicant.us_stage1.scm | 144 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 README create mode 100644 ftp.replicant.us_stage1.scm diff --git a/README b/README new file mode 100644 index 0000000..322f2a3 --- /dev/null +++ b/README @@ -0,0 +1,20 @@ +== Deployment == +- Install GuiX from the live image to be sure that the derivations + matches with the build servers. + If we instead generate a vm image directly, we may end up having to + often compile many packages because of some derivation mismatches. + TODO: Check with GuiX developers if this is really a concern. +- Add a strong password to prevent login inside the vm administration + or see with the FSF what are their requirements. +- scp ftp.replicant.us_stage1.scm to the remote vm and run + guix system reconfigure ftp.replicant.us_stage1.scm +- run /var/lib/certbot/renew-certificates to generate the letsencrypt + certificates +- Then you can copy ftp.replicant.us_stage1.scm on the vm + and run guix system reconfigure ftp.replicant.us.scm + +== TODO == +- Make a service that runs the IPv6 setup commands +- Use only one file for the two stage deployment maybe by switching + to use a manual challenge in certbot. Here the certbot log indicate + that webroot was used here. diff --git a/ftp.replicant.us.scm b/ftp.replicant.us.scm index ed7a7f4..459979a 100644 --- a/ftp.replicant.us.scm +++ b/ftp.replicant.us.scm @@ -1,16 +1,13 @@ ;; TODO before migration ;; - Change the IP address ;; - Change the domain name with the certificates -;; TODO to be useful: -;; - Switch to NginX -;; - Certificates ;; TODO after: ;; - rsync from osuosl ;; - rsync service (use-modules (gnu)) (use-service-modules certbot networking ssh web) -(use-package-modules admin base emacs rsync screen version-control vim web) +(use-package-modules admin base emacs rsync screen tls version-control vim web) ;; Variables specific to the vm ;; Change them when deploying this configuration in production @@ -65,6 +62,7 @@ (packages (append (list (specification->package "nss-certs") + certbot emacs-no-x git htop @@ -109,6 +107,7 @@ (service certbot-service-type (certbot-configuration (email "contact@replicant.us") + (default-location #f) ;; /!\ When deploying rsync, Only act as an rsync master ;; and not client, else any person controlling the server ;; from which we rsync may be able to get certificates issues @@ -119,6 +118,7 @@ (certificate-configuration (domains `((unquote %vm-domain-name))) (deploy-hook %nginx-deploy-hook) + (challenge #f) ) ) ) diff --git a/ftp.replicant.us_stage1.scm b/ftp.replicant.us_stage1.scm new file mode 100644 index 0000000..c464d02 --- /dev/null +++ b/ftp.replicant.us_stage1.scm @@ -0,0 +1,144 @@ +;; TODO before migration +;; - Change the IP address +;; - Change the domain name with the certificates +;; TODO after: +;; - rsync from osuosl +;; - rsync service + +(use-modules (gnu)) +(use-service-modules certbot networking ssh web) +(use-package-modules admin base emacs rsync screen tls version-control vim web) + +;; Variables specific to the vm +;; Change them when deploying this configuration in production +(define %vm-domain-name "ftp.replicant.cyberdimension.org") +;; TODO: +;; - Define IPv4 and IPv6 configuration here + +;; Hack to Add IPv6 support +(write "Hack to Add static IPv6 support:") +(system "ip addr add 2001:910:1314:ffff:ffff::43/80 dev eth0 || true") +(system "ip route add default via 2001:910:1314:ffff:ffff::1 || true") + + +(define %nginx-deploy-hook + (program-file + "nginx-deploy-hook" + #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read))) + (kill pid SIGHUP)))) + +(operating-system + (host-name %vm-domain-name) + (locale "en_US.utf8") + (timezone "America/New_York") + (bootloader + (bootloader-configuration + (bootloader grub-bootloader) + (target "/dev/vda"))) + (file-systems + (cons* (file-system + (mount-point "/") + (device + (uuid "b1ecb69d-4bb6-4bcf-9ab6-6a4d40c227f8" + 'ext4)) + (type "ext4")) + %base-file-systems)) + + (users (cons* (user-account + (name "gnutoo") + (comment "GNUtoo") + (group "users") + (home-directory "/home/gnutoo") + (supplementary-groups + '("wheel"))) + (user-account + (name "putti") + (comment "Putti") + (group "users") + (home-directory "/home/putti") + (supplementary-groups + '("wheel"))) + %base-user-accounts)) + (packages + (append + (list (specification->package "nss-certs") + certbot + emacs-no-x + git + htop + rsync + screen + vim) + %base-packages)) + (services + (append + (list (service openssh-service-type + (openssh-configuration + (port-number 222) + (permit-root-login #t) + (password-authentication? #f) + (challenge-response-authentication? #f) + (authorized-keys + `(("root", (local-file "keys/gnutoo.pub"), + (local-file "keys/putti.pub")) + ("gnutoo", (local-file "keys/gnutoo.pub")) + ("putti", (local-file "keys/putti.pub")) + ) + ) + (use-pam? #f))) + + ;; A public IP address is needed to test that configuration file as + ;; things like letsencrypt depends on it. + ;; The vm will have a public IPv4 IP address when deployed, however + ;; for testing we still need some sort of public IP address. + ;; As the static-networking-service doesn't have ipv6 support yet, + ;; because a netlink guile binding would be required to add support + ;; for it in a clean way. It will eventually get done as it seem + ;; important for GuiX to get it done. + ;; In the mean time, we either need to switch to DHCP for testing and + ;; get a public IPv6 address through that, or use some OpenVPN service + ;; to get a public IPv4 address. + (static-networking-service "eth0" "192.168.10.43" + #:gateway "192.168.10.1" + #:netmask "255.255.255.0" + #:name-servers '("192.168.10.1" + "192.168.10.2")) + + (service certbot-service-type + (certbot-configuration + (email "contact@replicant.us") + (default-location #f) + ;; /!\ When deploying rsync, Only act as an rsync master + ;; and not client, else any person controlling the server + ;; from which we rsync may be able to get certificates issues + ;; for ftp.replicant.us + (webroot "/srv/ftp") + (certificates + (list + (certificate-configuration + (domains `((unquote %vm-domain-name))) + (deploy-hook %nginx-deploy-hook) + (challenge #f) + ) + ) + ) + ) + ) + + ;; Nginx has more of its configuration available through GuiX than + ;; apache + (service nginx-service-type + (nginx-configuration + (server-blocks + (list + (nginx-server-configuration + (listen '("80")) + (root "/srv/ftp/")) + ) + ) + ) + ) + ) + %base-services) + ) + ) -- cgit v1.2.3