From 95b73daa36b23565a8566f71f9b202d3459b685f Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 25 Jun 2023 09:52:36 -0400 Subject: Initial Commit --- .../containers/pywttr_docker/tasks/main.yml | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 roles/services/containers/pywttr_docker/tasks/main.yml (limited to 'roles/services/containers/pywttr_docker/tasks') 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 @@ +- name: set image fact + set_fact: + image: gitea.chudnick.com/sam/pywttr-docker:latest + +- 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 pywttr-docker directory + file: + path: "{{ docker_home }}/pywttr-docker" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: clone pywttr-docker repository + notify: build pywttr-docker image + git: + repo: https://gitea.chudnick.com/sam/pywttr-docker + dest: "{{ docker_home }}/pywttr-docker/src" + +- meta: flush_handlers + +- name: create pywttr-docker network + become: yes + become_user: "{{ docker_username }}" + docker_network: + name: "{{ pywttr_docker_network_name }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + driver: bridge + ipam_config: + - subnet: "{{ pywttr_docker_subnet }}" + gateway: "{{ pywttr_docker_gateway }}" + +- name: create and deploy pywttr-docker container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "pywttr-docker" + hostname: "pywttr-docker" + image: "{{ image }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + networks: + - name: "{{ pywttr_docker_network_name }}" + ipv4_address: "{{ pywttr_docker_ipv4 }}" + ports: + - "127.0.0.1:{{ pywttr_docker_external_port }}:8000" + state: 'started' + recreate: yes + restart_policy: unless-stopped + +- name: deploy nginx configuration + notify: restart nginx + template: + src: "{{ pywttr_docker_nginx_config }}" + dest: /etc/nginx/sites-available/pywttr-docker.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/pywttr-docker.conf + dest: /etc/nginx/sites-enabled/pywttr-docker.conf + owner: root + group: root + state: link -- cgit v1.2.3