---
- file:
    path: /srv/www/nginx-proxy
    group: users
    state: directory
    owner: camino
    mode: u=rwx,g=rwx,o=r
  become: True
- name: Met en place le docker-compose
  ansible.builtin.copy:
    src: docker-compose.yml
    dest: /srv/www/nginx-proxy/docker-compose.yml
    owner: camino
    group: users
    mode: u=rw,g=r,o=r
  become: True
- name: Ajoute le fichier de template nginx
  ansible.builtin.copy:
    src: proxy.conf
    dest: /srv/www/nginx-proxy/proxy.conf
    owner: camino
    group: users
    mode: u=rw,g=r,o=r
  become: True
- name: Ajoute la redirection cd pour gitlab
  ansible.builtin.template:
    src: cd.conf
    dest: /srv/www/nginx-proxy/cd.conf
    owner: camino
    group: users
    mode: u=rw,g=r,o=r
  become: True

- name: Install docker support for python
  ansible.builtin.apt:
    name: python3-docker
  become: True
- name: Create a network
  community.docker.docker_network:
    name: nginx-proxy
# TODO 2023-10-12 https://github.com/ansible-collections/community.docker/issues/672
- name: Create and start services
  shell:
    chdir: /srv/www/nginx-proxy
    cmd: "docker compose up -d"
