Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config to have customizable pip and airflow executables #34

Merged
merged 3 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
airflow_version: 1.8.1
airflow_extra_packages:

airflow_pip_executable: "pip"
airflow_executable: "/usr/local/bin/airflow"

airflow_required_libs:
- python-pip
- acl
Expand Down Expand Up @@ -36,6 +39,7 @@ airflow_dags_folder: "{{ airflow_home }}/dags"
airflow_logs_folder: /var/log/airflow
airflow_child_process_log_folder: "{{ airflow_logs_folder }}/scheduler"
airflow_environment_file_folder: /etc/sysconfig
airflow_environment_extra_vars: []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a sample value like in L208?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.


# Allowing playbooks to provide external config files&templates
airflow_extra_conf_path: "{{ playbook_dir }}/files/airflow"
Expand Down
2 changes: 1 addition & 1 deletion tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
- restart airflow-flower

- name: Airflow | Initializing DB
command: /usr/local/bin/airflow initdb
command: "{{ airflow_executable }} initdb"
environment:
AIRFLOW_HOME: "{{ airflow_home }}"
become: true
Expand Down
5 changes: 5 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@

- name: Airflow | Installing proper Celery version
pip:
executable: "{{ airflow_pip_executable }}"
name: celery
version: "{{ celery_version }}"
when: airflow_executor == "CeleryExecutor"

- name: Airflow | Installing extra Celery packages
pip:
executable: "{{ airflow_pip_executable }}"
name: celery[{{ item }}]
version: "{{ celery_version }}"
with_items: "{{ celery_extra_packages }}"
Expand All @@ -51,20 +53,23 @@

- name: Airflow | Installing Airflow
pip:
executable: "{{ airflow_pip_executable }}"
name: apache-airflow
version: "{{ airflow_version }}"
extra_args: --no-cache-dir
register: airflow_install

- name: Airflow | Installing Airflow Extra Packages
pip:
executable: "{{ airflow_pip_executable }}"
name: apache-airflow[{{ item }}]
version: "{{ airflow_version }}"
with_items: "{{ airflow_extra_packages }}"
when: airflow_extra_packages

- name: Airflow | Installing DAGs dependencies
pip:
executable: "{{ airflow_pip_executable }}"
name: "{{ item.name }}"
version: "{{ item.version }}"
with_items: "{{ dags_dependencies }}"
Expand Down
6 changes: 5 additions & 1 deletion templates/airflow-environment-file.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
# required setting, 0 sets it to unlimited. Scheduler will get restart after every X runs
SCHEDULER_RUNS={{ airflow_scheduler_runs }}

AIRFLOW_HOME={{ airflow_home }}
AIRFLOW_HOME={{ airflow_home }}

{% for extra_var in airflow_environment_extra_vars %}
{{ extra_var.name }}={{ extra_var.value }}
{% endfor %}
2 changes: 1 addition & 1 deletion templates/airflow-flower.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ EnvironmentFile={{ airflow_environment_file_folder }}/airflow
User={{ airflow_user }}
Group={{ airflow_group }}
Type=simple
ExecStart=/usr/local/bin/airflow flower --pid /run/airflow/flower.pid
ExecStart={{ airflow_executable }} flower --pid /run/airflow/flower.pid
Restart=on-failure
RestartSec=10s
RuntimeDirectory=airflow
Expand Down
2 changes: 1 addition & 1 deletion templates/airflow-scheduler.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ EnvironmentFile={{ airflow_environment_file_folder }}/airflow
User={{ airflow_user }}
Group={{ airflow_group }}
Type=simple
ExecStart=/usr/local/bin/airflow scheduler -n ${SCHEDULER_RUNS} --pid /run/airflow/scheduler.pid
ExecStart={{ airflow_executable }} scheduler -n ${SCHEDULER_RUNS} --pid /run/airflow/scheduler.pid
Restart=always
RestartSec=5s
RuntimeDirectory=airflow
Expand Down
2 changes: 1 addition & 1 deletion templates/airflow-webserver.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ EnvironmentFile={{ airflow_environment_file_folder }}/airflow
User={{ airflow_user }}
Group={{ airflow_group }}
Type=simple
ExecStart=/usr/local/bin/airflow webserver --pid /run/airflow/webserver.pid
ExecStart={{ airflow_executable }} webserver --pid /run/airflow/webserver.pid
Restart=on-failure
RestartSec=5s
PrivateTmp=true
Expand Down
2 changes: 1 addition & 1 deletion templates/airflow-worker.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ EnvironmentFile={{ airflow_environment_file_folder }}/airflow
User={{ airflow_user }}
Group={{ airflow_group }}
Type=simple
ExecStart=/usr/local/bin/airflow worker --pid /run/airflow/worker.pid
ExecStart={{ airflow_executable }} worker --pid /run/airflow/worker.pid
Restart=on-failure
RestartSec=10s
RuntimeDirectory=airflow
Expand Down