Realm Join Integration


This has been implemented and merged into Foreman 1.5 via #1809. The API's discussed on this page are outdated, see the Smart Proxy API Documentation


This page covers ideas for joining hosts to FreeIPA realms or Active Directory domains when they're built, using a hypothetical foreman_realm plugin.

DNS management

Related, but not actually realm joining. Updates to DNS can be made via the normal smart proxy route, however for both FreeIPA and AD we require GSS-TSIG support for nsupdate. This was completed for Foreman 1.2 via #1685.

Realm configuration

foreman_realm should add a realm model and associate them with domains, plus everything needed to manage them.

  • model: ForemanRealm::Realm
    • associated with domain (one realm to many domains?)
    • attribute: realm name
    • attribute: proxy id
  • controller and views: ForemanRealm::Realms
    • index, update, edit, delete realms
  • API controller: ForemanRealm::Api::V2::Realms
    • index, update, delete realms

This would allow users to add/remove/edit realm information, have it associated with a remote smart proxy instance and associate with a domain (does this make sense?), which in turn is associated to a host.

A new orchestration hook (which runs when a host is created/destroyed) needs adding to call the proxy (via Foreman's proxy API) if the associated domain has a realm:

  • app/models/foreman_realm/orchestration/realm.rb
    • include this into Host::Managed
    • calls proxy API to add/remove host from realm
    • saves OTP into host.params (key/value attributes) for now, perhaps to a separate model later

The kickstart templates would need updating to check for @host.params["realm-otp"] or similar, then run the appropriate join command.

To support classes and hostgroups in IPA (see below), additional attributes could be added to Foreman's host groups (or whatever they get replaced with) to define the IPA classes that the host would have when created.

Guy Matz has implemented the orchestration and proxy API bit of this OK: I'm not sure about the controllers and associating realms directly to hosts - needs some thought, perhaps associating with a domain isn't correct either.

Host/computer creation

Proxy support

The proxy should provide an API for creating hosts in realms (or computer objects in AD domains). As an example:

  • POST /realm/:domain/:hostname
    • param: classes, array of clases to apply to host
  • DELETE /realm/:domain/:hostname


It should advertise the "Realm" API feature. Foreman core's proxy API and smart proxy model will need updating to understand this new feature.

Guy Matz has implemented much of this already, complete with vendor/provider support so IPA and other implementations can be swapped:


For FreeIPA, this can either call the ipa host-add command or the XMLRPC API that backs it. Here's an example of creating a user with minimal privileges that can create new hosts:

# kinit admin
# ipa user-add --first=Host --last=Adder hadder

# ipa privilege-add "Add computers" --desc"Add computers" 
# ipa privilege-add-permission "Add computers" --permissions="add hosts" 

# ipa role-add "Host Adder" --desc="Can add new hosts" 
# ipa role-add-privilege "Computer creator" --privilege="Add computers" 
# ipa role-add-member "Computer creator" --user=hadder

# ipa-getkeytab -s `hostname` -p hadder@IDM.LAB.BOS.REDHAT.COM -k /root/hadder.keytab
# kinit -kt /root/hadder.keytab hadder@IDM.LAB.BOS.REDHAT.COM
# klist
Ticket cache: DIR::/run/user/0/krb5cc/tkt3GbmCZ
Default principal: hadder@IDM.LAB.BOS.REDHAT.COM    <<<<<

Valid starting       Expires              Service principal
06/14/2013 21:54:06  06/15/2013 21:54:06

System user is now privileged to add hosts to IPA:

# ipa host-add --random --force
Added host "" 
  Host name:
  Random password: K8-5rr0U8vL,
  Password: True
  Keytab: False
  Managed by:

He is unable to perform other administrative tasks as expected:

# ipa host-mod --desc=foo
ipa: ERROR: Insufficient access: Insufficient 'write' privilege to the
'description' attribute of entry

As a later step, classes can be assigned to hosts in IPA that associate it with hostgroups (not to be confused with Foreman host groups).

The attribute is called "userClass" in IPA LDAP, it is available by default with host entries under "--class" option. This is how it works:

1. We create a hostgroups to demonstrate how the automatic assignment of hosts to host groups works

# ipa hostgroup-add webservers
Description: web servers
Added hostgroup "webservers" 
  Host-group: webservers
  Description: web servers

2. Create an automember rule for this hostgroup

# ipa automember-add --type=hostgroup webservers
Added automember rule "webservers" 
  Automember Rule: webservers

3. The automember condition is hooked to the host's userclass attribute

# ipa automember-add-condition --key=userclass --type=hostgroup
--inclusive-regex=^webserver webservers
Added condition(s) to "webservers" 
  Automember Rule: webservers
  Inclusive Regex: userclass=^webserver
Number of conditions added 1

Steps 1, 2 and 3 need to be done just once when the IPA is being configured.

4. Now this is the best part. When Foreman proxy adds a host, it can specify
the host class which will automatically triggers

# ipa host-add --force --class=webserver --class=mailserver
Added host "" 
  Host name:
  Principal name: host/
  Class: webserver, mailserver                    <<<<<<<<<<
  Password: False
  Member of host-groups: webservers               <<<<<<<<<<
  Indirect Member of netgroup: webservers
  Keytab: False
  Managed by:

You can have more these rules in parallel.

Active Directory

For AD, adcli can be used (available in F18+):

Foreman support

foreman_realm should add an orchestration step to create and destroy the host object via the proxy. The OTP used when creating should be stored.

Joining hosts

foreman_realm could add a new %post snippet which uses the "realm" command (part of realmd) to join the host to the specified realm. For new anacondas, we could use this instead (maybe a second snippet): For older (EL5/6/F18), it should also support the ipa* client tools as realm is only just getting FreeIPA support:

Example: ipa-client-install --password K8-5rr0U8vL,