blob: 1c639d6c251a8221256b43e85217ccd7d459df7e [file] [log] [blame]
James E. Blaireff5a9d2017-06-20 00:00:37 -07001:title: Components
2
3.. _components:
4
5Components
6==========
7
8Zuul is a distributed system consisting of several components, each of
9which is described below. All Zuul processes read the
10**/etc/zuul/zuul.conf** file (an alternate location may be supplied on
11the command line) which uses an INI file syntax. Each component may
12have its own configuration file, though you may find it simpler to use
13the same file for all components.
14
15A minimal Zuul system may consist of a *scheduler* and *executor* both
16running on the same host. Larger installations should consider
17running multiple executors, each on a dedicated host, and running
18mergers on dedicated hosts as well.
19
20Common
21------
22
23The following applies to all Zuul components.
24
25Configuration
26~~~~~~~~~~~~~
27
28The following sections of **zuul.conf** are used by all Zuul components:
29
30gearman
31"""""""
32
33Client connection information for gearman.
34
35**server**
36 Hostname or IP address of the Gearman server.
37 ``server=gearman.example.com`` (required)
38
39**port**
40 Port on which the Gearman server is listening.
41 ``port=4730`` (optional)
42
43**ssl_ca**
44 Optional: An openssl file containing a set of concatenated
45 “certification authority” certificates in PEM formet.
46
47**ssl_cert**
48 Optional: An openssl file containing the client public certificate in
49 PEM format.
50
51**ssl_key**
52 Optional: An openssl file containing the client private key in PEM format.
53
54
55Scheduler
56---------
57
58The scheduler is the primary component of Zuul. The scheduler is not
59a scalable component; one, and only one, scheduler must be running at
60all times for Zuul to be operational. It receives events from any
61connections to remote systems which have been configured, enqueues
62items into pipelines, distributes jobs to executors, and reports
63results.
64
65Configuration
66~~~~~~~~~~~~~
67
68The following sections of **zuul.conf** are used by the scheduler:
69
70gearman_server
71""""""""""""""
72
73The builtin gearman server. Zuul can fork a gearman process from itself rather
74than connecting to an external one.
75
76**start**
77 Whether to start the internal Gearman server (default: False).
78 ``start=true``
79
80**listen_address**
81 IP address or domain name on which to listen (default: all addresses).
82 ``listen_address=127.0.0.1``
83
84**log_config**
85 Path to log config file for internal Gearman server.
86 ``log_config=/etc/zuul/gearman-logging.yaml``
87
88**ssl_ca**
89 Optional: An openssl file containing a set of concatenated “certification authority” certificates
90 in PEM formet.
91
92**ssl_cert**
93 Optional: An openssl file containing the server public certificate in PEM format.
94
95**ssl_key**
96 Optional: An openssl file containing the server private key in PEM format.
97
98webapp
99""""""
100
101**listen_address**
102 IP address or domain name on which to listen (default: 0.0.0.0).
103 ``listen_address=127.0.0.1``
104
105**port**
106 Port on which the webapp is listening (default: 8001).
107 ``port=8008``
108
109.. TODO: move this to webapp (currently in 'zuul')
110
111**status_expiry**
112 Zuul will cache the status.json file for this many seconds. This is an
113 optional value and ``1`` is used by default.
114 ``status_expiry=1``
115
116scheduler
117"""""""""
118.. TODO: rename this to 'scheduler' (currently 'zuul') and update to match these docs
119
120**tenant_config**
121 Path to tenant config file.
122 ``layout_config=/etc/zuul/tenant.yaml``
123
124**log_config**
125 Path to log config file.
126 ``log_config=/etc/zuul/scheduler-logging.yaml``
127
128**pidfile**
129 Path to PID lock file.
130 ``pidfile=/var/run/zuul/scheduler.pid``
131
132**state_dir**
133 Path to directory that Zuul should save state to.
134 ``state_dir=/var/lib/zuul``
135
136Operation
137~~~~~~~~~
138
139To start the scheduler, run ``zuul-scheduler``. To stop it, kill the
140PID which was saved in the pidfile specified in the configuration.
141
142Most of Zuul's configuration is automatically updated as changes to
143the repositories which contain it are merged. However, Zuul must be
144explicitly notified of changes to the tenant config file, since it is
145not read from a git repository. To do so, send the scheduler PID
146(saved in the pidfile specified in the configuration) a SIGHUP signal.
147
148Merger
149------
150
151Mergers are an optional Zuul service; they are not required for Zuul
152to operate, but some high volume sites may benefit from running them.
153Zuul performs quite a lot of git operations in the course of its work.
154Each change that is to be tested must be speculatively merged with the
155current state of its target branch to ensure that it can merge, and to
156ensure that the tests that Zuul perform accurately represent the
157outcome of merging the change. Because Zuul's configuration is stored
158in the git repos it interacts with, and is dynamically evaluated, Zuul
159often needs to perform a speculative merge in order to determine
160whether it needs to perform any further actions.
161
162All of these git operations add up, and while Zuul executors can also
163perform them, large numbers may impact their ability to run jobs.
164Therefore, administrators may wish to run standalone mergers in order
165to reduce the load on executors.
166
167Configuration
168~~~~~~~~~~~~~
169
170The following section of **zuul.conf** is used by the merger:
171
172merger
173""""""
174
175**git_dir**
176 Directory that Zuul should clone local git repositories to.
177 ``git_dir=/var/lib/zuul/git``
178
179**git_user_email**
180 Optional: Value to pass to `git config user.email`.
181 ``git_user_email=zuul@example.com``
182
183**git_user_name**
184 Optional: Value to pass to `git config user.name`.
185 ``git_user_name=zuul``
186
187**log_config**
188 Path to log config file for the merger process.
189 ``log_config=/etc/zuul/logging.yaml``
190
191**pidfile**
192 Path to PID lock file for the merger process.
193 ``pidfile=/var/run/zuul-merger/merger.pid``
194
195Operation
196~~~~~~~~~
197
198To start the merger, run ``zuul-merger``. To stop it, kill the
199PID which was saved in the pidfile specified in the configuration.
200
201Executor
202--------
203
204Executors are responsible for running jobs. At the start of each job,
205an executor prepares an environment in which to run Ansible which
206contains all of the git repositories specified by the job with all
207dependent changes merged into their appropriate branches. The branch
208corresponding to the proposed change will be checked out (in all
209projects, if it exists). Any roles specified by the job will also be
210present (also with dependent changes merged, if appropriate) and added
211to the Ansible role path. The executor also prepares an Ansible
212inventory file with all of the nodes requested by the job.
213
214The executor also contains a merger. This is used by the executor to
215prepare the git repositories used by jobs, but is also available to
216perform any tasks normally performed by standalone mergers. Because
217the executor performs both roles, small Zuul installations may not
218need to run standalone mergers.
219
220Trusted and Untrusted Playbooks
221~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
222
223The executor runs playbooks in one of two execution contexts depending
224on whether the project containing the playbook is a *config project*
225or an *untrusted project*. If the playbook is in a *config project*,
226the executor runs the playbook in the *trusted* execution context,
227otherwise, it is run in the *untrusted* execution context.
228
229Both execution contexts use `bubblewrap`_ to create a namespace to
230ensure that playbook executions are isolated and are unable to access
231files outside of a restricted environment. The administrator may
232configure additional local directories on the executor to be made
233available to the restricted environment.
234
235The *trusted* execution context has access to all Ansible features,
236including the ability to load custom Ansible modules. Needless to
237say, extra scrutiny should be given to code that runs in a trusted
238context as it could be used to compromise other jobs running on the
239executor, or the executor itself, especially if the administrator has
240granted additional access through bubblewrap, or a method of escaping
241the restricted environment created by bubblewrap is found.
242
243Playbooks run in the *untrusted* execution context are not permitted
244to load additional Ansible modules or access files outside of the
245restricted environment prepared for them by the executor. In addition
246to the bubblewrap environment applied to both execution contexts, in
247the *untrusted* context some standard Ansible modules are replaced
248with versions which prohibit some actions, including attempts to
249access files outside of the restricted execution context. These
250redundant protections are made as part of a defense-in-depth strategy.
251
252.. _bubblewrap: https://github.com/projectatomic/bubblewrap
253
254Configuration
255~~~~~~~~~~~~~
256
257The following sections of **zuul.conf** are used by the executor:
258
259executor
260""""""""
261
262**finger_port**
263 Port to use for finger log streamer.
264 ``finger_port=79``
265
266**git_dir**
267 Directory that Zuul should clone local git repositories to.
268 ``git_dir=/var/lib/zuul/git``
269
270**log_config**
271 Path to log config file for the executor process.
272 ``log_config=/etc/zuul/logging.yaml``
273
274**private_key_file**
275 SSH private key file to be used when logging into worker nodes.
276 ``private_key_file=~/.ssh/id_rsa``
277
278**user**
279 User ID for the zuul-executor process. In normal operation as a daemon,
280 the executor should be started as the ``root`` user, but it will drop
281 privileges to this user during startup.
282 ``user=zuul``
283
284merger
285""""""
286
287**git_user_email**
288 Optional: Value to pass to `git config user.email`.
289 ``git_user_email=zuul@example.com``
290
291**git_user_name**
292 Optional: Value to pass to `git config user.name`.
293 ``git_user_name=zuul``
294
295Operation
296~~~~~~~~~
297
298To start the executor, run ``zuul-executor``.
299
300There are several commands which can be run to control the executor's
301behavior once it is running.
302
303To stop the executor immediately, aborting all jobs (they may be
304relaunched according to their retry policy), run ``zuul-executor
305stop``.
306
307To request that the executor stop executing new jobs and exit when all
308currently running jobs have completed, run ``zuul-executor graceful``.
309
310To enable or disable running Ansible in verbose mode (with the '-vvv'
311argument to ansible-playbook) run ``zuul-executor verbose`` and
312``zuul-executor unverbose``.