diff --git a/README.md b/README.md index 1ab1e58..639e3b4 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ If your configuration is right and Vault is running on the same host as the agen ## Configuration -`addr` The address of the Vault cluster. This is used to check the Vault cluster leader IP, as well as generate snapshots. +`addr` The address of the Vault cluster. This is used to check the Vault cluster leader IP, as well as generate snapshots. Defaults to "http://127.0.0.1:8200". `retain` The number of backups to retain. @@ -65,7 +65,7 @@ If your configuration is right and Vault is running on the same host as the agen `secret_id` Specifies the secret_id used to call the Vault API. -`approle` Specifies the approle name used to login. +`approle` Specifies the approle name used to login. Defaults to "approle". ### Storage options diff --git a/main.go b/main.go index 4ff40c4..4af6bd8 100644 --- a/main.go +++ b/main.go @@ -35,14 +35,15 @@ func main() { } snapshotter, err := snapshot_agent.NewSnapshotter(c) + if err != nil { + log.Fatalln("Cannot instantiate snapshotter.", err) + } frequency, err := time.ParseDuration(c.Frequency) if err != nil { frequency = time.Hour } - if err != nil { - log.Fatalln("Error retrieving Current instance IP. Verify internet connectivity.") - } + for { if snapshotter.TokenExpiration.Before(time.Now()) { snapshotter.SetClientTokenFromAppRole(c) @@ -94,4 +95,4 @@ func logSnapshotError(dest, snapshotPath string, err error) { } else { log.Printf("Successfully created %s snapshot to %s\n", dest, snapshotPath) } -} \ No newline at end of file +} diff --git a/snapshot_agent/agent.go b/snapshot_agent/agent.go index 0430d81..06a44eb 100644 --- a/snapshot_agent/agent.go +++ b/snapshot_agent/agent.go @@ -58,7 +58,9 @@ func NewSnapshotter(config *config.Configuration) (*Snapshotter, error) { func (s *Snapshotter) ConfigureVaultClient(config *config.Configuration) error { vaultConfig := vaultApi.DefaultConfig() - vaultConfig.Address = config.Address + if config.Address != "" { + vaultConfig.Address = config.Address + } tlsConfig := &vaultApi.TLSConfig{ Insecure: true, }