From f46e45b2b3f336b5254ef3810d6bd1b9b4ce013a Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 25 Aug 2025 06:09:49 -0700 Subject: [PATCH] add apache index to sd handler --- tasks/sd_handler.yaml | 68 ++++++++++++++++++-- templates/docker-compose-local-index.yaml.j2 | 12 ++++ 2 files changed, 76 insertions(+), 4 deletions(-) create mode 100755 templates/docker-compose-local-index.yaml.j2 diff --git a/tasks/sd_handler.yaml b/tasks/sd_handler.yaml index 98b8e01..ac9b03f 100644 --- a/tasks/sd_handler.yaml +++ b/tasks/sd_handler.yaml @@ -119,6 +119,9 @@ - debug: msg: "{{ sd_test_output.stdout_lines }}" +- name: SD Handler - samba and index + block: + - name: SD Handler - Share with samba block: @@ -140,10 +143,10 @@ - name: SD Handler - Include in smb.conf lineinfile: - path: "/etc/smb.conf" - search_string: "/etc/smb/smb.conf.d/vcr_rip.conf" - line: "/etc/smb/smb.conf.d/vcr_rip.conf" - insertafter: 'map to guest' + path: "/etc/samba/smb.conf" + search_string: "/etc/samba/smb.conf.d/vcr_rip.conf" + line: "include /etc/samba/smb.conf.d/vcr_rip.conf" + insertafter: '[global]' - name: SD Handler - restart smbd service: @@ -151,5 +154,62 @@ state: restarted enabled: yes + - name: SD Handler - Apache Index + block: + ############################################### + # Clone and build apache-index + ############################################### + + - name: SD Handler - - apache-index - Ensure the destination directory exists + file: + path: /opt/cosmos/apache-index # Replace with your desired directory on the target machine + state: directory + mode: '0755' + + - name: SD Handler - - apache-index - Clone the Git repository + git: + repo: 'https://gitea.matt-cloud.com/matt/apache-index.git' # Replace with your repository URL + dest: '/opt/cosmos/apache-index' # Replace with your desired directory on the target machine + version: 'main' # Replace with the branch, tag, or commit you want to clone + force: yes + + - name: SD Handler - - apache-index - Build image + docker_image: + name: apache-index # Name of the SD Handler - image + source: build + build: + path: /opt/cosmos/apache-index # Path to the directory containing your Dockerfile + state: present + tag: latest + register: build_index_output + - name: SD Handler - - apache-index - Image changed + debug: msg="{{ build_index_output.changed }}" + - name: SD Handler - - apache-index - Image failed + debug: msg="{{ build_index_output.failed }}" + - name: SD Handler - - apache-index - Image layers + debug: msg="{{ build_index_output.image.RootFS.Layers }}" + + ############################################### + # Install local-index 00 + ############################################### + + - name: SD Handler - - local-index - create folder + file: + path: "{{ streaming_working_folder }}/local-index" + state: directory + mode: '0755' + + - name: SD Handler - - local-index - Copy config + template: + src: docker-compose-local-index.yaml.j2 + dest: "{{ streaming_working_folder }}/local-index/docker-compose.yaml" + mode: 0644 + + - name: SD Handler - - local-index - Start container at 172.17.0.1:8080 + shell: "docker-compose -f {{ streaming_working_folder }}/local-index/docker-compose.yaml up -d" + register: local_index_output + - debug: | + msg="{{ local_index_output.stdout_lines }}" + msg="{{ local_index_output.stderr_lines }}" ... \ No newline at end of file diff --git a/templates/docker-compose-local-index.yaml.j2 b/templates/docker-compose-local-index.yaml.j2 new file mode 100755 index 0000000..a748692 --- /dev/null +++ b/templates/docker-compose-local-index.yaml.j2 @@ -0,0 +1,12 @@ +# docker-compose.yaml +version: '3' +services: + local-index: + image: apache-index + container_name: local-index + ports: + - 8080:80 + volumes: + - {{ working_storage }}:/mnt/smb + network_mode: bridge + restart: always