Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 4e0dfac

Browse files
Add support to configure which systemd unit services or targets to use
* Remove left-over `migrate_monitors` * Add support to configure which systemd unit services or targets to use Fixes: #95 Signed-off-by: Tobias Wolf <[email protected]>
1 parent 7c82cef commit 4e0dfac

File tree

12 files changed

+83
-23
lines changed

12 files changed

+83
-23
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,20 @@ OSD devices: Not analyzed yet
103103

104104
#### Troubleshooting
105105

106-
**ssh-issues:**
107-
- make sure the id-rsa keys are "clean" and do not contain unexpected strings like "\<\<EOF". E.g. call `ssh-keygen -p -N "" -f ssh.key` to convert and reformat the keyfile to the expected format.
108-
- allow direnv (`direnv allow`) to use `.envrc` or copy and execute the command from the file: this switches off the ssh-agent, which sometimes has too many keys loaded
106+
**missing Ceph systemd targets:**
107+
- please consult your distribution's documentation in case documented Ceph systemd unit services or targets are missing
108+
- `cephadm install ceph-common ceph-base ceph-mon ceph-mgr ceph-mds radosgw` may help if supported
109109

110110
**frozen state:**
111111
- if the rookify process freezes, check your connections. In the OSISM testbed especially check the vpn-connection (in testbed repository try `make vpn-*`)
112112

113+
**ssh-issues:**
114+
- make sure the id-rsa keys are "clean" and do not contain unexpected strings like "\<\<EOF". E.g. call `ssh-keygen -p -N "" -f ssh.key` to convert and reformat the keyfile to the expected format.
115+
- allow direnv (`direnv allow`) to use `.envrc` or copy and execute the command from the file: this switches off the ssh-agent, which sometimes has too many keys loaded
116+
113117
## Support
114118

115119
For issues, questions, or contributions, please open an issue or pull request in the GitHub repository. We welcome community feedback and contributions to enhance rookify.
116120

117-
118121
## License
119122
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

config.example.osism.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ rook:
4242

4343
migration_modules:
4444
- example
45-
- create_rook_cluster
4645
- migrate_osds
4746
- migrate_osd_pools
4847
- migrate_mds

config.example.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ logging:
1010
ceph:
1111
config: ./.ceph/ceph.conf
1212
keyring: ./.ceph/ceph.client.admin.keyring
13+
systemd_file_name_templates:
14+
mds: "ceph-{fsid}@mds.{host}.service"
15+
mgr: "ceph-{fsid}@mgr.{host}.service"
16+
mon: "ceph-{fsid}@mon.{host}.service"
17+
osd: "ceph-{fsid}@osd.{osd_id}.service"
18+
rgw: "ceph-{fsid}@rgw.{host}.service"
1319

1420
# fill in correct path to private key
1521
ssh:

src/rookify/config.schema.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ logging:
1010
ceph:
1111
config: str()
1212
keyring: str()
13+
systemd_file_name_templates: include("systemd_file_name_templates", required=False)
1314

1415
ssh:
1516
private_key: str()
@@ -39,3 +40,10 @@ migration_modules: list(str())
3940
ssh_host:
4041
address: ip()
4142
user: str()
43+
---
44+
systemd_file_name_templates:
45+
mds: str(required=False)
46+
mgr: str(required=False)
47+
mon: str(required=False)
48+
osd: str(required=False)
49+
rgw: str(required=False)

src/rookify/modules/ceph.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ def __init__(self, config: Dict[str, Any]):
1616
except rados.ObjectNotFound as err:
1717
raise ModuleException(f"Could not connect to ceph: {err}")
1818

19+
status_data = self.mon_command("status")
20+
21+
self._fsid = status_data["fsid"]
22+
self._systemd_file_name_templates = config.get(
23+
"systemd_file_name_templates", {}
24+
)
25+
1926
def __getattr__(self, name: str) -> Any:
2027
return getattr(self.__ceph, name)
2128

@@ -32,6 +39,42 @@ def _json_command(self, handler: Any, *args: Any) -> Any:
3239

3340
return data
3441

42+
def get_systemd_mds_file_name(self, host: str) -> str:
43+
return self._get_systemd_template_file_name(
44+
self._systemd_file_name_templates.get("mds", "ceph-mds.target"),
45+
host,
46+
)
47+
48+
def get_systemd_mgr_file_name(self, host: str) -> str:
49+
return self._get_systemd_template_file_name(
50+
self._systemd_file_name_templates.get("mgr", "ceph-mgr.target"),
51+
host,
52+
)
53+
54+
def get_systemd_mon_file_name(self, host: str) -> str:
55+
return self._get_systemd_template_file_name(
56+
self._systemd_file_name_templates.get("mon", "ceph-mon.target"),
57+
host,
58+
)
59+
60+
def get_systemd_osd_file_name(self, host: str, osd_id: int) -> str:
61+
file_name_template: str = self._systemd_file_name_templates.get(
62+
"osd", "ceph-osd@{0:d}.service".format(osd_id)
63+
)
64+
65+
return file_name_template.format(fsid=self._fsid, host=host, osd_id=osd_id)
66+
67+
def get_systemd_rgw_file_name(self, host: str) -> str:
68+
return self._get_systemd_template_file_name(
69+
self._systemd_file_name_templates.get("mon", "ceph-radosgw.target"),
70+
host,
71+
)
72+
73+
def _get_systemd_template_file_name(
74+
self, file_name_template: str, host: str
75+
) -> str:
76+
return file_name_template.format(fsid=self._fsid, host=host)
77+
3578
def get_osd_pool_configurations_from_map(
3679
self, dump_data: Dict[str, Any]
3780
) -> Dict[str, Any]:

src/rookify/modules/migrate_mds/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ def execute(self) -> None:
8383

8484
def _disable_mds(self, mds_host: str) -> None:
8585
result = self.ssh.command(
86-
mds_host, "sudo systemctl disable --now ceph-mds.target"
86+
mds_host,
87+
"sudo systemctl disable --now {0}".format(
88+
self.ceph.get_systemd_mds_file_name(mds_host)
89+
),
8790
)
8891

8992
if result.failed:

src/rookify/modules/migrate_mgrs/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ def _migrate_mgr(self, mgr_host: str) -> None:
4444
self.logger.info("Migrating ceph-mgr daemon at host'{0}'".format(mgr_host))
4545

4646
result = self.ssh.command(
47-
mgr_host, "sudo systemctl disable --now ceph-mgr.target"
47+
mgr_host,
48+
"sudo systemctl disable --now {0}".format(
49+
self.ceph.get_systemd_mgr_file_name(mgr_host)
50+
),
4851
)
4952

5053
if result.failed:

src/rookify/modules/migrate_monitors/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/rookify/modules/migrate_monitors/main.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/rookify/modules/migrate_mons/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def _migrate_mon(self, mon: Dict[str, Any]) -> None:
5151
self.logger.info("Migrating ceph-mon daemon '{0}'".format(mon["name"]))
5252

5353
result = self.ssh.command(
54-
mon["name"], "sudo systemctl disable --now ceph-mon.target"
54+
mon["name"],
55+
"sudo systemctl disable --now {0}".format(
56+
self.ceph.get_systemd_mon_file_name(mon["name"])
57+
),
5558
)
5659

5760
if result.failed:

0 commit comments

Comments
 (0)