Skip to content

Instantly share code, notes, and snippets.

@satishchennu1
Created May 22, 2020 22:29
Show Gist options
  • Save satishchennu1/9bc906ef35684ac13c42f033881cbf6c to your computer and use it in GitHub Desktop.
Save satishchennu1/9bc906ef35684ac13c42f033881cbf6c to your computer and use it in GitHub Desktop.
htpasswd_ansible
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