/
main.yml
250 lines (222 loc) · 7.47 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
---
# Defaults vars file for airflow role
# Airflow installation tasks
airflow_system_dependencies: "{{ _airflow_system_dependencies }}"
# Set changed when due to idempotency problem with pip module
# Always changed with airflow and airflow[crypto]
airflow_pip_changed_when: False
# Ansible's pip module doesn't currently support complex version strings
# https://github.com/ansible/ansible/issues/19321
# And Airflow may currently require custom version strings
# https://stackoverflow.com/a/48075827
airflow_pip_custom_version_install: False
# Installation vars
airflow_user_name: 'airflow'
airflow_user_group: "{{ airflow_user_name }}"
airflow_user_shell: '/bin/false'
airflow_user_home_path: '/var/lib/airflow'
airflow_user_home_mode: '0700'
airflow_log_path: '/var/log/airflow'
airflow_log_owner: "{{ airflow_user_name }}"
airflow_log_group: "{{ airflow_user_group }}"
airflow_log_mode: '0700'
airflow_pid_path: '/var/run/airflow'
airflow_pid_owner: "{{ airflow_user_name }}"
airflow_pid_group: "{{ airflow_user_group }}"
airflow_pid_mode: '0700'
airflow_virtualenv: "{{ airflow_user_home_path }}/venv"
airflow_virtualenv_mode: "0755"
airflow_python_version: "{{ _airflow_python_version }}"
airflow_packages:
- name: 'pip'
version: '10.0.1'
- name: 'setuptools'
version: '39.1.0'
- name: 'GitPython'
version: '2.1.9'
- name: 'Cython'
version: '0.28.2'
- name: 'apache-airflow'
version: '1.9.0'
airflow_extra_packages:
- name: 'apache-airflow[crypto]'
# option to set environment for all users,
# by providing a file in /etc/profile.d/
airflow_provide_user_env: False
# SERVICES MANAGEMENT
# -----------------------------------------------------------------------------
# Airflow systemd services specific settings
is_systemd_managed_system: "{{ _is_systemd_managed_system | default(False) }}"
airflow_services_systemd:
- dest: '/etc/systemd/system/airflow-webserver.service'
handler: 'Restart airflow-webserver'
options:
Install:
WantedBy: 'multi-user.target'
Service:
Environment: "PATH={{ airflow_virtualenv ~ '/bin' }}"
EnvironmentFile: "{{ airflow_paths.files.environment.path }}"
ExecStart: "{{ airflow_virtualenv ~ '/bin' }}/airflow webserver"
Group: "{{ airflow_user_group }}"
PrivateTmp: 'true'
Restart: 'on-failure'
RestartSec: '5s'
Type: 'simple'
User: "{{ airflow_user_name }}"
Unit:
After: 'network.target postgresql.service mysql.service redis.service rabbitmq-server.service'
Description: 'Airflow webserver daemon'
Wants: 'postgresql.service mysql.service redis.service rabbitmq-server.service'
- dest: '/etc/systemd/system/airflow-scheduler.service'
handler: 'Restart airflow-scheduler'
options:
Install:
WantedBy: 'multi-user.target'
Service:
Environment: "PATH={{ airflow_virtualenv ~ '/bin' }}"
EnvironmentFile: "{{ airflow_paths.files.environment.path }}"
ExecStart: "{{ airflow_virtualenv ~ '/bin' }}/airflow scheduler"
Group: "{{ airflow_user_group }}"
PrivateTmp: 'true'
Restart: 'always'
RestartSec: '5s'
Type: 'simple'
User: "{{ airflow_user_name }}"
Unit:
After: 'network.target postgresql.service mysql.service redis.service rabbitmq-server.service'
Description: 'Airflow scheduler daemon'
Wants: 'postgresql.service mysql.service redis.service rabbitmq-server.service'
airflow_services_states:
- name: 'airflow-webserver'
enabled: True
state: 'started'
- name: 'airflow-scheduler'
enabled: True
state: 'started'
# Environment variables file
airflow_paths:
files:
environment:
path: '/etc/default/airflow'
# Databases variables
airflow_manage_database: True
airflow_database_engine: 'mysql'
airflow_database_sqlite_file_path: "{{ airflow_user_home_path ~ '/airflow/airflow.db' }}"
# Set do_init to false if database already initialized
airflow_do_init_db: True
airflow_do_upgrade_db: True
# Default configuration
airflow_defaults_config:
core:
airflow_home: "{{ airflow_user_home_path ~ '/airflow' }}"
airflow_home_mode: "0700"
dags_folder: "{{ airflow_user_home_path ~ '/airflow/dags' }}"
dags_folder_mode: "0755"
base_log_folder: "{{ airflow_log_path }}"
remote_base_log_folder: ''
remote_log_conn_id: ''
encrypt_s3_logs: False
executor: 'SequentialExecutor'
sql_alchemy_conn: "sqlite:///{{ airflow_database_sqlite_file_path }}"
sql_alchemy_pool_size: 5
sql_alchemy_pool_recycle: 3600
parallelism: 32
dag_concurrency: 16
dags_are_paused_at_creation: True
non_pooled_task_slot_count: 128
max_active_runs_per_dag: 16
load_examples: False
plugins_folder: "{{ airflow_user_home_path ~ '/airflow/plugins' }}"
fernet_key: 'cryptography_not_found_storing_passwords_in_plain_text'
donot_pickle: False
dagbag_import_timeout: 30
operators:
default_owner: 'Airflow'
webserver:
auth_backend: ''
authenticate: False
base_url: 'http://localhost:8080'
debug: False
expose_config: True
filter_by_owner: False
hostname: "{{ ansible_default_ipv4.address }}"
log_file: "{{ airflow_log_path }}/airflow-webserver.log"
pid: "{{ airflow_pid_path }}/airflow-webserver.pid"
secret_key: 'temporary_key'
web_server_host: '0.0.0.0'
web_server_port: '8080'
web_server_worker_timeout: 120
workers: 1
worker_class: 'sync'
worker_timeout: 30
email:
email_backend: 'airflow.utils.email.send_email_smtp'
smtp:
smtp_host: 'localhost'
smtp_starttls: True
smtp_ssl: False
smtp_user: 'airflow'
smtp_port: 25
smtp_password: 'airflow'
smtp_mail_from: 'airflow@airflow.com'
celery:
celery_app_name: 'airflow.executors.celery_executor'
celeryd_concurrency: 16
worker_log_server_port: 8793
broker_url: 'sqla+mysql://airflow:airflow@localhost:3306/airflow'
celery_result_backend: 'db+mysql://airflow:airflow@localhost:3306/airflow'
flower_port: 5555
default_queue: 'default'
scheduler:
job_heartbeat_sec: 5
log_file: "{{ airflow_log_path }}/airflow-scheduler.log"
num_runs: 0
pid: "{{ airflow_pid_path }}/airflow-scheduler.pid"
scheduler_heartbeat_sec: 5
statsd_on: False
statsd_host: 'localhost'
statsd_port: 8125
statsd_prefix: 'airflow'
max_threads: 2
mesos:
master: 'localhost:5050'
framework_name: 'Airflow'
task_cpu: 1
task_memory: 256
checkpoint: False
failover_timeout: 604800
authenticate: False
default_principal: 'admin'
default_secret: 'admin'
ldap:
uri: 'ldaps://<your.ldap.server>:<port>'
user_filter: 'objectClass=*'
user_name_attr: 'uid'
superuser_filter: ''
data_profiler_filter: ''
bind_user: ''
bind_password: ''
basedn: 'dc=example,dc=com'
cacert: ''
search_scope: 'LEVEL'
airflow_user_config: {}
airflow_config: "{{ airflow_defaults_config | combine(airflow_user_config, recursive=True) }}"
# Connections management
airflow_drop_existing_connections_before_add: True
airflow_connections: []
# Variables management
airflow_drop_existing_variables_before_add: True
airflow_variables: []
# Logrotate configuration
airflow_logrotate_config:
- filename: '/etc/logrotate.d/airflow'
log_pattern:
- "{{ airflow_log_path }}/*.log"
options:
- 'rotate 12'
- 'weekly'
- 'compress'
- 'delaycompress'
- "create 640 {{ airflow_log_owner }} {{ airflow_log_group }}"
- 'postrotate'
- 'endscript'