diff --git a/salt/modules/elasticsearch.py b/salt/modules/elasticsearch.py index ed681307365b..81c249fe6c72 100644 --- a/salt/modules/elasticsearch.py +++ b/salt/modules/elasticsearch.py @@ -101,6 +101,8 @@ def _get_instance(hosts=None, profile=None): use_ssl = _profile.get('use_ssl', False) ca_certs = _profile.get('ca_certs', False) verify_certs = _profile.get('verify_certs', False) + username = _profile.get('username', None) + password = _profile.get('password', None) if not hosts: hosts = ['127.0.0.1:9200'] @@ -114,6 +116,14 @@ def _get_instance(hosts=None, profile=None): ca_certs=ca_certs, verify_certs=verify_certs, ) + elif username and password: + es = elasticsearch.Elasticsearch( + hosts, + use_ssl=use_ssl, + ca_certs=ca_certs, + verify_certs=verify_certs, + http_auth=(username, password) + ) else: # Custom connection class to use requests module with proxies class ProxyConnection(RequestsHttpConnection):