Skip to content

Commit

Permalink
Merge pull request #227 from sabaini/make-cephconf-wrld-read
Browse files Browse the repository at this point in the history
Make ceph.conf world-readable
  • Loading branch information
sabaini authored Oct 2, 2023
2 parents e327ed3 + 1dc487b commit e5c33c3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions microceph/ceph/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func Bootstrap(s common.StateInterface) error {
"monitors": s.ClusterState().Address().Hostname(),
"addr": s.ClusterState().Address().Hostname(),
},
0644,
)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions microceph/ceph/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ func updateConfig(s common.StateInterface) error {
"ipv4": strings.Contains(address, "."),
"ipv6": strings.Contains(address, ":"),
},
0644,
)
if err != nil {
return fmt.Errorf("Couldn't render ceph.conf: %w", err)
Expand All @@ -228,6 +229,7 @@ func updateConfig(s common.StateInterface) error {
"name": "client.admin",
"key": config["keyring.client.admin"],
},
0640,
)
if err != nil {
return fmt.Errorf("Couldn't render ceph.client.admin.keyring: %w", err)
Expand Down
5 changes: 2 additions & 3 deletions microceph/ceph/configwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ func (c *Config) GetPath() string {
return filepath.Join(c.configDir, c.configFile)
}

// WriteConfig writes the configuration file given a data bag
func (c *Config) WriteConfig(data map[string]any) error {
mode := int(0640) // rw: user, r: group, others: none.
// WriteConfig writes the configuration file given a data bag and a filemode
func (c *Config) WriteConfig(data map[string]any, mode int) error {
fd, err := os.OpenFile(c.GetPath(), os.O_CREATE|os.O_TRUNC|os.O_RDWR, os.FileMode(mode))
if err != nil {
return fmt.Errorf("Couldn't write %s: %w", c.configFile, err)
Expand Down
3 changes: 3 additions & 0 deletions microceph/ceph/configwriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (s *configWriterSuite) TestWriteCephConfig() {
"monitors": "foohost",
"addr": "foohost",
},
0644,
)
assert.Equal(s.T(), nil, err)
// Check that the file exists
Expand All @@ -49,6 +50,7 @@ func (s *configWriterSuite) TestWriteRadosGWConfig() {
map[string]any{
"monitors": "foohost",
},
0644,
)
assert.Equal(s.T(), nil, err)
// Check that the file exists
Expand All @@ -68,6 +70,7 @@ func (s *configWriterSuite) TestWriteCephKeyring() {
"name": "client.admin",
"key": "secretkey",
},
0644,
)
assert.Equal(s.T(), nil, err)
// Check that the file exists and has the right contents
Expand Down
1 change: 1 addition & 0 deletions microceph/ceph/rgw.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func EnableRGW(s common.StateInterface, port int) error {
"monitors": s.ClusterState().Address().Hostname(),
"rgwPort": port,
},
0644,
)
if err != nil {
return err
Expand Down

0 comments on commit e5c33c3

Please sign in to comment.