--- - name: Deploy and Reload Airflow Task Hook hosts: all gather_facts: no vars_files: - "{{ inventory_dir }}/group_vars/all/generated_vars.yml" - "{{ inventory_dir }}/group_vars/all/vault.yml" tasks: - name: Ensure config directory exists on MASTER server when: inventory_hostname in groups['airflow_master'] ansible.builtin.file: path: "{{ airflow_master_dir }}/config" state: directory owner: "{{ ansible_user }}" group: "{{ ansible_user }}" mode: '0755' become: yes - name: Ensure config directory exists on WORKER server when: inventory_hostname in groups['airflow_workers'] ansible.builtin.file: path: "{{ airflow_worker_dir }}/config" state: directory owner: "{{ ansible_user }}" group: "{{ ansible_user }}" mode: '0755' become: yes - name: Sync custom_task_hooks.py to MASTER server when: inventory_hostname in groups['airflow_master'] synchronize: src: "../airflow/config/custom_task_hooks.py" dest: "{{ airflow_master_dir }}/config/" archive: yes rsync_path: "sudo rsync" - name: Sync airflow_local_settings.py to MASTER server when: inventory_hostname in groups['airflow_master'] synchronize: src: "../airflow/config/airflow_local_settings.py" dest: "{{ airflow_master_dir }}/config/" archive: yes rsync_path: "sudo rsync" - name: Sync custom_task_hooks.py to WORKER server when: inventory_hostname in groups['airflow_workers'] synchronize: src: "../airflow/config/custom_task_hooks.py" dest: "{{ airflow_worker_dir }}/config/" archive: yes rsync_path: "sudo rsync" - name: Sync airflow_local_settings.py to WORKER server when: inventory_hostname in groups['airflow_workers'] synchronize: src: "../airflow/config/airflow_local_settings.py" dest: "{{ airflow_worker_dir }}/config/" archive: yes rsync_path: "sudo rsync" - name: Restart Airflow services on MASTER when: inventory_hostname in groups['airflow_master'] ansible.builtin.command: cmd: "docker compose restart airflow-scheduler airflow-webserver airflow-master-worker airflow-triggerer" chdir: "{{ airflow_master_dir }}" become: yes - name: Restart Airflow worker on WORKER when: inventory_hostname in groups['airflow_workers'] ansible.builtin.command: cmd: "docker compose restart airflow-worker-dl airflow-worker-auth" chdir: "{{ airflow_worker_dir }}" become: yes