|
18 | 18 | "SambaTopologyController", |
19 | 19 | "IPATrustADTopologyController", |
20 | 20 | "IPATrustSambaTopologyController", |
| 21 | + "IPATrustIPATopologyController", |
21 | 22 | ] |
22 | 23 |
|
23 | 24 |
|
@@ -174,3 +175,68 @@ class IPATrustSambaTopologyController(IPATrustADTopologyController): |
174 | 175 | """ |
175 | 176 |
|
176 | 177 | pass |
| 178 | + |
| 179 | + |
| 180 | +class IPATrustIPATopologyController(ProvisionedBackupTopologyController): |
| 181 | + """ |
| 182 | + IPA trust IPA Topology Controller. |
| 183 | + """ |
| 184 | + |
| 185 | + @BackupTopologyController.restore_vanilla_on_error |
| 186 | + def topology_setup(self, client: ClientHost, ipa: IPAHost, trusted: IPAHost) -> None: |
| 187 | + if self.provisioned: |
| 188 | + self.logger.info(f"Topology '{self.name}' is already provisioned") |
| 189 | + return |
| 190 | + |
| 191 | + # Add ipa-ipa trust COPR and update packages |
| 192 | + self.logger.info("Adding COPR and updating packages") |
| 193 | + ipa.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"]) |
| 194 | + client.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"]) |
| 195 | + trusted.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"]) |
| 196 | + |
| 197 | + ipa.conn.exec(["dnf", "update", "freeipa-server", "sssd-client", "-y"]) |
| 198 | + trusted.conn.exec(["dnf", "update", "freeipa-server", "sssd-client", "-y"]) |
| 199 | + client.conn.exec(["dnf", "update", "sssd-client", "-y"]) |
| 200 | + |
| 201 | + # F40 sssd-kcm fails to start with 'Invalid option --genconf-section=kcm:' |
| 202 | + ipa.conn.exec(["systemctl", "restart", "sssd-kcm"]) |
| 203 | + trusted.conn.exec(["systemctl", "restart", "sssd-kcm"]) |
| 204 | + |
| 205 | + # Create trust |
| 206 | + self.logger.info(f"Establishing trust between {ipa.domain} and {trusted.domain}") |
| 207 | + |
| 208 | + ipa.kinit() |
| 209 | + ipa.conn.exec( |
| 210 | + [ |
| 211 | + "ipa", |
| 212 | + "trust-add", |
| 213 | + trusted.domain, |
| 214 | + "--admin", |
| 215 | + "admin", |
| 216 | + "--password", |
| 217 | + "--range-type=ipa-ad-trust-posix", |
| 218 | + "--type=ipa", |
| 219 | + "--two-way=true", |
| 220 | + ], |
| 221 | + input=trusted.adminpw, |
| 222 | + ) |
| 223 | + |
| 224 | + # Do not enroll client into IPA domain if it is already joined |
| 225 | + if "ipa" not in self.multihost.provisioned_topologies: |
| 226 | + self.logger.info(f"Enrolling {client.hostname} into {ipa.domain}") |
| 227 | + |
| 228 | + # Remove any existing Kerberos configuration and keytab |
| 229 | + client.fs.rm("/etc/krb5.conf") |
| 230 | + client.fs.rm("/etc/krb5.keytab") |
| 231 | + |
| 232 | + # Backup ipa-client-install files |
| 233 | + client.fs.backup("/etc/ipa") |
| 234 | + client.fs.backup("/var/lib/ipa-client") |
| 235 | + |
| 236 | + # Join IPA domain) |
| 237 | + client.conn.exec(["realm", "join", ipa.domain], input=ipa.adminpw) |
| 238 | + |
| 239 | + # Backup so we can restore to this state after each test |
| 240 | + self.backup_data[ipa] = ipa.backup() |
| 241 | + self.backup_data[trusted] = trusted.backup() |
| 242 | + self.backup_data[client] = client.backup() |
0 commit comments