Streamlining setup of nginx base requriements

This commit is contained in:
shockrah 2024-04-20 13:23:24 -07:00
parent 7edf24ba20
commit c09dd6203f
6 changed files with 34 additions and 68 deletions

View File

@ -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/

View File

@ -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 }}"

View File

@ -2,6 +2,13 @@
--- ---
- hosts: webhost - hosts: webhost
remote_user: root remote_user: root
vars:
websites:
- shockrah.xyz
- temper.tv
- resume.shockrah.xyz
tasks: tasks:
- name: Setup nginx - name: Setup nginx
import_tasks: ../tasks/nginx-setup.yml import_tasks: ../tasks/nginx-setup.yml
- name: Test local sites
import_tasks: ../tasks/tests/local-site-presence.yml

View File

@ -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

View File

@ -14,7 +14,7 @@
path: /opt/nginx path: /opt/nginx
- name: Copy over the nginx.conf files for each server - name: Copy over the nginx.conf files for each server
copy: copy:
src: "files/{{ item }}" src: "../files/{{ item }}"
dest: /etc/nginx/sites-available/ dest: /etc/nginx/sites-available/
loop: loop:
- shockrah.xyz.conf - shockrah.xyz.conf

View File

@ -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 }}"