Configuring a Git Repo¶
Since version 3, Scap is now able to deploy any git-based repository from our
deployment server to any number of hosts. This deployment can happen in serial
or in parallel. All that is necessary, aside from the configuration outlined
here, is that the target hosts are accessible via SSH by the deploy_user
from the deploy_host
(the machine from which you run Scap).
Scap configuration is loaded from several files via scap.config.load()
function in the scap.config
module.
- scap.config.load(cfg_file=None, environment=None, overrides=None, use_global_config=True, use_local_config=True)[source]¶
Load configuration.
A configuration file consists of sections, led by a
[section]
header and followed byname: value
entries. Lines beginning with'#'
are ignored and may be used to provide comments.A configuration file can contain multiple sections. The configuration object is populated with values from the
global
section and additional sections based on the fully qualified domain name of the local host. For example, on the hostdeployXXXX.eqiad.wmnet
the final value for a given setting would be the first value found in sections:deployXXXX.eqiad.wmnet
,eqiad.wmnet
,wmnet
orglobal
. Sections not present in the configuration file will be ignored.Configuration values are loaded from a file specified by the
-c
or--conf
command-line options or from the default locations with the following hierarchy, sorted by override priority:$(pwd)/scap/environments/<environment>/scap.cfg
or$(pwd)/scap/scap.cfg
(if no environment was specified)/etc/scap.cfg
(if use_global_config is true)
For example, if a configuration parameter is set in
$(pwd)/scap/scap.cfg
and that same parameter is set in/etc/scap.cfg
the value for that parameter set in$(pwd)/scap/scap.cfg
will be used during execution.- Parameters:
cfg_file – Alternate configuration file
environment – the string path under which scap.cfg is found
overrides – Dict of configuration values
use_global_config – A boolean indicating if /etc/scap.cfg should be read
- Returns:
dict of configuration values
Simple initial setup¶
For a new repo setup, the main file that needs to be created is in the root of
the repository at scap/scap.cfg
. This new file should be made in
ConfigParser
format.
Warning
- These values must be set in
scap/scap.cfg
: git_repo
dsh_targets
.
Available configuration variables¶
Value |
Default |
Explanation |
---|---|---|
|
NONE |
(String) Server from which code is fetched. Use is not recommended! The deployment-host will have a good value set for this already. |
|
your username |
(String) User as whom to ssh to target hosts and execute remote commands |
|
NONE |
(String) Repo on
|
|
|
(String) Directory on targets in which your repo is placed |
|
HEAD |
(String) Specific git rev to deploy. |
|
False |
(Boolean) (Optional) Whether submodules need to be fetched and checked-out as part of the deploy on targets. |
|
False |
(Boolean) If |
|
False |
(Boolean) (Optional) Whether binary files are managed via git-fat and should be synced as part of the deploy on targets. |
|
None* |
(String) (Optional)
Binary files should be managed
by an external program.
Allowed values are |
|
|
(String) Path to list
of deploy targets. If
the path is not absolute,
Scap looks for a file in
|
|
|
(String) (Optional)
If this option is defined,
Scap will deploy to
these groups of servers
in order. If this is not
specified scap will deploy to
a single group of servers -
those listed in For example:
|
|
NONE |
(Int) (Optional) If defined, Scap will split each server group into smaller subgroups containing no more than the given number of hosts. A global and/or group specific configuration may be provided. This configuration can be used to achieve a more serial deployment within each server group. |
|
1 |
(Int or String) (Optional) Number or percentage of group targets that are allowed to fail without triggering a rollback. Percentages should be suffixed with ‘%’ (e.g. 10%). A global and/or group specific configuration may be provided. |
|
NONE |
(String) (Optional)
If a service name is
defined, the service
will be restarted on
each target as part
of the May also be a comma-separated
list of services to restart
(e.g. Each service may be reloaded
instead of restarted by
appending |
|
NONE |
(Int) (Optional)
If a port is defined,
Scap will verify that
the port is accepting TCP
connections after the
|
|
120 |
(Int) (Optional) The
amount of time to wait
when checking a
|
|
80 |
(Int) (Optional)
Parallelism of a stage of
deployment Number of hosts to
execute a particular
deployment stage on
simultaniously. This
is configurable by
stage by creating
a config variable:
|
|
False |
(Boolean) (Optional)
if |
|
|
(String) Directory in which nrpe checks are stored |
|
True |
(Boolean) If |
|
20 |
(Int) (Optional) Number of tags to keep in the deployment server repo. Git appears to max-out at 999. Scap thinks 20 tags on the deployment server is quite enough. |