It serves to deploy config files to pc by yaml
description.
It can:
- create symlinks
- expand templates
- execute commands
It shows execution log gracefully:
- what was changed
- what wasn't changed
- what wasn't able to succeed
By go
compiler tools:
go install github.com/backdround/deploy-configs@main
Lets create sample config repository to deploy:
./configs
├── .git
├── deploy-configs.yaml
└── terminal
├── tmux
└── gitconfig
deploy-configs.yaml
contains yaml that drives deploying process:
instances:
home:
links:
tmux:
target: "{{.GitRoot}}/terminal/tmux"
link: "{{.Home}}/.tmux.conf"
git:
target: "{{.GitRoot}}/terminal/gitconfig"
link: "{{.Home}}/.gitconfig"
To deploy home
instance we execute application:
deploy-configs home
Result user home tree with deployed configs:
/home/user/
├── .gitconfig -> /home/user/configs/terminal/gitconfig
├── .tmux.conf -> /home/user/configs/terminal/tmux
└── configs
└── ... # output truncated
# Config repository to deploy
./configs
├── .git
├── deploy-configs.yaml
├── desktop
│ ├── flameshot.ini
│ └── i3_template
├── git
│ └── gitconfig
└── terminal
└── tmux
# deploy-configs.yaml
instances:
home:
links:
tmux:
target: "{{.GitRoot}}/terminal/tmux"
link: "{{.Home}}/.tmux.conf"
git:
target: "{{.GitRoot}}/git/gitconfig"
link: "{{.Home}}/.gitconfig"
commands:
flameshot:
input: "{{.GitRoot}}/desktop/flameshot.ini"
output: "{{.Home}}/.config/flameshot/flameshot.ini"
command: "sed \"s~%HOMEDIR%~$HOME~g\" '{{.Input}}' > '{{.Output}}'"
templates:
i3:
input: "{{.GitRoot}}/desktop/i3_template"
output: "{{.Home}}/.config/i3/config"
data:
telegram:
size: "525 700"
position: "1348 96"
monitors:
left: "DP-2"
right: "HDMI-3"
# Deploying `home` instance
deploy-configs home
# Result home tree with deployed configs
/home/user/
├── .config
│ ├── flameshot
│ │ └── flameshot.ini
│ └── i3
│ └── config
├── .gitconfig -> /home/user/configs/git/gitconfig
├── .tmux.conf -> /home/user/configs/terminal/tmux
└── configs
└── ... # output truncated
Application deploys config files in accordance with deploy-configs.yaml
. It
searches file recursively from current directory to root.
Main structure
Schematic example:
# Arbitrary data that you need in your instances
<any-shared-data>:
any:
- shared
- data
# Field contains a dictionary with all possible instances.
instances:
# Instance is a set of deploying operation for performing at once.
<instance-one>:
[links:]
[templates:]
[commands:]
<instance-two>:
[links:]
[templates:]
[commands:]
...
Real example:
.dev-links: &dev-links
tmux:
target: "{{.GitRoot}}/terminal/tmux"
link: "{{.Home}}/.tmux.conf"
zsh:
target: "{{.GitRoot}}/terminal/zshrc"
link: "{{.Home}}/.zshrc"
instances:
home:
links:
<<: *dev-links
work:
links:
<<: *dev-links
templates:
...
Links
Links field describes links that are needed to be created.
Ripped out example:
links:
# Name is used in logs.
tmux:
# Target is a destination for link.
target: "{{.GitRoot}}/terminal/tmux"
# Link is used as a path to link creation.
link: "{{.Home}}/.tmux.conf"
zsh:
target: "{{.GitRoot}}/terminal/zshrc"
link: "{{.Home}}/.zshrc"
Templates
Templates field describes templates that are needed to be expanded and deployed.
Ripped out example:
templates:
# Name is used in logs.
i3:
# Input is a path to a `go` template (text/template).
input: "{{.GitRoot}}/desktop/i3_template"
# Output is a path to an expanded template.
output: "{{.Home}}/.config/i3/config"
# Data is an arbitrary structured data for template expantion.
data:
telegram:
size: "525 700"
position: "1348 96"
monitors:
left: "DP-2"
right: "HDMI-3"
Commands
Commands field describes commands that create output
files after execution.
Ripped out example:
commands:
# Name is used in logs.
flameshot:
# Input is a path to a command source config.
input: "{{.GitRoot}}/desktop/flameshot.ini"
# Output is a path to a generated config.
output: "{{.Home}}/.config/flameshot/flameshot.ini"
# Command converts the `input` config to an `output` config.
# It allows {{.Input}} and {{.Output}} substitutions accordingly.
command: "sed \"s~%HOMEDIR%~$HOME~g\" '{{.Input}}' > '{{.Output}}'"
There are some replacements to define paths:
- {{.GitRoot}} - expands into current git directory.
- {{.Home}} - expands into current user home directory.
It expands only in specific fields which are used for path holding.
Example:
links:
git:
target: "{{.GitRoot}}/git/gitconfig"
link: "{{.Home}}/.gitconfig"
It will expand to:
links:
git:
target: "/home/user/configs/git/gitconfig"
link: "/home/user/.gitconfig"