The install
command applies changes to the host system as specified in the manifest. The purpose of the install command is to setup a host sytem, the inverse operation being remove.
Consider the example manifest below:
{
"name": "example",
"version": "0.0.1",
"metadata": {
"gene_system": {
"version": "0.3.2"
}
},
"steps": [
{
"name": "install awscli",
"exe": {
"install": {
"skip": "brew ls --version awscli",
"cmd": [
"brew install awscli"
]
},
"remove": {
"cmd": [
"brew remove awscli"
]
}
},
"tags": "example install awscli"
}
{
"name": "greet user",
"exe": {
"install": {
"skip": "[ -f $HOME/.user-greeted ]",
"prompts": [
{
"prompt": "Please enter your name",
"var": "user_name"
}
],
"cmd": [
"echo 'Hello {{user_name}}'",
"touch $HOME/.user-greeted"
]
},
},
"tags": "example say hello"
}
]
}
Running the install command like this:
genesystem install --manfest /path/to/manifest.json
Will execute the install
block in step sequence. Considering the example above, the following will happen in the following order:
- We check to see if
awscli
brew is installed, if it is the step will be skipped. awscli
brew package will be installed- We then check to see if a file
$HOME/.user-greeted
exists, if it does the step will be skipped. - The user will be prompted for their name
- Then an
echo
command will be executed to say hello to the user. - Then a
$HOME/.user-greeted
file will be created so the user is not greeted on the next run of the manifest.
This demonstrates a few properties of manifest steps.
- Skip is executed before the user is prompted
- Prompts are executed after skip check, before commands
- Commands are run in sequence and may use variables set by the prompt.
Beyond that, manifests should be designed to run many times as both a setup and update tool. Keep this in mind when constructing manifests.
If the --manifest
flag is not provided, you’ll be prompted for a path to the manifest:
Please enter the path to the configuration manifest (manifest.json)
By default it will pick a manifest.json
file in the current directory.
Filtering Steps
It is possible to either include or exclude steps using the step tags.
For example if from the following example:
{
"name": "example",
"version": "0.0.1",
"metadata": {
"gene_system": {
"version": "0.3.2"
}
},
"steps": [
{
"name": "install awscli",
"exe": {
"install": {
"skip": "brew ls --version awscli",
"cmd": [
"brew install awscli"
]
},
"remove": {
"cmd": [
"brew remove awscli"
]
}
},
"tags": "example install awscli"
},
{
"name": "install libxml",
"exe": {
"install": {
"skip": "brew ls --version libxml",
"cmd": [
"brew install libxml"
]
},
"remove": {
"cmd": [
"brew remove libxml"
]
}
},
"tags": "example install libxml"
},
{
"name": "install libssl",
"exe": {
"install": {
"skip": "brew ls --version libssl",
"cmd": [
"brew install libssl"
]
},
"remove": {
"cmd": [
"brew remove libssl"
]
}
},
"tags": "install libssl"
}
]
}
We only want to install awscli
you can use the --include-tags
option on the install
command like this:
genesystem install --include-tags awscli
The inverse operation is --exclude-tags
and works in the opposite way, where steps with the provided tags are excluded from the run. So if we were wanting to skip installing awscli
, that could be achieved thus:
genesystem install --exclude-tags awscli
You may choose to specify 1 tag or many in both --include-tags
or --exclude-tags
, each tag is specified in a space delimited list:
genesystem install --include-tags example awscli
Finally it is possible to include and then exclude. Just note that the inclusion is executed first, that is useful if you want to reject steps from a smaller set of steps.
genesystem install --include-tags example --exclude-tags awscli