diff --git a/ansible/nuc.yaml b/ansible/nuc.yaml index 81f1f7d..cd3acbc 100644 --- a/ansible/nuc.yaml +++ b/ansible/nuc.yaml @@ -6,7 +6,6 @@ tags: - setup - nomad - - proxy - volumes ansible.builtin.include_role: name: local-server-head diff --git a/ansible/proxy.yaml b/ansible/proxy.yaml new file mode 100644 index 0000000..e729306 --- /dev/null +++ b/ansible/proxy.yaml @@ -0,0 +1,7 @@ +--- +- hosts: nigel.local + remote_user: nigel + tasks: + - name: Apply reverse proxy role + ansible.builtin.include_role: + name: proxy \ No newline at end of file diff --git a/ansible/roles/local-server-head/tasks/main.yaml b/ansible/roles/local-server-head/tasks/main.yaml index 373f75d..6dfecc3 100644 --- a/ansible/roles/local-server-head/tasks/main.yaml +++ b/ansible/roles/local-server-head/tasks/main.yaml @@ -23,14 +23,6 @@ become: true tags: - nomad -- name: Setup the reverse proxy outside of nomad - tags: proxy - ansible.builtin.include_tasks: - file: reverse_proxy.yaml - apply: - become: true - tags: - - proxy - name: Setup data directory for the nomad host volumes tags: volumes ansible.builtin.include_tasks: diff --git a/ansible/roles/local-server-head/tasks/reverse_proxy.yaml b/ansible/roles/local-server-head/tasks/reverse_proxy.yaml deleted file mode 100644 index 85ebff5..0000000 --- a/ansible/roles/local-server-head/tasks/reverse_proxy.yaml +++ /dev/null @@ -1,31 +0,0 @@ -- name: Keep /etc/hosts up to date - ansible.builtin.copy: - dest: /etc/hosts - src: host-file - mode: "0644" -- name: Ensure nginx is setup as latest - ansible.builtin.apt: - name: nginx -- name: Copy the nomad.conf to available configurations - ansible.builtin.copy: - src: "{{ item }}" - dest: "/etc/nginx/sites-available/{{ item }}" - mode: "0644" - loop: - - nomad.conf - - sanity.conf - - ncr.conf -- name: Link the nomad.conf to sites-enabled - ansible.builtin.file: - path: "/etc/nginx/sites-enabled/{{ item }}" - state: link - src: "/etc/nginx/sites-available/{{ item }}" - mode: "0644" - loop: - - nomad.conf - - sanity.conf - - ncr.conf -- name: Restart nginx - ansible.builtin.systemd_service: - name: nginx - state: restarted \ No newline at end of file diff --git a/ansible/roles/local-server-head/files/host-file b/ansible/roles/proxy/files/host-file similarity index 100% rename from ansible/roles/local-server-head/files/host-file rename to ansible/roles/proxy/files/host-file diff --git a/ansible/roles/local-server-head/files/ncr.conf b/ansible/roles/proxy/files/ncr.conf similarity index 100% rename from ansible/roles/local-server-head/files/ncr.conf rename to ansible/roles/proxy/files/ncr.conf diff --git a/ansible/roles/local-server-head/files/nomad.conf b/ansible/roles/proxy/files/nomad.conf similarity index 100% rename from ansible/roles/local-server-head/files/nomad.conf rename to ansible/roles/proxy/files/nomad.conf diff --git a/ansible/roles/proxy/tasks/main.yaml b/ansible/roles/proxy/tasks/main.yaml new file mode 100644 index 0000000..78ddccc --- /dev/null +++ b/ansible/roles/proxy/tasks/main.yaml @@ -0,0 +1,32 @@ +- name: Reverse proxy role configuration + become: true + vars: + nginx_configs: + - nomad.conf + - ncr.conf + block: + - name: Ensure /etc/hosts are up to date + ansible.builtin.copy: + dest: /etc/hosts + src: host-file + mode: "0644" + - name: Ensure nginx is setup as latest + ansible.builtin.apt: + name: nginx + - name: Copy the nomad.conf to available configurations + ansible.builtin.copy: + src: "{{ item }}" + dest: "/etc/nginx/sites-available/{{ item }}" + mode: "0644" + loop: "{{ nginx_configs }}" + - name: Link the nomad.conf to sites-enabled + ansible.builtin.file: + path: "/etc/nginx/sites-enabled/{{ item }}" + state: link + src: "/etc/nginx/sites-available/{{ item }}" + mode: "0644" + loop: "{{ nginx_configs }}" + - name: Restart nginx + ansible.builtin.systemd_service: + name: nginx + state: restarted