diff --git a/ansible/README.md b/ansible/README.md index d4839e027..ef0e7b03b 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -20,9 +20,12 @@ ansible -> roles -> nginx -> ssl -> .privkey.pem ``` 5. to run playbook ```bash -ansible-playbook ./playbook.yml -i --extra-vars "kuma_domain=" +ansible-playbook ./playbook.yml -i -e "kuma_domain=" -e "kuma_image_os=" -e "kuma_image_version=" ``` you can use other ansible playbook options too > Note: Replace `` with your desired domain for uptime kuma +> replace `` with a version from https://github.com/louislam/uptime-kuma/releases +> replace `` with one of options +> `-e "kuma_image_os=" -e "kuma_image_version="` is not required and you can remove this part or change only one of them (kuma_image_os is debian & kuma_image_version is 1 by default) > If you are not using root user as your ansible_user use -bK option to become root diff --git a/ansible/roles/nginx/tasks/main.yml b/ansible/roles/nginx/tasks/main.yml index 11ca80fa7..25cf89eac 100644 --- a/ansible/roles/nginx/tasks/main.yml +++ b/ansible/roles/nginx/tasks/main.yml @@ -4,16 +4,9 @@ state: directory loop: - /compose - - /compose/nginx - /compose/volumes - /compose/volumes/nginx - -- name: Ensure docker-compose file has been updated - template: - src: "{{item}}" - dest: /compose/nginx/ - loop: - - docker-compose.yml + - /compose/volumes/nginx/log/{{ kuma_domain }} - name: Ensure nginx config directory exist copy: @@ -27,9 +20,3 @@ template: src: "nginx.conf" dest: /compose/volumes/nginx/nginx.conf - -- name: Ensure nginx is up - community.docker.docker_compose: - state: present - project_src: /compose/nginx - pull: no diff --git a/ansible/roles/nginx/templates/docker-compose.yml b/ansible/roles/nginx/templates/docker-compose.yml deleted file mode 100644 index 02b367e45..000000000 --- a/ansible/roles/nginx/templates/docker-compose.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: '3.3' -services: - nginx: - network_mode: host - restart: always - image: nginx:stable-alpine - volumes: - - '/compose/volumes/nginx/:/etc/nginx/' \ No newline at end of file diff --git a/ansible/roles/nginx/templates/nginx.conf b/ansible/roles/nginx/templates/nginx.conf index fc23747ea..2e3486230 100644 --- a/ansible/roles/nginx/templates/nginx.conf +++ b/ansible/roles/nginx/templates/nginx.conf @@ -67,8 +67,8 @@ http { server_name {{ kuma_domain }}; listen 443 ssl http2 default_server; - access_log /var/log/nginx/yoursite.access.log main; - error_log /var/log/nginx/yoursite.error.log; + access_log /var/log/nginx/{{ kuma_domain }}.access.log main; + error_log /var/log/nginx/{{ kuma_domain }}.error.log; location / { # rewrite ^/(.*)/$ /$1 permanent; @@ -79,7 +79,7 @@ http { # } proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_pass http://localhost:3001/; + proxy_pass http://uptime-kuma:3001/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; diff --git a/ansible/roles/uptime-kuma/defaults/main.yml b/ansible/roles/uptime-kuma/defaults/main.yml new file mode 100644 index 000000000..7f2896862 --- /dev/null +++ b/ansible/roles/uptime-kuma/defaults/main.yml @@ -0,0 +1,3 @@ +--- +kuma_image_version: '1' +kuma_image_os: 'debian' diff --git a/ansible/roles/uptime-kuma/templates/docker-compose.yml b/ansible/roles/uptime-kuma/templates/docker-compose.yml index 54cca27dc..f87afc286 100644 --- a/ansible/roles/uptime-kuma/templates/docker-compose.yml +++ b/ansible/roles/uptime-kuma/templates/docker-compose.yml @@ -2,9 +2,18 @@ version: '3.3' services: uptime-kuma: restart: always - ports: - - '127.0.0.1:3001:3001' + expose: + - 3001 volumes: - '/compose/volumes/uptime-kuma:/app/data' container_name: uptime-kuma - image: 'louislam/uptime-kuma:alpine' + image: 'louislam/uptime-kuma:{{kuma_image_version}}-{{kuma_image_os}}' + + nginx: + depends_on: + - uptime-kuma + restart: always + image: nginx:stable-alpine + volumes: + - '/compose/volumes/nginx/:/etc/nginx/' + - '/compose/volumes/nginx/log/{{ kuma_domain }}:/var/log/nginx/{{ kuma_domain }}/'