Skip to content

Commit

Permalink
Use Ansible for uploading files and managing NGINX
Browse files Browse the repository at this point in the history
  • Loading branch information
opdavies committed May 3, 2024
1 parent 45e8206 commit cd6575c
Show file tree
Hide file tree
Showing 7 changed files with 489 additions and 3 deletions.
1 change: 1 addition & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ language: php
flake:
devshell:
packages:
- ansible
- nodePackages.pnpm
- nodejs
- php82
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
inherit (pkgs) mkShell;
in {
devShells.${system}.default =
mkShell { buildInputs = with pkgs; [ nodePackages.pnpm nodejs php82 php82Packages.composer ]; };
mkShell { buildInputs = with pkgs; [ ansible nodePackages.pnpm nodejs php82 php82Packages.composer ]; };

formatter.${system} = pkgs.nixfmt;
};
Expand Down
5 changes: 3 additions & 2 deletions run.local
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ function publish {
npm:build:css
generate

rsync --archive --verbose --compress --update --delete \
output_prod/ ssh.oliverdavies.uk:/srv/oliverdavies.uk-sculpin
ansible-playbook tools/ansible/deploy.yaml \
-i tools/ansible/hosts.ini \
--ask-become-pass

git stash pop
}
Expand Down
18 changes: 18 additions & 0 deletions tools/ansible/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- hosts: all

vars:
project_dir: /srv/www.oliverdavies.uk

tasks:
- ansible.builtin.file:
path: "{{ project_dir }}"
state: directory
owner: opdavies
group: opdavies
become: true

- ansible.builtin.synchronize:
src: ../../output_prod/
dest: "{{ project_dir }}"
delete: true
1 change: 1 addition & 0 deletions tools/ansible/hosts.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh.oliverdavies.uk
16 changes: 16 additions & 0 deletions tools/ansible/reload-nginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- hosts: all
become: true

vars:
domain: www.oliverdavies.uk

tasks:
- ansible.builtin.copy:
src: ../nginx/{{ domain }}.conf
dest: /etc/nginx/sites-available/{{ domain }}.conf

- ansible.builtin.file:
src: /etc/nginx/sites-available/{{ domain }}.conf
dest: /etc/nginx/sites-enabled/{{ domain }}.conf
state: link
449 changes: 449 additions & 0 deletions tools/nginx/www.oliverdavies.uk.conf

Large diffs are not rendered by default.

0 comments on commit cd6575c

Please sign in to comment.