|
@@ -24,6 +24,10 @@ container_uid: uid of above user name
|
|
container_group: group name of container_user
|
|
container_group: group name of container_user
|
|
container_gid: gid of above group name
|
|
container_gid: gid of above group name
|
|
|
|
|
|
|
|
+Automated pulls and purges are handled by systemd timers. Any valid [systemd timer calendar event expression](https://www.freedesktop.org/software/systemd/man/systemd.timer.html#OnCalendar=) may be passed to them:
|
|
|
|
+docker_pull_timer: weekly
|
|
|
|
+docker_purge_timer: monthly
|
|
|
|
+
|
|
global_env_vars: # will be set on any container which has include_global_env_vars: true
|
|
global_env_vars: # will be set on any container which has include_global_env_vars: true
|
|
- PUID={{ container_uid }}
|
|
- PUID={{ container_uid }}
|
|
- PGID={{ container_gid }}
|
|
- PGID={{ container_gid }}
|
|
@@ -40,7 +44,7 @@ This role sets up each container as an individual docker-compose.yml file with a
|
|
Outline any networks you need via container_networks:
|
|
Outline any networks you need via container_networks:
|
|
|
|
|
|
container_networks:
|
|
container_networks:
|
|
- - name: backend
|
|
|
|
|
|
+ - name: nginx-proxy
|
|
driver: bridge
|
|
driver: bridge
|
|
subnet: 172.21.10.0/24
|
|
subnet: 172.21.10.0/24
|
|
ip_range: 172.21.10.0/24
|
|
ip_range: 172.21.10.0/24
|
|
@@ -49,33 +53,83 @@ Outline any networks you need via container_networks:
|
|
And specify those networks in the corresponding container's dictionary:
|
|
And specify those networks in the corresponding container's dictionary:
|
|
|
|
|
|
containers:
|
|
containers:
|
|
- - name: nginx
|
|
|
|
|
|
+ - name: swag
|
|
active: true
|
|
active: true
|
|
- image: linuxserver/nginx
|
|
|
|
|
|
+ image: linuxserver/swag
|
|
ports:
|
|
ports:
|
|
- 80:80
|
|
- 80:80
|
|
- 443:443
|
|
- 443:443
|
|
volumes:
|
|
volumes:
|
|
- - /opt/nginx:/config
|
|
|
|
|
|
+ - /opt/swag:/config
|
|
include_global_env_vars: true
|
|
include_global_env_vars: true
|
|
|
|
+ environment:
|
|
|
|
+ - URL=myexamplesite.biz
|
|
|
|
+ - VALIDATION=http
|
|
|
|
+ - SUBDOMAINS=www,git,
|
|
|
|
+ - EMAIL=admin@myexamplesite.biz
|
|
restart: unless-stopped
|
|
restart: unless-stopped
|
|
memlimit: 300m
|
|
memlimit: 300m
|
|
networks:
|
|
networks:
|
|
- - backend
|
|
|
|
|
|
+ - nginx-proxy
|
|
|
|
|
|
- - name: mysql
|
|
|
|
|
|
+ - name: gogs
|
|
active: true
|
|
active: true
|
|
- image: mysql
|
|
|
|
|
|
+ image: gogs/gogs
|
|
|
|
+ ports:
|
|
|
|
+ - "10022:22" # https://github.com/go-yaml/yaml/issues/34#issuecomment-55772666
|
|
volumes:
|
|
volumes:
|
|
- - /opt/mysql:/var/lib/mysql
|
|
|
|
|
|
+ - /opt/gogs:/data
|
|
include_global_env_vars: false
|
|
include_global_env_vars: false
|
|
- environment:
|
|
|
|
- - MYSQL_ROOT_PASSWORD="{{ vaulted_mysql_root_password }}"
|
|
|
|
restart: unless-stopped
|
|
restart: unless-stopped
|
|
memlimit: 500m
|
|
memlimit: 500m
|
|
networks:
|
|
networks:
|
|
- - backend
|
|
|
|
|
|
+ - nginx-proxy
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+Usage
|
|
|
|
+-----
|
|
|
|
+
|
|
|
|
+This role creates docker-compose.yml files for each entry in the list of containers under the filename:<br>
|
|
|
|
+`/root/docker/<name>/docker-compose.yml`
|
|
|
|
+
|
|
|
|
+It also generates systemd services files of the name:<br>
|
|
|
|
+`/etc/systemd/system/<name>.service`
|
|
|
|
+
|
|
|
|
+This file is a simple wrapper around docker-compose:
|
|
|
|
+
|
|
|
|
+ [root@shareunderware ~]# systemctl cat swag.service
|
|
|
|
+ # /etc/systemd/system/swag.service
|
|
|
|
+ # This file is managed by Ansible. Any local changes may be wiped out!
|
|
|
|
+ [Unit]
|
|
|
|
+ Description=systemd wrapper around docker swag service
|
|
|
|
+ Requires=docker.service
|
|
|
|
+ After=docker.service
|
|
|
|
+
|
|
|
|
+ [Service]
|
|
|
|
+ Restart=always
|
|
|
|
+ User=root
|
|
|
|
+ Group=docker
|
|
|
|
+
|
|
|
|
+ ExecStartPre=/usr/bin/docker-compose -f /root/docker/swag/docker-compose.yml down -v
|
|
|
|
+ ExecStart=/usr/bin/docker-compose -f /root/docker/swag/docker-compose.yml up
|
|
|
|
+ ExecStop=/usr/bin/docker-compose -f /root/docker/swag/docker-compose.yml down -v
|
|
|
|
+
|
|
|
|
+ [Install]
|
|
|
|
+ WantedBy=multi-user.target
|
|
|
|
+
|
|
|
|
+This method allows the logs to be captured via journald and can be queried just like any other service:
|
|
|
|
|
|
|
|
+ [root@shareunderware ~]# journalctl -fu swag.service
|
|
|
|
+ Apr 25 04:20:59 shareunderware docker-compose[1956]: swag | [cont-init.d] 70-templates: exited 0.
|
|
|
|
+ Apr 25 04:20:59 shareunderware docker-compose[1956]: swag | [cont-init.d] 90-custom-folders: executing...
|
|
|
|
+ Apr 25 04:20:59 shareunderware docker-compose[1956]: swag | [cont-init.d] 90-custom-folders: exited 0.
|
|
|
|
+ Apr 25 04:20:59 shareunderware docker-compose[1956]: swag | [cont-init.d] 99-custom-files: executing...
|
|
|
|
+ Apr 25 04:20:59 shareunderware docker-compose[1956]: swag | [custom-init] no custom files found exiting...
|
|
|
|
+ Apr 25 04:20:59 shareunderware docker-compose[1956]: swag | [cont-init.d] 99-custom-files: exited 0.
|
|
|
|
+ Apr 25 04:20:59 shareunderware docker-compose[1956]: swag | [cont-init.d] done.
|
|
|
|
+ Apr 25 04:20:59 shareunderware docker-compose[1956]: swag | [services.d] starting services
|
|
|
|
+ Apr 25 04:20:59 shareunderware docker-compose[1956]: swag | [services.d] done.
|
|
|
|
+ Apr 25 04:21:03 shareunderware docker-compose[1956]: swag | Server ready
|
|
|
|
|
|
|
|
|
|
License
|
|
License
|