Ansible playbook driver options
Ansible playbook driver options specification
A builder provides relevant information about how to build a Docker image. It is defined using a YAML data structure, and its schema is described on Keywords reference for builders configuration.
There are two types of builders: global and in-line. Global builders are defined in a builders configuration file and can be used by any image. Information on how to set the location path for the builders configuration file can be found in the configuration documentation.
In-line builders, on the other hand, are defined within the image definition itself.
A global builder must be defined under the builders
block inside the Stevedore configuration. It means that Stevedore looks for the builders
block within the file defined in builders_path configuration parameter.
You can also set a directory on the builders_path. There you can create several files with the builders
block defined on them. In that case, Stevedore loads the builders found within all files.
|
|
builder1
, builder2
and builder3
, all of them are defined under the builders
block.Through Stevedore CLI command, you can retrieve the value of the builders_path configuration parameter.
$ stevedore get configuration
builders_path: stevedore.yaml
concurrency: 4
semantic_version_tags_enabled: false
images_path: stevedore.yaml
push_images: false
semantic_version_tags_templates:
- {{ .Major }}.{{ .Minor }}.{{ .Patch }}
credentials:
storage_type: local
format: json
local_storage_path: credentials
encryption_key: 12345asdfg
When you want to create an image using an ad-hoc builder, you can provide it in the image definition itself. In that case, the builder is known as an in-line builder.
In-line builders are defined following the Keywords reference for builders’ configuration as well.
|
|
The coming section describes the keyword attributes required to define a builder.
Keyword | Type | Description | Value |
---|---|---|---|
name | string | Name of the builder optional | When you create a global builder, by default its name is inherited from the key used within the builders’ data structure. If the builder is defined as an in-line builder, its name is set as the image’s name. |
driver | string | Driver to be used to build the image mandatory | The allowed values are: - ansible-playbook - docker |
options | map | Options hold those parameters required by the driver mandatory | Each driver requires its own configuration parameters. Refer to the options reference for a detailed description. |
variables_mapping | map | Stevedore creates automatically a bunch of parameters, such as the image name or image version. The variables mapping is a key-value data structure where you can override the name of those variables that Stevedore creates and passes to drivers. optional | Each driver requires its own variables mapping. Refer to the variables mapping for a detailed description. |
Builder options are defined in a YAML data structure, and each driver has its own unique set of options. To learn more about which options are accepted by a particular driver, refer to the corresponding section:
Stevedore always sends a set of parameters to the driver when building a Docker image. These parameters are organized in a key-value data structure called variables_mapping
. Importantly, these parameters are sent to the driver by Stevedore regardless of whether they have been explicitly specified in the image definition or as a CLI flag.
When Stevedore sets a parameter to the driver that comes from the variables_mapping
, it searches for the corresponding argument-name in the variables_mapping
dictionary in the builder’s definition. Users can override the default name of the argument by providing a new name for that argument in the same variables_mapping
block.
For example, Stevedore sends the parent name and version to the driver even if the user doesn’t request them. These parameters are then passed as build arguments to Docker, making them available in the Dockerfile.
It’s important to understand the concepts within the variables-mapping context, such as the key name, argument name, and argument value:
variables-mapping
, please refer to variables-mapping for Ansible playbook driver or variables-mapping for Docker driver.Each driver receives a distinct set of parameters coming from variables-mapping. Refer to the following links to know more about the variables that each driver receives:
The following example demonstrates how to define a builder that uses Docker as the driver, with a local build context and a Dockerfile located at build/Dockerfile
:
|
|
The following example demonstrates how to define a builder that uses Docker as the driver, with a remote Git repository as the build context and a Dockerfile located at build/Dockerfile
. Besides, the Git repository https://github.com/apenella/simple-go-helloworld.git
is used as the build context with the reference v1.2.3
.
|
|
The following example shows how to define a builder that uses the ansible-playbook driver. In this example, the builder optiosn defines the ansible inventory and playbook, pointing to the Ansible inventory file located at inventory/all and the playbook file located at build_applications.yml.
|
|
Ansible playbook driver options specification
Docker driver options specification