Project

General

Profile

RealmJoinIntegration » History » Version 6

Dominic Cleal, 10/03/2013 09:50 AM

1 1 Dominic Cleal
h1. Realm Join Integration
2
3
*This is just sketching out some ideas, it doesn't exist, yet.*
4
5
This page covers ideas for joining hosts to FreeIPA realms or Active Directory domains when they're built, using a hypothetical foreman_realm plugin.
6
7
h2. DNS management
8
9 2 Dominic Cleal
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.
10 1 Dominic Cleal
11
h2. Realm configuration
12
13
foreman_realm should add a realm model and associate them with domains, plus everything needed to manage them.
14
15 4 Dominic Cleal
* model: ForemanRealm::Realm
16
** associated with domain (one realm to many domains?)
17
** attribute: realm name
18
** attribute: proxy id
19
* controller and views: ForemanRealm::Realms
20
** index, update, edit, delete realms
21
* API controller: ForemanRealm::Api::V2::Realms
22
** index, update, delete realms
23
24 6 Dominic Cleal
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.
25 1 Dominic Cleal
26 6 Dominic Cleal
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:
27
28 4 Dominic Cleal
* app/models/foreman_realm/orchestration/realm.rb
29 1 Dominic Cleal
** include this into Host::Managed
30 4 Dominic Cleal
** calls proxy API to add/remove host from realm
31 6 Dominic Cleal
** saves OTP into host.params (key/value attributes) for now, perhaps to a separate model later
32 4 Dominic Cleal
33
The "kickstart templates":https://github.com/theforeman/community-templates would need updating to check for @@host.params["realm-otp"]@ or similar, then run the appropriate join command.
34
35 3 Dominic Cleal
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.
36 1 Dominic Cleal
37 5 Dominic Cleal
Guy Matz has implemented the orchestration and proxy API bit of this OK: https://github.com/guymatz/foreman/compare/develop...1809-add_IPA_support.  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.
38
39 1 Dominic Cleal
h2. Host/computer creation
40
41
h3. Proxy support
42
43 4 Dominic Cleal
The proxy should provide an API for creating hosts in realms (or computer objects in AD domains).  As an example:
44 1 Dominic Cleal
45 4 Dominic Cleal
* POST @/realm/:domain/:hostname@
46
** param: classes, array of clases to apply to host
47
* DELETE @/realm/:domain/:hostname@
48
49
(http://projects.theforeman.org/projects/smart-proxy/wiki/API)
50
51
It should advertise the "Realm" API feature.  Foreman core's proxy API and smart proxy model will need updating to understand this new feature.
52
53
Guy Matz has implemented much of this already, complete with vendor/provider support so IPA and other implementations can be swapped: https://github.com/guymatz/smart-proxy/compare/develop...1809-add_IPA_support
54
55 3 Dominic Cleal
h4. FreeIPA
56 1 Dominic Cleal
57 3 Dominic Cleal
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:
58
59
<pre>
60
# kinit admin
61
# ipa user-add --first=Host --last=Adder hadder
62
63
# ipa privilege-add "Add computers" --desc"Add computers"
64
# ipa privilege-add-permission "Add computers" --permissions="add hosts"
65
66
# ipa role-add "Host Adder" --desc="Can add new hosts"
67
# ipa role-add-privilege "Computer creator" --privilege="Add computers"
68
# ipa role-add-member "Computer creator" --user=hadder
69
70
# ipa-getkeytab -s `hostname` -p hadder@IDM.LAB.BOS.REDHAT.COM -k /root/hadder.keytab
71
# kinit -kt /root/hadder.keytab hadder@IDM.LAB.BOS.REDHAT.COM
72
# klist
73
Ticket cache: DIR::/run/user/0/krb5cc/tkt3GbmCZ
74
Default principal: hadder@IDM.LAB.BOS.REDHAT.COM    <<<<<
75
76
Valid starting       Expires              Service principal
77
06/14/2013 21:54:06  06/15/2013 21:54:06
78
krbtgt/IDM.LAB.BOS.REDHAT.COM@IDM.LAB.BOS.REDHAT.COM
79
</pre>
80
81
System user is now privileged to add hosts to IPA:
82
83
<pre>
84
# ipa host-add random.host.test --random --force
85
-----------------------------
86
Added host "random.host.test"
87
-----------------------------
88
  Host name: random.host.test
89
  Random password: K8-5rr0U8vL,
90
  Password: True
91
  Keytab: False
92
  Managed by: random.host.test
93
</pre>
94
95
He is unable to perform other administrative tasks as expected:
96
97
<pre>
98
# ipa host-mod random.host.test --desc=foo
99
ipa: ERROR: Insufficient access: Insufficient 'write' privilege to the
100
'description' attribute of entry
101
'fqdn=random.host.test,cn=computers,cn=accounts,dc=idm,dc=lab,dc=bos,dc=redhat,dc=com'.
102
</pre>
103
104
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).
105
106
The attribute is called "userClass" in IPA LDAP, it is available by default with host entries under "--class" option. This is how it works:
107
108
1. We create a hostgroups to demonstrate how the automatic assignment of hosts to host groups works
109
110
<pre>
111
# ipa hostgroup-add webservers
112
Description: web servers
113
----------------------------
114
Added hostgroup "webservers"
115
----------------------------
116
  Host-group: webservers
117
  Description: web servers
118
</pre>
119
120
2. Create an automember rule for this hostgroup
121
122
<pre>
123
# ipa automember-add --type=hostgroup webservers
124
----------------------------------
125
Added automember rule "webservers"
126
----------------------------------
127
  Automember Rule: webservers
128
</pre>
129
130
3. The automember condition is hooked to the host's userclass attribute
131
132
<pre>
133
# ipa automember-add-condition --key=userclass --type=hostgroup
134
--inclusive-regex=^webserver webservers
135
----------------------------------
136
Added condition(s) to "webservers"
137
----------------------------------
138
  Automember Rule: webservers
139
  Inclusive Regex: userclass=^webserver
140
----------------------------
141
Number of conditions added 1
142
----------------------------
143
</pre>
144
145
Steps 1, 2 and 3 need to be done just once when the IPA is being configured.
146
147
4. Now this is the best part. When Foreman proxy adds a host, it can specify
148
the host class which will automatically triggers
149
150
<pre>
151
# ipa host-add web.example.com --force --class=webserver --class=mailserver
152
----------------------------
153
Added host "web.example.com"
154
----------------------------
155
  Host name: web.example.com
156
  Principal name: host/web.example.com@EXAMPLE.COM
157
  Class: webserver, mailserver                    <<<<<<<<<<
158
  Password: False
159
  Member of host-groups: webservers               <<<<<<<<<<
160
  Indirect Member of netgroup: webservers
161
  Keytab: False
162
  Managed by: web.example.com
163
</pre>
164
165
You can have more these rules in parallel.
166
167
h4. Active Directory
168 1 Dominic Cleal
169
For AD, adcli can be used (available in F18+):
170
* http://fedoraproject.org/wiki/Features/ActiveDirectory
171
* https://fedoraproject.org/wiki/Features/AnacondaRealmIntegration (has an adcli example)
172
173
h3. Foreman support
174
175
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.
176
177
h2. Joining hosts
178
179 4 Dominic Cleal
foreman_realm could add a new %post snippet which uses the "realm" command (part of realmd) to join the host to the specified realm.
180 1 Dominic Cleal
* http://www.freedesktop.org/software/realmd/docs/index.html (see joining sections)
181
182
For new anacondas, we could use this instead (maybe a second snippet):
183
* https://fedoraproject.org/wiki/Features/AnacondaRealmIntegration
184
185
For older (EL5/6/F18), it should also support the ipa* client tools as realm is only just getting FreeIPA support:
186
* http://fedoraproject.org/wiki/Features/RealmdFreeIpaSupport
187 3 Dominic Cleal
188
Example: @ipa-client-install --password K8-5rr0U8vL,@