|
18 | 18 | "SambaTopologyController", |
19 | 19 | "IPATrustADTopologyController", |
20 | 20 | "IPATrustSambaTopologyController", |
| 21 | + "IPATrustIPATopologyController", |
21 | 22 | "KeycloakTopologyController", |
22 | 23 | ] |
23 | 24 |
|
@@ -217,3 +218,72 @@ def topology_setup(self, client: ClientHost, keycloak: KeycloakHost) -> None: |
217 | 218 |
|
218 | 219 | # Backup so we can restore to this state after each test |
219 | 220 | super().topology_setup() |
| 221 | + |
| 222 | + |
| 223 | +class IPATrustIPATopologyController(ProvisionedBackupTopologyController): |
| 224 | + """ |
| 225 | + IPA trust IPA Topology Controller. |
| 226 | + """ |
| 227 | + |
| 228 | + @BackupTopologyController.restore_vanilla_on_error |
| 229 | + def topology_setup(self, client: ClientHost, ipa: IPAHost, trusted: IPAHost) -> None: |
| 230 | + if self.provisioned: |
| 231 | + self.logger.info(f"Topology '{self.name}' is already provisioned") |
| 232 | + return |
| 233 | + |
| 234 | + # Add ipa-ipa trust COPR and update packages |
| 235 | + self.logger.info("Adding COPR and updating packages") |
| 236 | + ipa.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"]) |
| 237 | + client.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"]) |
| 238 | + trusted.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"]) |
| 239 | + |
| 240 | + ipa.conn.exec(["dnf", "update", "freeipa-server", "sssd-client", "-y"]) |
| 241 | + trusted.conn.exec(["dnf", "update", "freeipa-server", "sssd-client", "-y"]) |
| 242 | + client.conn.exec(["dnf", "update", "sssd-client", "-y"]) |
| 243 | + |
| 244 | + # F40 sssd-kcm fails to start with 'Invalid option --genconf-section=kcm:' |
| 245 | + ipa.conn.exec(["systemctl", "restart", "sssd-kcm"]) |
| 246 | + trusted.conn.exec(["systemctl", "restart", "sssd-kcm"]) |
| 247 | + |
| 248 | + # IPA server and the remote domain cannot share the same NetBIOS name: MASTER |
| 249 | + trusted.kinit() |
| 250 | + trusted.conn.exec(["ipa-adtrust-install", "--netbios-name", "MASTER2", "-U"]) |
| 251 | + |
| 252 | + # Create trust |
| 253 | + self.logger.info(f"Establishing trust between {ipa.domain} and {trusted.domain}") |
| 254 | + |
| 255 | + ipa.kinit() |
| 256 | + ipa.conn.exec( |
| 257 | + [ |
| 258 | + "ipa", |
| 259 | + "trust-add", |
| 260 | + trusted.domain, |
| 261 | + "--admin", |
| 262 | + "admin", |
| 263 | + "--password", |
| 264 | + "--range-type=ipa-ad-trust-posix", |
| 265 | + "--type=ipa", |
| 266 | + "--two-way=true", |
| 267 | + ], |
| 268 | + input=trusted.adminpw, |
| 269 | + ) |
| 270 | + |
| 271 | + # Do not enroll client into IPA domain if it is already joined |
| 272 | + if "ipa" not in self.multihost.provisioned_topologies: |
| 273 | + self.logger.info(f"Enrolling {client.hostname} into {ipa.domain}") |
| 274 | + |
| 275 | + # Remove any existing Kerberos configuration and keytab |
| 276 | + client.fs.rm("/etc/krb5.conf") |
| 277 | + client.fs.rm("/etc/krb5.keytab") |
| 278 | + |
| 279 | + # Backup ipa-client-install files |
| 280 | + client.fs.backup("/etc/ipa") |
| 281 | + client.fs.backup("/var/lib/ipa-client") |
| 282 | + |
| 283 | + # Join IPA domain) |
| 284 | + client.conn.exec(["realm", "join", ipa.domain], input=ipa.adminpw) |
| 285 | + |
| 286 | + # Backup so we can restore to this state after each test |
| 287 | + self.backup_data[ipa] = ipa.backup() |
| 288 | + self.backup_data[trusted] = trusted.backup() |
| 289 | + self.backup_data[client] = client.backup() |
0 commit comments