From a0c3f8cf1812e738a69bf550f4e65c587b9f7480 Mon Sep 17 00:00:00 2001 From: Alexander Gabriel Date: Sun, 25 Jun 2023 00:25:51 +0200 Subject: [PATCH] updated airflow playbook --- tasks/main.yml | 32 ++++++++++++++++++++++++++------ templates/airflow.service.j2 | 2 +- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index e9a9d8f..7d2e8f0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -4,16 +4,28 @@ name: - python3-pip - python-is-python3 + - python3-full + - python3-virtualenv + - python3-psycopg2 + - libpq-dev update_cache: yes -- name: Install pip package apache-airflow - ansible.builtin.pip: - name: apache-airflow - - name: Add the user 'airflow' ansible.builtin.user: name: airflow - system: true + +- name: Install pip package apache-airflow + ansible.builtin.pip: + name: apache-airflow[celery]==2.6.2 + virtualenv: /home/airflow/airflow + virtualenv_python: python3 + extra_args: --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.6.2/constraints-3.7.txt" + +- name: Install pip package psycopg2 + ansible.builtin.pip: + name: psycopg2 + virtualenv: /home/airflow/airflow + virtualenv_python: python3 - name: generate /etc/systemd/system/airflow.service template: @@ -42,7 +54,15 @@ dest: /home/airflow/airflow/airflow.cfg owner: airflow group: airflow - mode: "0644" + notify: + - restart airflow + +- name: set permissions correct + file: + dest: /home/airflow/airflow + owner: airflow + group: airflow + recurse: yes notify: - restart airflow diff --git a/templates/airflow.service.j2 b/templates/airflow.service.j2 index 86db620..34399c9 100644 --- a/templates/airflow.service.j2 +++ b/templates/airflow.service.j2 @@ -5,7 +5,7 @@ Description=Apache Airflow User=airflow Group=airflow Type=simple -ExecStart=/usr/local/bin/airflow standalone +ExecStart=/home/airflow/airflow/bin/airflow standalone Restart=on-failure RestartSec=10s