-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
67 lines (65 loc) · 2.11 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{
description = "Flake for running ansible scripts";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
};
outputs = { self, nixpkgs, flake-utils, devshell }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs {
inherit system;
overlays = [
devshell.overlays.default
];
};
in
{
devShells.default =
pkgs.devshell.mkShell {
packages = [
pkgs.ansible
pkgs.netcat
pkgs.tree
pkgs.doctl
];
commands = [
{
name = ''new-role'';
help = ''scaffolds new role with given name'';
category = ''ansible tasks'';
command =
''
ROLESDIR=$(git rev-parse --show-toplevel)/roles/$1
mkdir -p $ROLESDIR/{tasks,templates,files,defaults,meta}
touch $ROLESDIR/{tasks,defaults,meta}/main.yml
echo "# $1" >> $ROLESDIR/README.md
echo "new role created: "
tree $ROLESDIR
'';
}
{
name = ''new-inventory'';
help = ''scaffolds new inventory with given name'';
category = ''ansible tasks'';
command =
''
INVDIR=$(git rev-parse --show-toplevel)/inventories/$1
mkdir -p $INVDIR/group_vars/all
touch $INVDIR/group_vars/all/vault.yml
echo "# $1 Inventory" >> $INVDIR/README.md
cat <<EOF > $INVDIR/inventory.yml
---
$1:
vars:
hosts:
children:
EOF
echo "new inventory created: "
tree $INVDIR
'';
}
];
};
});
}