From c09dd6203febf72883084483fe8ea4759f8b7c12 Mon Sep 17 00:00:00 2001 From: shockrah Date: Sat, 20 Apr 2024 13:23:24 -0700 Subject: [PATCH] Streamlining setup of nginx base requriements --- .../ansible/playbooks/download-publics.yml | 20 ----------- .../playbooks/remote-localized-curl-tests.yml | 35 ------------------- .../ansible/playbooks/static-host-setup.yml | 7 ++++ .../ansible/playbooks/test-setup.yml | 12 ------- .../ansible/tasks/nginx-setup.yml | 2 +- .../tasks/tests/local-site-presence.yml | 26 ++++++++++++++ 6 files changed, 34 insertions(+), 68 deletions(-) delete mode 100644 infra/static-vultr/ansible/playbooks/download-publics.yml delete mode 100644 infra/static-vultr/ansible/playbooks/remote-localized-curl-tests.yml delete mode 100644 infra/static-vultr/ansible/playbooks/test-setup.yml create mode 100644 infra/static-vultr/ansible/tasks/tests/local-site-presence.yml diff --git a/infra/static-vultr/ansible/playbooks/download-publics.yml b/infra/static-vultr/ansible/playbooks/download-publics.yml deleted file mode 100644 index 802d563..0000000 --- a/infra/static-vultr/ansible/playbooks/download-publics.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- hosts: webhost - remote_user: root - vars: - websites: - - shockrah.xyz - tasks: - - name: Remove wget - apt: - name: wget - state: absent - - name: Clean out /opt/nginx/ - file: - path: /opt/nginx/ - state: absent - - name: Ensure /opt/nginx is still present - file: - state: directory - owner: nginx - path: /opt/nginx/ diff --git a/infra/static-vultr/ansible/playbooks/remote-localized-curl-tests.yml b/infra/static-vultr/ansible/playbooks/remote-localized-curl-tests.yml deleted file mode 100644 index 7a4d120..0000000 --- a/infra/static-vultr/ansible/playbooks/remote-localized-curl-tests.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -- hosts: webhost - remote_user: root - vars: - websites: - - shockrah.xyz - - resume.shockrah.xyz - - temper.tv - tasks: - - name: Add local routing for the server confs - lineinfile: - path: /etc/hosts - state: present - line: "127.0.0.1 {{ item }}" - loop: "{{ websites }}" - - name: Curl the local endpoints to check connection nginx reverse proxy - uri: - url: "http://{{ item }}" - status_code: - - 200 - - 404 - loop: "{{ websites }}" - - name: Sanity Check the nginx reverse proxy - uri: - url: "http://not-real.{{ item }}" - loop: "{{ websites }}" - register: result - failed_when: result.status != -1 - - name: Cleanup /etc/hosts - lineinfile: - path: /etc/hosts - state: absent - line: "127.0.0.1 {{ item }}" - loop: "{{ websites }}" - diff --git a/infra/static-vultr/ansible/playbooks/static-host-setup.yml b/infra/static-vultr/ansible/playbooks/static-host-setup.yml index 8df5a53..f325ef6 100644 --- a/infra/static-vultr/ansible/playbooks/static-host-setup.yml +++ b/infra/static-vultr/ansible/playbooks/static-host-setup.yml @@ -2,6 +2,13 @@ --- - hosts: webhost remote_user: root + vars: + websites: + - shockrah.xyz + - temper.tv + - resume.shockrah.xyz tasks: - name: Setup nginx import_tasks: ../tasks/nginx-setup.yml + - name: Test local sites + import_tasks: ../tasks/tests/local-site-presence.yml diff --git a/infra/static-vultr/ansible/playbooks/test-setup.yml b/infra/static-vultr/ansible/playbooks/test-setup.yml deleted file mode 100644 index cc2e3b8..0000000 --- a/infra/static-vultr/ansible/playbooks/test-setup.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- hosts: webhost - remote_user: root - tasks: - - name: Echo something - shell: echo 'Testing playbook' - - - name: Testing HTTP egress - shell: curl http://google.com - - - name: Testing HTTPS egress - shell: curl https://google.com diff --git a/infra/static-vultr/ansible/tasks/nginx-setup.yml b/infra/static-vultr/ansible/tasks/nginx-setup.yml index 9c2fcbb..8e7496c 100644 --- a/infra/static-vultr/ansible/tasks/nginx-setup.yml +++ b/infra/static-vultr/ansible/tasks/nginx-setup.yml @@ -14,7 +14,7 @@ path: /opt/nginx - name: Copy over the nginx.conf files for each server copy: - src: "files/{{ item }}" + src: "../files/{{ item }}" dest: /etc/nginx/sites-available/ loop: - shockrah.xyz.conf diff --git a/infra/static-vultr/ansible/tasks/tests/local-site-presence.yml b/infra/static-vultr/ansible/tasks/tests/local-site-presence.yml new file mode 100644 index 0000000..3e0023c --- /dev/null +++ b/infra/static-vultr/ansible/tasks/tests/local-site-presence.yml @@ -0,0 +1,26 @@ + - name: Add local routing for the server confs + lineinfile: + path: /etc/hosts + state: present + line: "127.0.0.1 {{ item }}" + loop: "{{ websites }}" + - name: Curl the local endpoints to check connection nginx reverse proxy + uri: + url: "http://{{ item }}" + status_code: + - 200 + - 404 + loop: "{{ websites }}" + - name: Sanity Check the nginx reverse proxy + uri: + url: "http://not-real.{{ item }}" + loop: "{{ websites }}" + register: result + failed_when: result.status != -1 + - name: Cleanup /etc/hosts + lineinfile: + path: /etc/hosts + state: absent + line: "127.0.0.1 {{ item }}" + loop: "{{ websites }}" +