aboutsummaryrefslogtreecommitdiff
path: root/roles/services/containers/text_generation/tasks
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/text_generation/tasks
Initial CommitHEADmaster
Diffstat (limited to 'roles/services/containers/text_generation/tasks')
-rw-r--r--roles/services/containers/text_generation/tasks/main.yml89
1 files changed, 89 insertions, 0 deletions
diff --git a/roles/services/containers/text_generation/tasks/main.yml b/roles/services/containers/text_generation/tasks/main.yml
new file mode 100644
index 0000000..80988a6
--- /dev/null
+++ b/roles/services/containers/text_generation/tasks/main.yml
@@ -0,0 +1,89 @@
1- name: set image fact
2 set_fact:
3 image: gitea.chudnick.com/sam/text-generation: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 text-generation directory
13 file:
14 path: "{{ docker_home }}/text-generation"
15 state: directory
16 owner: "{{ docker_username }}"
17 group: "{{ docker_username }}"
18 mode: '0755'
19
20- name: create models directory
21 file:
22 path: "{{ docker_home }}/text-generation/models"
23 state: directory
24 owner: "{{ docker_username }}"
25 group: "{{ docker_username }}"
26 mode: '0755'
27
28- name: clone text-generation repository
29 notify:
30 - login to docker registry
31 - build text-generation image
32 git:
33 repo: https://gitea.chudnick.com/sam/text-generation-docker
34 dest: "{{ docker_home }}/text-generation/src"
35
36- meta: flush_handlers
37
38- name: create text-generation network
39 become: yes
40 become_user: "{{ docker_username }}"
41 docker_network:
42 name: "{{ text_generation_network_name }}"
43 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
44 driver: bridge
45 ipam_config:
46 - subnet: "{{ text_generation_subnet }}"
47 gateway: "{{ text_generation_gateway }}"
48
49- name: create and deploy text-generation container
50 become: yes
51 become_user: "{{ docker_username }}"
52 environment:
53 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
54 docker_container:
55 name: "text-generation"
56 hostname: "text-generation"
57 image: "{{ image }}"
58 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
59 purge_networks: yes
60 networks:
61 - name: "{{ text_generation_network_name }}"
62 ipv4_address: "{{ text_generation_ipv4 }}"
63 volumes:
64 - "{{ docker_home }}/text-generation/models:/models"
65 ports:
66 - "127.0.0.1:{{ text_generation_external_port }}:7860"
67 - "127.0.0.1:{{ text_generation_api_port }}:5005"
68 - "127.0.0.1:{{ text_generation_api_stream_port }}:5000"
69 command: "--cpu --listen --listen-port 7860 --chat --auto-devices --mlock"
70 state: 'started'
71 recreate: yes
72 restart_policy: unless-stopped
73
74- name: deploy nginx configuration
75 notify: restart nginx
76 template:
77 src: "{{ text_generation_nginx_config }}"
78 dest: /etc/nginx/sites-available/text-generation.conf
79 owner: root
80 group: root
81 mode: '0644'
82
83- name: symlink site
84 file:
85 src: /etc/nginx/sites-available/text-generation.conf
86 dest: /etc/nginx/sites-enabled/text-generation.conf
87 owner: root
88 group: root
89 state: link