Created
May 22, 2020 22:29
-
-
Save satishchennu1/9bc906ef35684ac13c42f033881cbf6c to your computer and use it in GitHub Desktop.
htpasswd_ansible
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
user=admin | |
password=admin | |
htpasswd=$(printf "$user:$(openssl passwd -apr1 $password)\n") | |
htpasswd=$(echo $htpasswd | base64) | |
oc apply -f - <<EOF | |
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: htpass-secret | |
namespace: openshift-config | |
data: | |
htpasswd: $htpasswd | |
EOF | |
# configure HTPasswd IDP | |
oc apply -f - <<EOF | |
apiVersion: config.openshift.io/v1 | |
kind: OAuth | |
metadata: | |
name: cluster | |
spec: | |
identityProviders: | |
- name: htpassidp | |
challenge: true | |
login: true | |
mappingMethod: claim | |
type: HTPasswd | |
htpasswd: | |
fileData: | |
name: htpass-secret | |
EOF | |
oc adm policy add-cluster-role-to-user cluster-admin admin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment