-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
250 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1 @@ | ||
let | ||
httpServer = content: { pkgs, ... }: { | ||
networking.firewall.allowedTCPPorts = [ 80 443 ]; | ||
services.nginx = { | ||
enable = true; | ||
virtualHosts.localhost = { | ||
locations."/" = { | ||
root = pkgs.runCommand "hej" {} '' | ||
mkdir -p $out | ||
printf %s '${content}' > $out/index.html | ||
''; | ||
}; | ||
}; | ||
}; | ||
}; | ||
in { | ||
"aws-1" = { config, ... }: { | ||
require = [ | ||
(httpServer '' | ||
hej hej Im nixos-1 : ${config.terranix.aws-1.ip} | ||
'') | ||
]; | ||
}; | ||
} | ||
import ../network-1-node.nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
http-server = content: { pkgs, ... }: { | ||
networking.firewall.allowedTCPPorts = [ 80 443 ]; | ||
services.nginx = { | ||
enable = true; | ||
virtualHosts.localhost = { | ||
locations."/" = { | ||
root = pkgs.runCommand "http-server-content" {} '' | ||
mkdir -p $out | ||
cat > $out/index.html <<EOF | ||
<pre> | ||
${content} | ||
</pre> | ||
EOF | ||
''; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
info = with builtins; cfg: | ||
concatStringsSep "" (map (x: '' | ||
${x.name} | ||
============== | ||
provider: ${x.provider} | ||
ip: ${x.ip} | ||
'') (attrValues cfg) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1 @@ | ||
let | ||
httpServer = content: { pkgs, ... }: { | ||
networking.firewall.allowedTCPPorts = [ 80 443 ]; | ||
services.nginx = { | ||
enable = true; | ||
virtualHosts.localhost = { | ||
locations."/" = { | ||
root = pkgs.runCommand "hej" {} '' | ||
mkdir -p $out | ||
printf %s '${content}' > $out/index.html | ||
''; | ||
}; | ||
}; | ||
}; | ||
}; | ||
in { | ||
"do-1" = { config, ... }: { | ||
require = [ | ||
(httpServer '' | ||
hej hej Im nixos-1 : ${config.terranix.do-1.ip} | ||
'') | ||
]; | ||
}; | ||
} | ||
import ../network-1-node.nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
variable "name" {} | ||
variable "authorized_keys" { | ||
type = "list" | ||
} | ||
|
||
resource "hcloud_ssh_key" "default" { | ||
name = "Some SSH key" | ||
public_key = "${var.authorized_keys[0]}" | ||
} | ||
|
||
resource "hcloud_server" "ubuntu" { | ||
name = "terranix-${var.name}" | ||
server_type = "cx11" | ||
image = "ubuntu-18.04" | ||
ssh_keys = ["${hcloud_ssh_key.default.id}"] | ||
} | ||
|
||
output "provider" { | ||
value = "hcloud" | ||
} | ||
|
||
output "name" { | ||
value = "${var.name}" | ||
} | ||
|
||
output "ip" { | ||
value = "${hcloud_server.ubuntu.ipv4_address}" | ||
} | ||
|
||
output "authorized_keys" { | ||
value = ["${var.authorized_keys[0]}"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
variable "hcloud_token" {} | ||
|
||
provider "hcloud" { | ||
token = "${var.hcloud_token}" | ||
} | ||
|
||
module "node-1" { | ||
source = "./hcloud_nixos" | ||
name = "node-1" | ||
authorized_keys = [ "${file("${path.module}/../ssh_key.pub")}" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import ../network-1-node.nix |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1 @@ | ||
let | ||
# libvirt specific configuration | ||
virtlib = ./libvirt_nixos/conf.nix; | ||
|
||
httpServer = content: { pkgs, ... }: { | ||
networking.firewall.allowedTCPPorts = [ 80 443 ]; | ||
services.nginx = { | ||
enable = true; | ||
virtualHosts.localhost = { | ||
locations."/" = { | ||
root = pkgs.runCommand "hej" {} '' | ||
mkdir -p $out | ||
printf %s '${content}' > $out/index.html | ||
''; | ||
}; | ||
}; | ||
}; | ||
}; | ||
in { | ||
"nixos-1" = { config, ... }: { require = [ virtlib (httpServer '' | ||
hej hej Im nixos-1 : ${config.terranix.nixos-1.ip} | ||
'') ]; }; | ||
"nixos-2" = { config, ... }: { require = [ virtlib (httpServer '' | ||
hello my name is nixos-2 and my IP is ${config.terranix.nixos-2.ip} | ||
'') ]; }; | ||
} | ||
import ../network-2-nodes.nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
let | ||
common = import ./common.nix; | ||
in { | ||
"node-1" = { config, ... }: { | ||
require = [ (common.http-server '' | ||
hej hej I'm node-1 | ||
${common.info config.terranix} | ||
'') ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
let | ||
common = import ./common.nix; | ||
in { | ||
"node-1" = { config, ... }: { | ||
require = [ (common.http-server '' | ||
hej hej I'm node-1 | ||
${common.info config.terranix} | ||
'') ]; | ||
}; | ||
"node-2" = { config, ... }: { | ||
require = [ (common.http-server '' | ||
hello my name is node-2 | ||
${common.info config.terranix} | ||
'') ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.