confctl 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +11 -0
  3. data/.gitignore +8 -0
  4. data/.overcommit.yml +6 -0
  5. data/.rubocop.yml +67 -0
  6. data/.rubocop_todo.yml +5 -0
  7. data/.ruby-version +1 -0
  8. data/CHANGELOG.md +2 -0
  9. data/Gemfile +2 -0
  10. data/LICENSE.txt +674 -0
  11. data/README.md +522 -0
  12. data/Rakefile +40 -0
  13. data/bin/confctl +4 -0
  14. data/confctl.gemspec +33 -0
  15. data/example/.gitignore +2 -0
  16. data/example/README.md +38 -0
  17. data/example/cluster/cluster.nix +7 -0
  18. data/example/cluster/module-list.nix +3 -0
  19. data/example/cluster/nixos-machine/config.nix +15 -0
  20. data/example/cluster/nixos-machine/hardware.nix +4 -0
  21. data/example/cluster/nixos-machine/module.nix +8 -0
  22. data/example/cluster/vpsadminos-container/config.nix +22 -0
  23. data/example/cluster/vpsadminos-container/module.nix +8 -0
  24. data/example/cluster/vpsadminos-machine/config.nix +22 -0
  25. data/example/cluster/vpsadminos-machine/hardware.nix +4 -0
  26. data/example/cluster/vpsadminos-machine/module.nix +8 -0
  27. data/example/cluster/vpsfreecz-vps/config.nix +25 -0
  28. data/example/cluster/vpsfreecz-vps/module.nix +8 -0
  29. data/example/configs/confctl.nix +10 -0
  30. data/example/configs/swpins.nix +28 -0
  31. data/example/data/default.nix +5 -0
  32. data/example/data/ssh-keys.nix +7 -0
  33. data/example/environments/base.nix +13 -0
  34. data/example/modules/module-list.nix +13 -0
  35. data/example/shell.nix +11 -0
  36. data/example/swpins/channels/nixos-unstable.json +35 -0
  37. data/example/swpins/channels/vpsadminos-staging.json +35 -0
  38. data/lib/confctl/cli/app.rb +551 -0
  39. data/lib/confctl/cli/attr_filters.rb +51 -0
  40. data/lib/confctl/cli/cluster.rb +1248 -0
  41. data/lib/confctl/cli/command.rb +206 -0
  42. data/lib/confctl/cli/configuration.rb +296 -0
  43. data/lib/confctl/cli/gen_data.rb +97 -0
  44. data/lib/confctl/cli/generation.rb +335 -0
  45. data/lib/confctl/cli/log_view.rb +267 -0
  46. data/lib/confctl/cli/output_formatter.rb +288 -0
  47. data/lib/confctl/cli/swpins/base.rb +40 -0
  48. data/lib/confctl/cli/swpins/channel.rb +73 -0
  49. data/lib/confctl/cli/swpins/cluster.rb +80 -0
  50. data/lib/confctl/cli/swpins/core.rb +86 -0
  51. data/lib/confctl/cli/swpins/utils.rb +55 -0
  52. data/lib/confctl/cli/swpins.rb +5 -0
  53. data/lib/confctl/cli/tag_filters.rb +30 -0
  54. data/lib/confctl/cli.rb +5 -0
  55. data/lib/confctl/conf_cache.rb +105 -0
  56. data/lib/confctl/conf_dir.rb +88 -0
  57. data/lib/confctl/erb_template.rb +37 -0
  58. data/lib/confctl/exceptions.rb +3 -0
  59. data/lib/confctl/gcroot.rb +30 -0
  60. data/lib/confctl/generation/build.rb +145 -0
  61. data/lib/confctl/generation/build_list.rb +106 -0
  62. data/lib/confctl/generation/host.rb +35 -0
  63. data/lib/confctl/generation/host_list.rb +81 -0
  64. data/lib/confctl/generation/unified.rb +117 -0
  65. data/lib/confctl/generation/unified_list.rb +63 -0
  66. data/lib/confctl/git_repo_mirror.rb +79 -0
  67. data/lib/confctl/health_checks/base.rb +66 -0
  68. data/lib/confctl/health_checks/run_command.rb +179 -0
  69. data/lib/confctl/health_checks/systemd/properties.rb +84 -0
  70. data/lib/confctl/health_checks/systemd/property_check.rb +31 -0
  71. data/lib/confctl/health_checks/systemd/property_list.rb +20 -0
  72. data/lib/confctl/health_checks.rb +5 -0
  73. data/lib/confctl/hook.rb +35 -0
  74. data/lib/confctl/line_buffer.rb +53 -0
  75. data/lib/confctl/logger.rb +151 -0
  76. data/lib/confctl/machine.rb +107 -0
  77. data/lib/confctl/machine_control.rb +172 -0
  78. data/lib/confctl/machine_list.rb +108 -0
  79. data/lib/confctl/machine_status.rb +135 -0
  80. data/lib/confctl/module_options.rb +95 -0
  81. data/lib/confctl/nix.rb +382 -0
  82. data/lib/confctl/nix_build.rb +108 -0
  83. data/lib/confctl/nix_collect_garbage.rb +64 -0
  84. data/lib/confctl/nix_copy.rb +49 -0
  85. data/lib/confctl/nix_format.rb +124 -0
  86. data/lib/confctl/nix_literal_expression.rb +15 -0
  87. data/lib/confctl/parallel_executor.rb +43 -0
  88. data/lib/confctl/pattern.rb +9 -0
  89. data/lib/confctl/settings.rb +50 -0
  90. data/lib/confctl/std_line_buffer.rb +40 -0
  91. data/lib/confctl/swpins/change_set.rb +151 -0
  92. data/lib/confctl/swpins/channel.rb +62 -0
  93. data/lib/confctl/swpins/channel_list.rb +47 -0
  94. data/lib/confctl/swpins/cluster_name.rb +94 -0
  95. data/lib/confctl/swpins/cluster_name_list.rb +15 -0
  96. data/lib/confctl/swpins/core.rb +137 -0
  97. data/lib/confctl/swpins/deployed_info.rb +23 -0
  98. data/lib/confctl/swpins/spec.rb +20 -0
  99. data/lib/confctl/swpins/specs/base.rb +184 -0
  100. data/lib/confctl/swpins/specs/directory.rb +51 -0
  101. data/lib/confctl/swpins/specs/git.rb +135 -0
  102. data/lib/confctl/swpins/specs/git_rev.rb +24 -0
  103. data/lib/confctl/swpins.rb +17 -0
  104. data/lib/confctl/system_command.rb +10 -0
  105. data/lib/confctl/user_script.rb +13 -0
  106. data/lib/confctl/user_scripts.rb +41 -0
  107. data/lib/confctl/utils/file.rb +21 -0
  108. data/lib/confctl/version.rb +3 -0
  109. data/lib/confctl.rb +43 -0
  110. data/man/man8/confctl-options.nix.8 +1334 -0
  111. data/man/man8/confctl-options.nix.8.md +1340 -0
  112. data/man/man8/confctl.8 +660 -0
  113. data/man/man8/confctl.8.md +654 -0
  114. data/nix/evaluator.nix +160 -0
  115. data/nix/lib/default.nix +83 -0
  116. data/nix/lib/machine/default.nix +74 -0
  117. data/nix/lib/machine/info.nix +5 -0
  118. data/nix/lib/swpins/eval.nix +71 -0
  119. data/nix/lib/swpins/options.nix +94 -0
  120. data/nix/machines.nix +31 -0
  121. data/nix/modules/cluster/default.nix +459 -0
  122. data/nix/modules/confctl/cli.nix +21 -0
  123. data/nix/modules/confctl/generations.nix +84 -0
  124. data/nix/modules/confctl/nix.nix +28 -0
  125. data/nix/modules/confctl/swpins.nix +55 -0
  126. data/nix/modules/module-list.nix +19 -0
  127. data/shell.nix +42 -0
  128. data/template/confctl-options.nix/main.erb +45 -0
  129. data/template/confctl-options.nix/options.erb +15 -0
  130. metadata +353 -0
@@ -0,0 +1,22 @@
1
+ { config, pkgs, lib, ... }:
2
+ {
3
+ imports = [
4
+ ../../environments/base.nix
5
+ <vpsadminos/os/lib/nixos-container/vpsadminos.nix>
6
+ ];
7
+
8
+ networking.hostName = "vpsadminos-container";
9
+
10
+ environment.systemPackages = with pkgs; [
11
+ vim
12
+ ];
13
+
14
+ networking.useDHCP = false;
15
+ services.resolved.enable = false;
16
+ systemd.services.systemd-udev-trigger.enable = false;
17
+
18
+ documentation.enable = true;
19
+ documentation.nixos.enable = true;
20
+
21
+ system.stateVersion = "20.09";
22
+ }
@@ -0,0 +1,8 @@
1
+ { config, ... }:
2
+ {
3
+ cluster."vpsadminos-container" = {
4
+ spin = "nixos";
5
+ swpins.channels = [ "nixos-unstable" "vpsadminos-staging" ];
6
+ host.target = "<ip address>";
7
+ };
8
+ }
@@ -0,0 +1,22 @@
1
+ { config, pkgs, lib, ... }:
2
+ {
3
+ imports = [
4
+ ../../environments/base.nix
5
+ ./hardware.nix
6
+ ];
7
+
8
+ networking.hostName = "vpsadminos-machine";
9
+
10
+ boot.loader.grub.enable = true;
11
+ boot.loader.grub.version = 2;
12
+ # boot.loader.grub.device = "";
13
+
14
+ boot.supportedFilesystems = [ "zfs" ];
15
+ boot.kernelParams = [ "nolive" ];
16
+
17
+ boot.zfs.pools = {
18
+ # ZFS pool configuration
19
+ };
20
+
21
+ system.stateVersion = "20.09";
22
+ }
@@ -0,0 +1,4 @@
1
+ { config, pkgs, lib, ... }:
2
+ {
3
+ # Your hardware-configuration.nix
4
+ }
@@ -0,0 +1,8 @@
1
+ { config, ... }:
2
+ {
3
+ cluster."vpsadminos-machine" = {
4
+ spin = "nixos";
5
+ swpins.channels = [ "vpsadminos-staging" "nixos-unstable" ];
6
+ host.target = "<ip address>";
7
+ };
8
+ }
@@ -0,0 +1,25 @@
1
+ { config, pkgs, lib, ... }:
2
+ {
3
+ imports = [
4
+ ../../environments/base.nix
5
+ <vpsadminos/os/lib/nixos-container/vpsadminos.nix>
6
+ ];
7
+
8
+ networking.hostName = "vpsfreecz-vps";
9
+
10
+ environment.systemPackages = with pkgs; [
11
+ vim
12
+ ];
13
+
14
+ networking.useDHCP = false;
15
+ services.resolved.enable = false;
16
+ systemd.extraConfig = ''
17
+ DefaultTimeoutStartSec=900s
18
+ '';
19
+ systemd.services.systemd-udev-trigger.enable = false;
20
+
21
+ documentation.enable = true;
22
+ documentation.nixos.enable = true;
23
+
24
+ system.stateVersion = "20.09";
25
+ }
@@ -0,0 +1,8 @@
1
+ { config, ... }:
2
+ {
3
+ cluster."vpsfreecz-vps" = {
4
+ spin = "nixos";
5
+ swpins.channels = [ "nixos-unstable" "vpsadminos-staging" ];
6
+ host.target = "<ip address>";
7
+ };
8
+ }
@@ -0,0 +1,10 @@
1
+ { config, ... }:
2
+ {
3
+ confctl = {
4
+ # listColumns = {
5
+ # "name"
6
+ # "spin"
7
+ # "host.fqdn"
8
+ # };
9
+ };
10
+ }
@@ -0,0 +1,28 @@
1
+ { config, ... }:
2
+ let
3
+ nixpkgsBranch = branch: {
4
+ type = "git-rev";
5
+
6
+ git-rev = {
7
+ url = "https://github.com/NixOS/nixpkgs";
8
+ update.ref = "refs/heads/${branch}";
9
+ };
10
+ };
11
+
12
+ vpsadminosBranch = branch: {
13
+ type = "git-rev";
14
+
15
+ git-rev = {
16
+ url = "https://github.com/vpsfreecz/vpsadminos";
17
+ update.ref = "refs/heads/${branch}";
18
+ };
19
+ };
20
+ in {
21
+ confctl.swpins.channels = {
22
+ nixos-unstable = { nixpkgs = nixpkgsBranch "nixos-unstable"; };
23
+
24
+ # nixos-stable = { nixpkgs = nixpkgsBranch "nixos-20.09"; };
25
+
26
+ vpsadminos-staging = { vpsadminos = vpsadminosBranch "staging"; };
27
+ };
28
+ }
@@ -0,0 +1,5 @@
1
+ { lib }:
2
+ {
3
+ # Place to load custom data sets
4
+ sshKeys = import ./ssh-keys.nix;
5
+ }
@@ -0,0 +1,7 @@
1
+ rec {
2
+ admins = [
3
+ # someone
4
+ ];
5
+
6
+ someone = "...ssh public key...";
7
+ }
@@ -0,0 +1,13 @@
1
+ { config, pkgs, confData, ... }:
2
+ {
3
+ time.timeZone = "Europe/Amsterdam";
4
+
5
+ services.openssh.enable = true;
6
+
7
+ environment.systemPackages = with pkgs; [
8
+ vim
9
+ screen
10
+ ];
11
+
12
+ users.users.root.openssh.authorizedKeys.keys = with confData.sshKeys; admins;
13
+ }
@@ -0,0 +1,13 @@
1
+ rec {
2
+ shared = [
3
+ # Modules not dependent on spin
4
+ ];
5
+
6
+ nixos = shared ++ [
7
+ # Modules only for NixOS
8
+ ];
9
+
10
+ vpsadminos = shared ++ [
11
+ # Modules only for vpsAdminOS
12
+ ];
13
+ }
data/example/shell.nix ADDED
@@ -0,0 +1,11 @@
1
+ # When a part of confctl repository
2
+ import ../shell.nix
3
+
4
+ # When copied elsewhere
5
+ # if builtins.pathExists ../confctl/shell.nix then
6
+ # import ../confctl/shell.nix
7
+ # else if builtins.pathExists ../../confctl/shell.nix then
8
+ # import ../../confctl/shell.nix
9
+ # else if builtins.pathExists /where-is-your-confctl/shell.nix then
10
+ # import /where-is-your-confctl/shell.nix
11
+ # else builtins.abort "Unable to find confctl shell"
@@ -0,0 +1,35 @@
1
+ {
2
+ "nixpkgs": {
3
+ "type": "git-rev",
4
+ "nix_options": {
5
+ "fetchSubmodules": false,
6
+ "update": {
7
+ "auto": false,
8
+ "interval": 3600,
9
+ "ref": "refs/heads/nixos-unstable"
10
+ },
11
+ "url": "https://github.com/NixOS/nixpkgs"
12
+ },
13
+ "state": {
14
+ "rev": "ff9efb0724de5ae0f9db9df2debefced7eb1571d",
15
+ "date": "2022-04-14T19:08:46+02:00"
16
+ },
17
+ "info": {
18
+ "rev": "ff9efb0724de5ae0f9db9df2debefced7eb1571d",
19
+ "sha256": "188h461pilsiym2dqzl17vx1g9pb816cwdi0az9mbw207w721avz"
20
+ },
21
+ "fetcher": {
22
+ "type": "git-rev",
23
+ "options": {
24
+ "rev": "ff9efb0724de5ae0f9db9df2debefced7eb1571d",
25
+ "wrapped_fetcher": {
26
+ "type": "zip",
27
+ "options": {
28
+ "url": "https://github.com/NixOS/nixpkgs/archive/ff9efb0724de5ae0f9db9df2debefced7eb1571d.tar.gz",
29
+ "sha256": "188h461pilsiym2dqzl17vx1g9pb816cwdi0az9mbw207w721avz"
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "vpsadminos": {
3
+ "type": "git-rev",
4
+ "nix_options": {
5
+ "fetchSubmodules": false,
6
+ "update": {
7
+ "auto": false,
8
+ "interval": 3600,
9
+ "ref": "refs/heads/staging"
10
+ },
11
+ "url": "https://github.com/vpsfreecz/vpsadminos"
12
+ },
13
+ "state": {
14
+ "rev": "87481308b69dc3ae001a9a11073b07cae230ee75",
15
+ "date": "2022-04-14T19:02:59+02:00"
16
+ },
17
+ "info": {
18
+ "rev": "87481308b69dc3ae001a9a11073b07cae230ee75",
19
+ "sha256": "0bhy9jb0ji19aknhcibfk7z9yg66vwihy11c631alk45k8z3j4v8"
20
+ },
21
+ "fetcher": {
22
+ "type": "git-rev",
23
+ "options": {
24
+ "rev": "87481308b69dc3ae001a9a11073b07cae230ee75",
25
+ "wrapped_fetcher": {
26
+ "type": "zip",
27
+ "options": {
28
+ "url": "https://github.com/vpsfreecz/vpsadminos/archive/87481308b69dc3ae001a9a11073b07cae230ee75.tar.gz",
29
+ "sha256": "0bhy9jb0ji19aknhcibfk7z9yg66vwihy11c631alk45k8z3j4v8"
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }