Added caddy docker
This commit is contained in:
1 parent
8a6744a1b1
commit
5b8d77c839
7 files changed
+210
No files matched your search
Executable
+44
@@ -0,0 +1,44 @@
|
||||
---
|
||||
- hosts: all
|
||||
become: true
|
||||
vars_files:
|
||||
- vars/default.yml
|
||||
|
||||
tasks:
|
||||
- name: Pull Caddy image
|
||||
docker_image:
|
||||
name: "{{ caddy_image }}"
|
||||
source: pull
|
||||
force_source: yes
|
||||
|
||||
- name: Ensure Caddy Directories exist
|
||||
file:
|
||||
path: "/var/lib/{{ host_directory }}/{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
loop:
|
||||
- conf
|
||||
- site
|
||||
- data
|
||||
- config
|
||||
|
||||
- name: Ensure Caddyfile exists
|
||||
file:
|
||||
path: "/var/lib/{{ host_directory }}/conf/Caddyfile"
|
||||
state: touch
|
||||
mode: 0644
|
||||
|
||||
- name: Create caddy container
|
||||
docker_container:
|
||||
name: "{{ caddy_name }}"
|
||||
image: "{{ caddy_image }}"
|
||||
state: started
|
||||
restart_policy: unless-stopped
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- "/var/lib/{{ host_directory }}/conf:/etc/caddy"
|
||||
- "/var/lib/{{ host_directory }}/site:/srv"
|
||||
- "/var/lib/{{ host_directory }}/data:/data"
|
||||
- "/var/lib/{{ host_directory }}/config:/config"
|
||||
@@ -0,0 +1,46 @@
|
||||
# Docker on Ubuntu 18.04
|
||||
|
||||
This playbook will install Docker an Ubuntu 18.04 machine, as explained in the guide on
|
||||
[How to Use Ansible to Install and Set Up Docker on Ubuntu 18.04](https://www.digitalocean.com/community/tutorials/how-to-use-ansible-to-install-and-set-up-docker-on-ubuntu-18-04).
|
||||
A number of containers will be created with the options specified in the `vars/default.yml` variable file.
|
||||
|
||||
## Settings
|
||||
|
||||
- `create_containers`: number of containers to create.
|
||||
- `default_container_name`: default name for new containers.
|
||||
- `default_container_image`: default image for new containers.
|
||||
- `default_container_command`: default command to run on new containers.
|
||||
|
||||
|
||||
## Running this Playbook
|
||||
|
||||
Quick Steps:
|
||||
|
||||
### 1. Obtain the playbook
|
||||
```shell
|
||||
git clone https://github.com/do-community/ansible-playbooks.git
|
||||
cd ansible-playbooks/docker_ubuntu1804
|
||||
```
|
||||
|
||||
### 2. Customize Options
|
||||
|
||||
```shell
|
||||
nano vars/default.yml
|
||||
```
|
||||
|
||||
```yml
|
||||
#vars/default.yml
|
||||
---
|
||||
create_containers: 4
|
||||
default_container_name: docker
|
||||
default_container_image: ubuntu
|
||||
default_container_command: sleep 1d
|
||||
```
|
||||
|
||||
### 3. Run the Playbook
|
||||
|
||||
```command
|
||||
ansible-playbook -l [target] -i [inventory file] -u [remote user] playbook.yml
|
||||
```
|
||||
|
||||
For more information on how to run this Ansible setup, please check this guide: [How to Use Ansible to Install and Set Up Docker on Ubuntu 18.04](https://www.digitalocean.com/community/tutorials/how-to-use-ansible-to-install-and-set-up-docker-on-ubuntu-18-04).
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
caddy_name: caddy
|
||||
caddy_image: caddy:alpine
|
||||
|
||||
host_directory: caddy
|
||||
Reference in new issue
Block a user