2021-12-27 08:58:52 -08:00
|
|
|
---
|
|
|
|
|
|
|
|
|
|
- name: create paths
|
|
|
|
|
file:
|
|
|
|
|
path: /srv/nextcloud/{item}
|
|
|
|
|
state: directory
|
2022-01-02 13:01:20 -08:00
|
|
|
recurse: true
|
2021-12-27 08:58:52 -08:00
|
|
|
with_items:
|
|
|
|
|
- db
|
|
|
|
|
- data
|
2022-01-02 13:01:20 -08:00
|
|
|
- nginx/conf.d
|
2021-12-27 08:58:52 -08:00
|
|
|
|
2022-01-01 14:55:44 -08:00
|
|
|
- name: install docker
|
|
|
|
|
apt:
|
|
|
|
|
force_apt_get: yes
|
|
|
|
|
name: "{{ packages }}"
|
|
|
|
|
vars:
|
|
|
|
|
packages:
|
|
|
|
|
- docker.io
|
|
|
|
|
- docker-compose
|
2022-01-02 13:01:20 -08:00
|
|
|
- openssl
|
2022-01-01 14:55:44 -08:00
|
|
|
|
|
|
|
|
- name: Add users to docker group
|
|
|
|
|
user:
|
|
|
|
|
name: "{{ item }}"
|
|
|
|
|
groups: docker
|
|
|
|
|
append: yes
|
|
|
|
|
with_items:
|
|
|
|
|
- ubuntu
|
|
|
|
|
|
2022-01-02 13:01:20 -08:00
|
|
|
# --
|
|
|
|
|
|
|
|
|
|
- name: check for existing cert
|
|
|
|
|
stat:
|
|
|
|
|
path: /srv/nextcloud/letsencrypt/etc/live/cloud.stoopid.club
|
|
|
|
|
register: certpath
|
|
|
|
|
|
|
|
|
|
- name: seed initial cert data
|
|
|
|
|
command: |
|
|
|
|
|
docker run -it --rm --name certbot \
|
|
|
|
|
-v "/srv/nextcloud/letsencrypt/etc:/etc/letsencrypt" \
|
|
|
|
|
-v "/srv/nextcloud/letsencrypt/var:/var/lib/letsencrypt" \
|
|
|
|
|
-p 80:80 \
|
|
|
|
|
certbot/certbot:arm64v8-latest certonly \
|
|
|
|
|
-m erik@erikstambaugh.com \
|
|
|
|
|
--agree-tos \
|
|
|
|
|
-n \
|
|
|
|
|
--standalone \
|
|
|
|
|
-d cloud.stoopid.club
|
|
|
|
|
when: certpath.stat.isdir is not defined
|
|
|
|
|
|
|
|
|
|
#docker run -it --rm --name certbot \
|
|
|
|
|
# -v "/etc/letsencrypt:/etc/letsencrypt" \
|
|
|
|
|
# -v "/var/lib/letsencrypt:/var/lib/letsencrypt" \
|
|
|
|
|
# certbot/certbot:arm32v6-latest certonly \
|
|
|
|
|
# -m erik@erikstambaugh.com \
|
|
|
|
|
# --agree-tos \
|
|
|
|
|
# --standalone \
|
|
|
|
|
# --dry-run \
|
|
|
|
|
# -p 80:80 \
|
|
|
|
|
# -d cloud.stoopid.club
|
|
|
|
|
## certbot/certbot:arm32v6-latest certonly --help
|
|
|
|
|
|
|
|
|
|
- name: pick up latest nginx ssl config
|
|
|
|
|
get_url:
|
|
|
|
|
url: https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf
|
|
|
|
|
dest: /srv/nextcloud/letsencrypt/etc/options-ssl-nginx.conf
|
|
|
|
|
register: certbotnginx
|
|
|
|
|
|
|
|
|
|
- name: check for dhparams
|
|
|
|
|
stat:
|
|
|
|
|
path: /srv/nextcloud/letsencrypt/etc/ssl-dhparams.pem
|
|
|
|
|
register: dhparams
|
|
|
|
|
|
|
|
|
|
- name: "create dhparams (this could take up to an hour)"
|
|
|
|
|
command: openssl dhparam -out ssl-dhparams.pem 4096
|
|
|
|
|
args:
|
|
|
|
|
chdir: /srv/nextcloud/letsencrypt/etc
|
|
|
|
|
when: dhparams.stat.exists == False
|
|
|
|
|
|
2022-01-02 08:25:58 -08:00
|
|
|
# ---
|
|
|
|
|
|
|
|
|
|
- name: nextcloud docker-compose
|
|
|
|
|
copy:
|
|
|
|
|
src: files/docker-compose.yaml
|
|
|
|
|
dest: /srv/nextcloud/docker-compose.yaml
|
|
|
|
|
register: dockercompose
|
|
|
|
|
|
2022-01-02 13:01:20 -08:00
|
|
|
- name: nextcloud nginx.conf
|
|
|
|
|
copy:
|
|
|
|
|
src: files/nginx.conf
|
|
|
|
|
dest: /srv/nextcloud/nginx/nginx.conf
|
|
|
|
|
register: nginxconf
|
|
|
|
|
|
2022-01-02 08:25:58 -08:00
|
|
|
- name: install nextcloud
|
|
|
|
|
command: docker-compose up -d
|
|
|
|
|
args:
|
|
|
|
|
chdir: /srv/nextcloud
|
|
|
|
|
|
2022-01-02 13:01:20 -08:00
|
|
|
- name: restart nextcloud
|
2022-01-02 08:25:58 -08:00
|
|
|
command: docker-compose restart
|
|
|
|
|
args:
|
|
|
|
|
chdir: /srv/nextcloud
|
2022-01-02 13:01:20 -08:00
|
|
|
when: nginxconf.changed or certbotnginx.changed
|
2022-01-02 08:25:58 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---
|
|
|
|
|
|
2022-01-01 14:55:44 -08:00
|
|
|
- name: do some cleanup
|
|
|
|
|
command: "{{item}}"
|
|
|
|
|
with_items:
|
|
|
|
|
- "docker image prune -a --force"
|
|
|
|
|
- "docker system prune --volumes --force"
|
|
|
|
|
|