@@ -26,6 +26,7 @@ const url = require('url');
2626const { log : defaultLog , decompress } = require ( '../utils' ) ;
2727const { BASE_PATH , ES_CONFIG , ES_KEYSTORE_BIN } = require ( '../paths' ) ;
2828const { Artifact } = require ( '../artifact' ) ;
29+ const { parseSettings, SettingsFilter } = require ( '../settings' ) ;
2930
3031/**
3132 * Extracts an ES archive and optionally installs plugins
@@ -45,6 +46,7 @@ exports.installArchive = async function installArchive(archive, options = {}) {
4546 installPath = path . resolve ( basePath , path . basename ( archive , '.tar.gz' ) ) ,
4647 log = defaultLog ,
4748 bundledJDK = false ,
49+ esArgs = [ ] ,
4850 } = options ;
4951
5052 let dest = archive ;
@@ -69,7 +71,10 @@ exports.installArchive = async function installArchive(archive, options = {}) {
6971 await appendToConfig ( installPath , 'xpack.security.enabled' , 'true' ) ;
7072
7173 await appendToConfig ( installPath , 'xpack.license.self_generated.type' , license ) ;
72- await configureKeystore ( installPath , password , log , bundledJDK ) ;
74+ await configureKeystore ( installPath , log , bundledJDK , [
75+ [ 'bootstrap.password' , password ] ,
76+ ...parseSettings ( esArgs , { filter : SettingsFilter . SecureOnly } ) ,
77+ ] ) ;
7378 }
7479
7580 return { installPath } ;
@@ -90,21 +95,33 @@ async function appendToConfig(installPath, key, value) {
9095 * Creates and configures Keystore
9196 *
9297 * @param {String } installPath
93- * @param {String } password
9498 * @param {ToolingLog } log
99+ * @param {boolean } bundledJDK
100+ * @param {Array<[string, string]> } secureSettings List of custom Elasticsearch secure settings to
101+ * add into the keystore.
95102 */
96- async function configureKeystore ( installPath , password , log = defaultLog , bundledJDK = false ) {
97- log . info ( 'setting bootstrap password to %s' , chalk . bold ( password ) ) ;
98-
103+ async function configureKeystore (
104+ installPath ,
105+ log = defaultLog ,
106+ bundledJDK = false ,
107+ secureSettings
108+ ) {
99109 const env = { } ;
100110 if ( bundledJDK ) {
101111 env . JAVA_HOME = '' ;
102112 }
103113 await execa ( ES_KEYSTORE_BIN , [ 'create' ] , { cwd : installPath , env } ) ;
104114
105- await execa ( ES_KEYSTORE_BIN , [ 'add' , 'bootstrap.password' , '-x' ] , {
106- input : password ,
107- cwd : installPath ,
108- env,
109- } ) ;
115+ for ( const [ secureSettingName , secureSettingValue ] of secureSettings ) {
116+ log . info (
117+ `setting secure setting %s to %s` ,
118+ chalk . bold ( secureSettingName ) ,
119+ chalk . bold ( secureSettingValue )
120+ ) ;
121+ await execa ( ES_KEYSTORE_BIN , [ 'add' , secureSettingName , '-x' ] , {
122+ input : secureSettingValue ,
123+ cwd : installPath ,
124+ env,
125+ } ) ;
126+ }
110127}
0 commit comments