@ -123,6 +123,9 @@ AUTH_ARG_SPEC = {
' aliases ' : [ ' key_file ' ] ,
' aliases ' : [ ' key_file ' ] ,
} ,
} ,
' proxy ' : { } ,
' proxy ' : { } ,
' persist_config ' : {
' type ' : ' bool ' ,
} ,
}
}
# Map kubernetes-client parameters to ansible parameters
# Map kubernetes-client parameters to ansible parameters
@ -138,6 +141,7 @@ AUTH_ARG_MAP = {
' cert_file ' : ' client_cert ' ,
' cert_file ' : ' client_cert ' ,
' key_file ' : ' client_key ' ,
' key_file ' : ' client_key ' ,
' proxy ' : ' proxy ' ,
' proxy ' : ' proxy ' ,
' persist_config ' : ' persist_config ' ,
}
}
@ -179,13 +183,13 @@ class K8sAnsibleMixin(object):
# We have enough in the parameters to authenticate, no need to load incluster or kubeconfig
# We have enough in the parameters to authenticate, no need to load incluster or kubeconfig
pass
pass
elif auth_set ( ' kubeconfig ' ) or auth_set ( ' context ' ) :
elif auth_set ( ' kubeconfig ' ) or auth_set ( ' context ' ) :
kubernetes . config . load_kube_config ( auth . get ( ' kubeconfig ' ) , auth . get ( ' context ' ) )
kubernetes . config . load_kube_config ( auth . get ( ' kubeconfig ' ) , auth . get ( ' context ' ) , persist_config = auth . get ( ' persist_config ' ) )
else :
else :
# First try to do incluster config, then kubeconfig
# First try to do incluster config, then kubeconfig
try :
try :
kubernetes . config . load_incluster_config ( )
kubernetes . config . load_incluster_config ( )
except kubernetes . config . ConfigException :
except kubernetes . config . ConfigException :
kubernetes . config . load_kube_config ( auth . get ( ' kubeconfig ' ) , auth . get ( ' context ' ) )
kubernetes . config . load_kube_config ( auth . get ( ' kubeconfig ' ) , auth . get ( ' context ' ) , persist_config = auth . get ( ' persist_config ' ) )
# Override any values in the default configuration with Ansible parameters
# Override any values in the default configuration with Ansible parameters
configuration = kubernetes . client . Configuration ( )
configuration = kubernetes . client . Configuration ( )