---
- name: Deploy Airflow DAGs to Master
  hosts: airflow_master
  gather_facts: no
  vars_files:
    - group_vars/all.yml
  remote_user: "{{ ansible_user }}"
  tasks:
    - name: Sync DAGs to MASTER server
      ansible.posix.synchronize:
        src: "../airflow/dags/"
        dest: /srv/airflow_master/dags/
        archive: yes
        delete: yes
        rsync_path: "sudo rsync"
        rsync_opts:
          - "--exclude=__pycache__/"
          - "--exclude=*.pyc"

    - name: Sync Config to MASTER server
      ansible.posix.synchronize:
        src: "../airflow/config/"
        dest: /srv/airflow_master/config/
        archive: yes
        delete: yes
        rsync_path: "sudo rsync"
        rsync_opts:
          - "--exclude=__pycache__/"
          - "--exclude=*.pyc"

- name: Deploy Airflow DAGs to DL Workers
  hosts: airflow_workers
  gather_facts: no
  vars_files:
    - group_vars/all.yml
  remote_user: "{{ ansible_user }}"
  tasks:
    - name: Sync DAGs to WORKER server
      ansible.posix.synchronize:
        src: "../airflow/dags/"
        dest: /srv/airflow_dl_worker/dags/
        archive: yes
        delete: yes
        rsync_path: "sudo rsync"
        rsync_opts:
          - "--exclude=__pycache__/"
          - "--exclude=*.pyc"
