-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a module that will configure nslcd in client machine.
- Loading branch information
1 parent
97a3994
commit 08cfe22
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""Configuring nslcd.""" | ||
|
||
from __future__ import annotations | ||
|
||
from pytest_mh import MultihostHost, MultihostUtility | ||
from pytest_mh.utils.fs import LinuxFileSystem | ||
from sssd_test_framework.roles.ldap import LDAP | ||
|
||
__all__ = [ | ||
"Nslcd", | ||
] | ||
|
||
|
||
class Nslcd(MultihostUtility[MultihostHost]): | ||
""" | ||
Use nslcd to configure sssd proxy. | ||
.. code-block:: python | ||
:caption: Example usage | ||
@pytest.mark.topology(KnownTopology.LDAP) | ||
def test_example(client: Client, ldap: LDAP): | ||
client.nslcd.confignslcd(ldap) | ||
.. note:: | ||
All changes are automatically reverted when a test is finished. | ||
""" | ||
|
||
def __init__(self, host: MultihostHost, fs: LinuxFileSystem) -> None: | ||
""" | ||
:param host: Remote host instance. | ||
:type host: MultihostHost | ||
:param fs: Linux file system | ||
:type fs: LinuxFileSystem | ||
""" | ||
super().__init__(host) | ||
self.fs: LinuxFileSystem = fs | ||
|
||
def confignslcd(self, ldap: LDAP) -> None: | ||
""" | ||
Configure nslcd. | ||
:param ldap: Ldap role. | ||
:type ldap: LDAP | ||
""" | ||
self.fs.write('/etc/pam.d/sssdproxyldap', ''' | ||
auth required pam_ldap.so | ||
account required pam_ldap.so | ||
password required pam_ldap.so | ||
session required pam_ldap.so | ||
''') | ||
self.fs.write('/etc/nslcd.conf', f'uid nslcd\ngid ldap\nuri ' | ||
f'ldap://{ldap.host.hostname}\nbase ' | ||
f'{ldap.ldap.naming_context}\n', dedent=False) | ||
self.host.ssh.run("systemctl restart nslcd") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters