From e2ac53e627a9342ab2999673c8e726899c4cc01f Mon Sep 17 00:00:00 2001 From: Kekskurse Date: Mon, 18 Jan 2021 00:34:34 +0100 Subject: [PATCH] Stuff --- app/Console/Kernel.php | 4 +- resources/ansible/hosts.yml | 6 ++- resources/ansible/playbook.yml | 82 ++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 3 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2eab6d2..a33ee2e 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -29,9 +29,9 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - $schedule->command('calculate:space')->hourlyAt(10)->withoutOverlapping(); + //$schedule->command('calculate:space')->hourlyAt(10)->withoutOverlapping(); //$schedule->command('calculate:traffic')->hourlyAt(10)->withoutOverlapping(); - $schedule->command('calculate:traffic')->everyFiveMinutes(); + //$schedule->command('calculate:traffic')->everyFiveMinutes(); } /** diff --git a/resources/ansible/hosts.yml b/resources/ansible/hosts.yml index 39c8b73..cecd9d5 100644 --- a/resources/ansible/hosts.yml +++ b/resources/ansible/hosts.yml @@ -1,9 +1,13 @@ all: children: + pweb: + hosts: + www1.fra.kuvia.cloud: + http_domain: www.kuvia.cloud web: hosts: www1.fra.kuvia.cloud: - domain: www1.fra.kuvia.cloud www.kuvia.cloud kuvia.cloud + domain: www1.fra.kuvia.cloud mysql: hosts: diff --git a/resources/ansible/playbook.yml b/resources/ansible/playbook.yml index d7c2d62..2ffffeb 100644 --- a/resources/ansible/playbook.yml +++ b/resources/ansible/playbook.yml @@ -153,6 +153,10 @@ rule: allow port: '443' proto: tcp + - name: Check if certificat exists + stat: + path: "/etc/letsencrypt/live/{{domain}}/privkey.pem" + register: ssl_result - name: Template a file to /etc/file.conf ansible.builtin.template: src: nginx.j2 @@ -160,6 +164,8 @@ owner: root group: root mode: '0644' + vars: + - ssl: "{{ ssl_result.stat.exists }}" - name: Create a symbolic link ansible.builtin.file: src: /etc/nginx/sites-available/kuvia @@ -192,3 +198,79 @@ state: restarted daemon_reload: no name: php7.4-fpm + - name: Install certbot + apt: + name: certbot + state: present + - name: Install python3-certbot-nginx + apt: + name: python3-certbot-nginx + state: present + - name: Cert bot + ansible.builtin.shell: "certbot --nginx -d {{domain}} -n --agree-tos -m hello@kekskurse.de" + when: not ssl_result.stat.exists + - name: Template a file to /etc/file.conf + ansible.builtin.template: + src: nginx.j2 + dest: /etc/nginx/sites-available/kuvia_main + owner: root + group: root + mode: '0644' + vars: + - ssl: "{{ ssl_result.stat.exists }}" + - name: Restart nginx + ansible.builtin.systemd: + state: restarted + daemon_reload: no + name: nginx +- hosts: pweb + tasks: + - name: Domain + ansible.builtin.debug: + msg: "Domain: {{http_domain}}" + - name: Check if certificat exists + stat: + path: "/etc/letsencrypt/live/{{http_domain}}/privkey.pem" + register: ssl_result + - name: Template a file to /etc/file.conf + ansible.builtin.template: + src: nginx.j2 + dest: /etc/nginx/sites-available/kuvia_main + owner: root + group: root + mode: '0644' + vars: + - ssl: "{{ ssl_result.stat.exists }}" + - domain: "{{ http_domain }}" + - name: Create a symbolic link + ansible.builtin.file: + src: /etc/nginx/sites-available/kuvia_main + dest: /etc/nginx/sites-enabled/kuvia_main + state: link + - name: Restart nginx + ansible.builtin.systemd: + state: restarted + daemon_reload: no + name: nginx + - name: Cert bot + ansible.builtin.shell: "certbot --nginx -d {{http_domain}} -n --agree-tos -m hello@kekskurse.de" + when: not ssl_result.stat.exists + - name: Check if certificat exists + stat: + path: "/etc/letsencrypt/live/{{http_domain}}/privkey.pem" + register: ssl_result + - name: Template a file to /etc/file.conf + ansible.builtin.template: + src: nginx.j2 + dest: /etc/nginx/sites-available/kuvia_main + owner: root + group: root + mode: '0644' + vars: + - ssl: "{{ ssl_result.stat.exists }}" + - domain: "{{ http_domain }}" + - name: Restart nginx + ansible.builtin.systemd: + state: restarted + daemon_reload: no + name: nginx