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