From 95b73daa36b23565a8566f71f9b202d3459b685f Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 25 Jun 2023 09:52:36 -0400 Subject: Initial Commit --- roles/services/containers/drawio/tasks/main.yml | 149 ++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 roles/services/containers/drawio/tasks/main.yml (limited to 'roles/services/containers/drawio/tasks') diff --git a/roles/services/containers/drawio/tasks/main.yml b/roles/services/containers/drawio/tasks/main.yml new file mode 100644 index 0000000..27bbefd --- /dev/null +++ b/roles/services/containers/drawio/tasks/main.yml @@ -0,0 +1,149 @@ +- name: set image fact + set_fact: + image: jgraph/drawio:21.5.0 + +- name: set other facts + vars: + array: "{{ image.split('/', 1) }}" + set_fact: + repo_tag: "{{ array.1 }}" + custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}" + +- name: create drawio directory + file: + path: "{{ docker_home }}/drawio" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create drawio fonts directory + file: + path: /usr/share/fonts/drawio + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: login to docker registry + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_login: + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + registry_url: "{{ docker_registry_url }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + +- name: get drawio image + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + push: yes + +- name: get export-server image + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ docker_registry_url }}/{{ docker_registry_username }}/image-export:latest" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + push: yes + +- name: create drawio docker network + become: yes + become_user: "{{ docker_username }}" + docker_network: + name: "{{ drawio_network_name }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + driver: bridge + ipam_config: + - subnet: "{{ drawio_subnet }}" + gateway: "{{ drawio_gateway }}" + +- name: create and deploy drawio export-server + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "image-export" + image: "{{ docker_registry_url }}/{{ docker_registry_username }}/image-export:latest" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + pull: yes + exposed_ports: + - '8000' + purge_networks: yes + networks: + - name: "{{ drawio_network_name }}" + ipv4_address: "{{ drawio_export_ipv4 }}" + volumes: + - fonts_volume:/usr/share/fonts/drawio + env: + DRAWIO_BASE_URL: "{{ drawio_base_url }}" + cap_drop: + - all + hostname: "image-export" + restart_policy: unless-stopped + state: 'started' + recreate: yes + +- name: create and deploy drawio + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "drawio" + image: "{{ custom_registry }}/{{ repo_tag }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + pull: yes + purge_networks: yes + networks: + - name: "{{ drawio_network_name }}" + ipv4_address: "{{ drawio_ipv4 }}" + ports: + - "127.0.0.1:8443:8443" + - "127.0.0.1:8400:8080" + links: + - image-export:image-export + env: + DRAWIO_SELF_CONTAINED: "1" + PLANTUML_URL: "http://plantuml-server:8080/" + EXPORT_URL: "http://image-export:8000/" + DRAWIO_PUSHER_MODE: "2" + cap_drop: + - all + hostname: "drawio" + restart_policy: unless-stopped + state: 'started' + recreate: yes + +- name: deploy nginx configuration + notify: restart nginx + register: nginx_config + copy: + src: "{{ drawio_nginx_config }}" + dest: /etc/nginx/sites-available/drawio.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/drawio.conf + dest: /etc/nginx/sites-enabled/drawio.conf + owner: root + group: root + state: link -- cgit v1.2.3