Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # add-puppetclass.pl
- use Net::LDAP;
- use Net::LDAP::Util qw(ldap_error_text ldap_error_name);
- # put your ldap info here
- my $ldaphost = "";
- my $ldapuser = "";
- my $passwd = "";
- my $base = "";
- if ($#ARGV != 1) {
- print "Usage: $0 fqdn puppetclass\n";
- exit 1;
- }
- my $fqdn = $ARGV[0];
- my $class = $ARGV[1];
- $ldap = Net::LDAP->new ( "$ldaphost" ) or die "$@";
- $mesg = $ldap->bind ( "$ldapuser",
- password => "$passwd",
- version => 3 );
- if ($mesg->code) {
- die "An error occurred binding to the LDAP server: "
- .ldap_error_text($mesg->code)."\n";
- }
- $result = $ldap->modify("cn=$fqdn,$base",
- add => [ 'puppetclass' => $class
- ]
- );
- if ($result->code) {
- die "An error occurred adding the class $class to host $fqdn: "
- .ldap_error_text($result->code)."\n";
- }
- $ldap->unbind;
Add Comment
Please, Sign In to add comment