mirror of
https://gitlab.com/TECHNOFAB/nixible.git
synced 2025-12-12 10:10:08 +01:00
chore: initial commit
This commit is contained in:
commit
7602719790
24 changed files with 1916 additions and 0 deletions
84
docs/examples.md
Normal file
84
docs/examples.md
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
# Examples
|
||||
|
||||
See the `examples` directory in the repo.
|
||||
|
||||
## Task Examples
|
||||
|
||||
### File Operations
|
||||
|
||||
```nix
|
||||
{
|
||||
name = "Create configuration";
|
||||
template = {
|
||||
src = "nginx.conf.j2";
|
||||
dest = "/etc/nginx/nginx.conf";
|
||||
backup = true;
|
||||
};
|
||||
notify = "restart nginx";
|
||||
}
|
||||
```
|
||||
|
||||
### Service Management
|
||||
|
||||
```nix
|
||||
{
|
||||
name = "Start services";
|
||||
service = {
|
||||
name = "{{ item }}";
|
||||
state = "started";
|
||||
enabled = true;
|
||||
};
|
||||
loop = ["nginx" "postgresql"];
|
||||
}
|
||||
```
|
||||
|
||||
### Conditional Tasks
|
||||
|
||||
```nix
|
||||
{
|
||||
name = "Install SSL certificate";
|
||||
copy = {
|
||||
src = "ssl/cert.pem";
|
||||
dest = "/etc/ssl/certs/";
|
||||
};
|
||||
when = "ssl_enabled | default(false)";
|
||||
}
|
||||
```
|
||||
|
||||
### Block Tasks
|
||||
|
||||
```nix
|
||||
{
|
||||
block = [
|
||||
{
|
||||
name = "Create user";
|
||||
user = {
|
||||
name = "deploy";
|
||||
state = "present";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "Set up SSH key";
|
||||
authorized_key = {
|
||||
user = "deploy";
|
||||
key = "{{ ssh_public_key }}";
|
||||
};
|
||||
}
|
||||
];
|
||||
rescue = [
|
||||
{
|
||||
name = "Log error";
|
||||
debug.msg = "Failed to create user";
|
||||
}
|
||||
];
|
||||
always = [
|
||||
{
|
||||
name = "Cleanup";
|
||||
file = {
|
||||
path = "/tmp/setup";
|
||||
state = "absent";
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue