package cluster import ( "github.com/hack-pad/hackpadfs" ) // SyncAll updates all config files func (m *Cluster) SyncAll() error { for _, fn := range []func() error{ m.MkdirAll, m.SyncAllWireguard, m.SyncAllCeph, m.WriteHosts, } { if err := fn(); err != nil { return err } } return nil } // MkdirAll creates the directories needed to store files // required to represent the cluster. func (m *Cluster) MkdirAll() error { err := hackpadfs.MkdirAll(m.dir, ".", 0755) if err == nil { m.ForEachMachine(func(p *Machine) bool { err = p.MkdirAll() return err != nil }) } return err } // SyncAllWireguard updates all wireguard config files func (m *Cluster) SyncAllWireguard() error { var err error for ring := 0; ring < RingsCount; ring++ { err = m.WriteWireguardKeys(ring) if err != nil { return err } err = m.SyncWireguardConfig(ring) if err != nil { return err } } return nil } // SyncAllCeph updates the ceph.conf file func (m *Cluster) SyncAllCeph() error { cfg, err := m.GenCephConfig() if err != nil { return err } return m.WriteCephConfig(cfg) }