Skip to content

Commit

Permalink
modify script blksmanager for to add functionality of modify base of …
Browse files Browse the repository at this point in the history
…sudoers and add user with privileges sudo
  • Loading branch information
juanjoselopezroldan committed Apr 3, 2020
1 parent 7a5d4cc commit 95f423d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion inventory/local/group_vars/all/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ldap_setup: true
kerberos_setup: true
sssd_setup: true

domain: "linux.example.local"
domain: "linux.gstwdt.local"

openldap_linux: '{{ domain.split(".")[0] | lower }}'
openldap_org: '{{ domain.split(".")[1] | lower }}'
Expand Down
22 changes: 19 additions & 3 deletions roles/kerberos/files/blksmanager
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ done

function add_to_ldap ()
{
ldapadd -h $HOST_IP -D "cn=$ADMIN, $ldapDN" -w $ADMIN_PASS << EOF
dn: uid=$USERNAME,cn=sudobase,cn=Workers,ou=SUDOers,dc=$DC1,dc=$DC2,dc=$DC3
ldapadd -h $HOST_IP -D "cn=$ADMIN,$ldapDN" -w $ADMIN_PASS << EOF
dn: uid=$USERNAME,cn=sudobase,cn=Workers,ou=SUDOers,$ldapDN
objectClass: top
objectClass: posixAccount
objectClass: inetOrgPerson
Expand All @@ -84,6 +84,12 @@ gecos: $USERNAME
loginShell: /bin/bash
homeDirectory: /home/$USERNAME
EOF
ldapmodify -h $HOST_IP -D "cn=$ADMIN,$ldapDN" -w $ADMIN_PASS << EOF
dn: cn=sudobase,cn=Workers,ou=SUDOers,$ldapDN
changetype: modify
add: sudoUser
sudoUser: $USERNAME
EOF
}

function add_kerberos ()
Expand All @@ -99,7 +105,15 @@ kadmin.local -q "ktadd -norandkey -k $KEYTAB $USERNAME@$UPPER_DOMAIN"

function del_ldap_kerberos ()
{
ldapdelete -h $HOST_IP -x -D "cn=$ADMIN,dc=$DC1,dc=$DC2,dc=$DC3" "uid=$USERNAME,cn=sudobase,cn=Workers,ou=SUDOers,dc=$DC1,dc=$DC2,dc=$DC3" -w $ADMIN_PASS
ldapdelete -h $HOST_IP -x -D "cn=$ADMIN,$ldapDN" "uid=$USERNAME,cn=sudobase,cn=Workers,ou=SUDOers,$ldapDN" -w $ADMIN_PASS

ldapmodify -h $HOST_IP -D "cn=$ADMIN, $ldapDN" -w $ADMIN_PASS << EOF
dn: cn=sudobase,cn=Workers,ou=SUDOers,$ldapDN
changetype: modify
delete: sudoUser
sudoUser: $USERNAME
EOF

kadmin.local -q "delete_principal $USERNAME@$UPPER_DOMAIN"
kdestroy
}
Expand Down Expand Up @@ -168,6 +182,8 @@ then
DC2=$(echo "$DOMAIN" | cut -d"." -f2)
DC3=$(echo "$DOMAIN" | cut -d"." -f3)

ldapDN="dc=$DC1, dc=$DC2, dc=$DC3"

del_ldap_kerberos
fi
else
Expand Down

0 comments on commit 95f423d

Please sign in to comment.