Skip to main content

No project description provided

Project description

Deployment Director

Plug this utility in your CI/CD pipeline and customise your deployment flow with advanced logic using simple yaml configuration.

Docker support required.

How to run

Usage: deployment-director [OPTIONS] RULES_FILE

Options:
  --ci-name TEXT      Name of the CI product deployment director is running
                      under
  -n, --dry-run TEXT  Do not actually execute any actions, just print them out
  -v, --verbose
  --help              Show this message and exit.

The rules file

Sample:

version: "1"
rules:
  - when:
    - branch: [ master, development ]
    then:
    - add_action:
        name: deploy
        action:
          class_name: CommandAction
          arguments:
            command: deploy.sh {server_ip}
        parameters:
          server_ip:
            key: branch
            map:
              master: 10.0.0.1
              development: 10.0.1.1

A decomposition follows:

Version

Version of the file, we just have version 1 (string) so far

version: "1"

Rules

The bulk of the file is a list of rules. Each rule has a when and a then clause:

rules:
  - when: ...
    then: ...
  - when: ...
    then: ...

Rules are evaluated sequentially.

Rule conditions

Conditions belong to the when clause of the rules. They indicate when the rule consequences (then) should trigger.

They are introduced as a list inside the when clause.

Conditions are evaluated sequentially. The list represents a logical OR. ANY single condition block evaluating to true will trigger the rule consequence

Each condition consists of a dictionary of clauses. The condition evaluates to true only if ALL its clauses are satisfied.

Each clause can specify a number of possible matches. The clause will be satisfied if ANY of the possibilities is an actual match

...
when:
  # condition 1 -- true for branch master of repo1 OR repo2
  - repo: [ repo1, repo2 ]
    branch: master

  # condition 2 -- true for branches master and develop of any repo
  - branch: [ master, develop ]

  # condition 3 -- true for branches master and develop of repo1
  - repo: repo1
    branch: [ master, develop ]
  ...

Regex match

Clauses can also match with regexes:

- branch: /release-.+/

Will match any branch or tag starting with the text "release-"

In the case of a regex match, it's possible to tag that match so that it can be used as a key in parameter maps (see example of usage below).

- branch:
    match: /release-.+/
    as: release_TAG

Rule consequences

Consequences of the rules belong inside the then section, that's a list inside the clause.

There are two possible classes of consequences: add_action and configure_action . The first one creates new actions, the second allows to modify previously added actions.

...
then:
  - add_action:
    ...
  - configure_action:
    ...
  - add_action:
    ...

Consequences are evaluated sequentially. Actions are executed after parsing and evaluating the complete rules file.

add_action rule class

When adding an action, you specify name, parameters, action and an enabled flag.

  • The name of the parameter should be unique across the rules file. Two actions with the same name cannot be added in the same run.

  • The enabled flag indicates whether the action will actually run, it is disabled by default

  • The action clause is the action definition. It consists of class_name and arguments. The contents of the arguments will vary depending on the action class.

  • The parameters clause is a dictionary of parameters that will be passed to the action. Parameters can be defined in several ways.

    The simplest is static value assignation.

    parameter: value
    

    Values can use variable substitution from the execution context, i.e:

    parameter: "${env[ENV_VAR]}"
    

    Another option is usage of maps, i.e:

    parameter:
      key: branch
      map:
        master: value1
        development: value2
        release_TAG: value3
    

    Supported keys can be any value present in the context.

    Note the usage of release_TAG, which was defined as a clause matching alias when we were covering regex matches in clauses.

Parameters can be referenced in the definition of the action by using the {parameter} syntax.

Available action classes

CommandAction

Takes the following arguments:

  • env: a dictionary with environment variables.
  • command: a string with the command to be executed, the command is parsed through the system shell.

The Context object

Throughout the evaluation of the rules file, references can be made to values in the context. The context contains information about the environment where the deployment director is running in.

This is approximately what the context object would look like if we exported it to YAML:

branch: ... # <the branch/tag provided by the CI>
repo: ... # <the name of the repository provided by the CI>
ci:
  # all the bits of information provided by the CI
  # i.e. Codeship provides
  branch: ...
  build_id: ...
  committer_email: ...
  committer_name: ...
  committer_username: ...
  commit_description: ...
  commit_id: ...
  commit_message: ...
  name: ...
  project_id: ...
  repo_name: ...
  string_time: ...
  timestamp: ...
env:
  # environment variables
  PATH: ...
  HOME: ...
  ...

Which CI/CD are supported

  • Codeship

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deployment-director-0.2.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distributions

deployment_director-0.2.1-py3.7.egg (12.0 kB view details)

Uploaded Source

deployment_director-0.2.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file deployment-director-0.2.1.tar.gz.

File metadata

  • Download URL: deployment-director-0.2.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.5

File hashes

Hashes for deployment-director-0.2.1.tar.gz
Algorithm Hash digest
SHA256 126aa7c220b4899bca83529285afe96c19437405fda6d36fc15056010eb6f813
MD5 e9e4729e820cf965dcbba0b8f1cf269b
BLAKE2b-256 b04f3a2b9b312c546d5eed43af0199b431ff6f4c98fb93103f1b8f73539a0b38

See more details on using hashes here.

File details

Details for the file deployment_director-0.2.1-py3.7.egg.

File metadata

  • Download URL: deployment_director-0.2.1-py3.7.egg
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.5

File hashes

Hashes for deployment_director-0.2.1-py3.7.egg
Algorithm Hash digest
SHA256 66029e7b937c0f9e9851006bc2907f093de4a4e174f932aa4cbe2ad411fd8d1c
MD5 280b12a363cb2e9b2c9fab059fed152f
BLAKE2b-256 f8ad5c25fec4e56e4ed27004c44aa562c25803a0bc4b4c1bc0bdaf5b522daf81

See more details on using hashes here.

File details

Details for the file deployment_director-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: deployment_director-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.5

File hashes

Hashes for deployment_director-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 906548cbdd1da35e6930c5a6b47a50cd0051d4ad18e7f918227c07c3be36fee6
MD5 7358df34ad5035c5140c3642a0af4b67
BLAKE2b-256 565994cc290d69bf947983abb210770be930ff35fcc401727a55a1194e0bf951

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page