Compare commits

..

3 Commits

Author SHA1 Message Date
Brian Picciano
97d4aacc15 Make output of hosts list more useful 2022-11-05 16:55:17 +01:00
Brian Picciano
0d7d69679f Rename to make-bootstrap to create-bootstrap 2022-11-05 16:41:14 +01:00
Brian Picciano
4bc0750797 Adjust .gitignore after change to yml 2022-11-05 16:32:26 +01:00
7 changed files with 30 additions and 20 deletions

4
.gitignore vendored
View File

@ -1,4 +1,4 @@
*-bin
*-admin.tgz*
*-bootstrap.tgz
*admin.yml*
*bootstrap.yml*
result

View File

@ -43,7 +43,7 @@ To create a `bootstrap.yml` file for the new host, the admin should perform the
following command from their own host:
```
cryptic-net hosts make-bootstrap \
cryptic-net hosts create-bootstrap \
--hostname <name> \
--ip <ip> \
--admin-path <path to admin.yml> \
@ -61,12 +61,12 @@ running their host's `cryptic-net daemon`.
### Encrypted `admin.yml`
If `admin.yml` is kept in an encrypted format on disk (it should be!) then the
decrypted form can be piped into `make-bootstrap` over stdin. For example, if
decrypted form can be piped into `create-bootstrap` over stdin. For example, if
GPG is being used to secure `admin.yml` then the following could be used to
generate a `bootstrap.yml`:
```
gpg -d <path to admin.yml.gpg> | cryptic-net hosts make-boostrap \
gpg -d <path to admin.yml.gpg> | cryptic-net hosts create-bootstrap \
--hostname <name> \
--ip <ip> \
--admin-path - \

View File

@ -11,10 +11,6 @@ func (b Bootstrap) GaragePeers() []garage.RemotePeer {
for _, host := range b.Hosts {
if host.Garage == nil {
continue
}
for _, instance := range host.Garage.Instances {
peer := garage.RemotePeer{
@ -49,7 +45,7 @@ func (b Bootstrap) ChooseGaragePeer() garage.RemotePeer {
thisHost := b.ThisHost()
if thisHost.Garage != nil && len(thisHost.Garage.Instances) > 0 {
if len(thisHost.Garage.Instances) > 0 {
inst := thisHost.Garage.Instances[0]
return garage.RemotePeer{

View File

@ -58,9 +58,9 @@ type GarageHost struct {
// Host consolidates all information about a single host from the bootstrap
// file.
type Host struct {
Name string `yaml:"name"`
Nebula NebulaHost `yaml:"nebula"`
Garage *GarageHost `yaml:"garage,omitempty"`
Name string `yaml:"name"`
Nebula NebulaHost `yaml:"nebula"`
Garage GarageHost `yaml:"garage,omitempty"`
}
// IP returns the IP address encoded in the Host's nebula certificate, or panics

View File

@ -245,8 +245,8 @@ var subCmdAdminCreateNetwork = subCmd{
},
}
var subCmdAdminMakeBootstrap = subCmd{
name: "make-bootstrap",
var subCmdAdminCreateBootstrap = subCmd{
name: "create-bootstrap",
descr: "Creates a new bootstrap.yml file for a particular host and writes it to stdout",
checkLock: true,
do: func(subCmdCtx subCmdCtx) error {
@ -335,7 +335,7 @@ var subCmdAdmin = subCmd{
do: func(subCmdCtx subCmdCtx) error {
return subCmdCtx.doSubCmd(
subCmdAdminCreateNetwork,
subCmdAdminMakeBootstrap,
subCmdAdminCreateBootstrap,
)
},
}

View File

@ -26,8 +26,6 @@ func mergeDaemonConfigIntoBootstrap(
if allocs := daemonConfig.Storage.Allocations; len(allocs) > 0 {
host.Garage = new(bootstrap.GarageHost)
for _, alloc := range allocs {
id, err := garage.InitAlloc(alloc.MetaPath)

View File

@ -38,8 +38,24 @@ var subCmdHostsList = subCmd{
return fmt.Errorf("retrieving hosts from garage: %w", err)
}
hosts := make([]bootstrap.Host, 0, len(hostsMap))
for _, host := range hostsMap {
type host struct {
Name string `yaml:"name"`
Nebula struct {
IP string `yaml:"ip"`
} `yaml:"nebula"`
Garage bootstrap.GarageHost `yaml:"garage,omitempty"`
}
hosts := make([]host, 0, len(hostsMap))
for _, h := range hostsMap {
host := host{
Name: h.Name,
Garage: h.Garage,
}
host.Nebula.IP = h.IP().String()
hosts = append(hosts, host)
}