aboutsummaryrefslogtreecommitdiff
path: root/roles/services/containers/pywttr_docker
diff options
context:
space:
mode:
authorSam Chudnick <sam@chudnick.com>2023-06-25 09:52:36 -0400
committerSam Chudnick <sam@chudnick.com>2023-06-25 09:52:36 -0400
commit95b73daa36b23565a8566f71f9b202d3459b685f (patch)
treecb17b021be70e7868d0ec235a761f0ecdc80f3f2 /roles/services/containers/pywttr_docker
Initial CommitHEADmaster
Diffstat (limited to 'roles/services/containers/pywttr_docker')
-rw-r--r--roles/services/containers/pywttr_docker/handlers/main.yml18
-rw-r--r--roles/services/containers/pywttr_docker/tasks/main.yml74
2 files changed, 92 insertions, 0 deletions
diff --git a/roles/services/containers/pywttr_docker/handlers/main.yml b/roles/services/containers/pywttr_docker/handlers/main.yml
new file mode 100644
index 0000000..de5dcb6
--- /dev/null
+++ b/roles/services/containers/pywttr_docker/handlers/main.yml
@@ -0,0 +1,18 @@
1- name: build pywttr-docker image
2 become: yes
3 become_user: "{{ docker_username }}"
4 environment:
5 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
6 docker_image:
7 name: "{{ docker_registry_url }}/{{ docker_registry_username }}/pywttr-docker:latest"
8 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
9 build:
10 path: /srv/docker/pywttr-docker/src
11 source: build
12 push: yes
13 force_source: yes
14
15- name: restart nginx
16 service:
17 name: nginx
18 state: restarted
diff --git a/roles/services/containers/pywttr_docker/tasks/main.yml b/roles/services/containers/pywttr_docker/tasks/main.yml
new file mode 100644
index 0000000..45f7b2f
--- /dev/null
+++ b/roles/services/containers/pywttr_docker/tasks/main.yml
@@ -0,0 +1,74 @@
1- name: set image fact
2 set_fact:
3 image: gitea.chudnick.com/sam/pywttr-docker:latest
4
5- name: set other facts
6 vars:
7 array: "{{ image.split('/', 1) }}"
8 set_fact:
9 repo_tag: "{{ array.1 }}"
10 custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}"
11
12- name: create pywttr-docker directory
13 file:
14 path: "{{ docker_home }}/pywttr-docker"
15 state: directory
16 owner: "{{ docker_username }}"
17 group: "{{ docker_username }}"
18 mode: '0755'
19
20- name: clone pywttr-docker repository
21 notify: build pywttr-docker image
22 git:
23 repo: https://gitea.chudnick.com/sam/pywttr-docker
24 dest: "{{ docker_home }}/pywttr-docker/src"
25
26- meta: flush_handlers
27
28- name: create pywttr-docker network
29 become: yes
30 become_user: "{{ docker_username }}"
31 docker_network:
32 name: "{{ pywttr_docker_network_name }}"
33 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
34 driver: bridge
35 ipam_config:
36 - subnet: "{{ pywttr_docker_subnet }}"
37 gateway: "{{ pywttr_docker_gateway }}"
38
39- name: create and deploy pywttr-docker container
40 become: yes
41 become_user: "{{ docker_username }}"
42 environment:
43 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
44 docker_container:
45 name: "pywttr-docker"
46 hostname: "pywttr-docker"
47 image: "{{ image }}"
48 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
49 purge_networks: yes
50 networks:
51 - name: "{{ pywttr_docker_network_name }}"
52 ipv4_address: "{{ pywttr_docker_ipv4 }}"
53 ports:
54 - "127.0.0.1:{{ pywttr_docker_external_port }}:8000"
55 state: 'started'
56 recreate: yes
57 restart_policy: unless-stopped
58
59- name: deploy nginx configuration
60 notify: restart nginx
61 template:
62 src: "{{ pywttr_docker_nginx_config }}"
63 dest: /etc/nginx/sites-available/pywttr-docker.conf
64 owner: root
65 group: root
66 mode: '0644'
67
68- name: symlink site
69 file:
70 src: /etc/nginx/sites-available/pywttr-docker.conf
71 dest: /etc/nginx/sites-enabled/pywttr-docker.conf
72 owner: root
73 group: root
74 state: link