diff --git a/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/IClusterComposeTask.cs b/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/IClusterComposeTask.cs index cf6942a61a..0a2e905dcd 100644 --- a/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/IClusterComposeTask.cs +++ b/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/IClusterComposeTask.cs @@ -189,12 +189,17 @@ private static void ExecuteBinaryInternal(EphemeralClusterConfiguration config, var command = $"{{{binary}}} {{{string.Join(" ", arguments)}}}"; writer?.WriteDiagnostic($"{{{nameof(ExecuteBinary)}}} starting process [{description}] {command}"); - var environment = environmentVariables != null - ? new Dictionary(environmentVariables) - : new Dictionary(); + var environment = new Dictionary + { + {config.FileSystem.ConfigEnvironmentVariableName, config.FileSystem.ConfigPath}, + {"OPENSEARCH_HOME", config.FileSystem.OpenSearchHome} + }; - environment.Add(config.FileSystem.ConfigEnvironmentVariableName, config.FileSystem.ConfigPath); - environment.Add("OPENSEARCH_HOME", config.FileSystem.OpenSearchHome); + if (environmentVariables != null) + { + foreach (var kvp in environmentVariables) + environment.Add(kvp.Key, kvp.Value); + } var timeout = TimeSpan.FromSeconds(420); var processStartArguments = new StartArguments(binary, arguments) diff --git a/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/InstallationTasks/InitialConfiguration.cs b/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/InstallationTasks/InitialConfiguration.cs index 64d83aca57..ef278dd649 100644 --- a/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/InstallationTasks/InitialConfiguration.cs +++ b/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/InstallationTasks/InitialConfiguration.cs @@ -30,6 +30,7 @@ using System.IO; using System.Linq; using OpenSearch.OpenSearch.Managed.ConsoleWriters; +using OpenSearch.Stack.ArtifactsApi.Products; using SemanticVersioning; namespace OpenSearch.OpenSearch.Ephemeral.Tasks.InstallationTasks @@ -42,17 +43,15 @@ public override void Run(IEphemeralCluster cluste var installConfigDir = Path.Combine(fs.OpenSearchHome, "config"); var installConfigFile = Path.Combine(installConfigDir, "opensearch.yml"); - var configFile = Path.Combine(fs.ConfigPath, "opensearch.yml"); - var configSecurity = Path.Combine(fs.ConfigPath, "opensearch-security"); + var pluginSecurity = Path.Combine(fs.OpenSearchHome, "plugins/opensearch-security"); - var isNewDemoScript = cluster.ClusterConfiguration.Version.BaseVersion() >= new Version(2, 12, 0); - - var installSecurityConfig = Path.Combine(installConfigDir, "opensearch-security"); + if (!Directory.Exists(pluginSecurity)) + return; - if (isNewDemoScript && Directory.Exists(configSecurity)) Directory.Move(configSecurity, installSecurityConfig); + var isNewDemoScript = cluster.ClusterConfiguration.Version.BaseVersion() >= new Version(2, 12, 0); - const string securityInstallDemoConfigSubPath = "plugins/opensearch-security/tools/install_demo_configuration.sh"; - var securityInstallDemoConfig = Path.Combine(fs.OpenSearchHome, securityInstallDemoConfigSubPath); + const string securityInstallDemoConfigSubPath = "tools/install_demo_configuration.sh"; + var securityInstallDemoConfig = Path.Combine(pluginSecurity, securityInstallDemoConfigSubPath); cluster.Writer?.WriteDiagnostic($"{{{nameof(InitialConfiguration)}}} going to run [{securityInstallDemoConfigSubPath}]"); @@ -78,20 +77,7 @@ public override void Run(IEphemeralCluster cluste args.ToArray()); } - Directory.CreateDirectory(fs.ConfigPath); - - if (isNewDemoScript) - { - Directory.CreateDirectory(configSecurity); - CopyFolder(installSecurityConfig, configSecurity); - } - - foreach (var f in new[]{"opensearch.yml", "esnode.pem", "esnode-key.pem", "root-ca.pem"}) - File.Copy(Path.Combine(installConfigDir, f), Path.Combine(fs.ConfigPath, f), true); - - if (cluster.ClusterConfiguration.EnableSsl) return; - - File.AppendAllText(configFile, "plugins.security.disabled: true"); + File.AppendAllText(installConfigFile, $"\n\nplugins.security.disabled: {!cluster.ClusterConfiguration.EnableSsl}"); } } } diff --git a/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/InstallationTasks/InstallPlugins.cs b/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/InstallationTasks/InstallPlugins.cs index c64501038e..afcb93db1c 100644 --- a/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/InstallationTasks/InstallPlugins.cs +++ b/abstractions/src/OpenSearch.OpenSearch.Ephemeral/Tasks/InstallationTasks/InstallPlugins.cs @@ -27,6 +27,7 @@ */ using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; @@ -93,12 +94,21 @@ public override void Run(IEphemeralCluster cluste cluster.Writer?.WriteDiagnostic( $"{{{nameof(InstallPlugins)}}} attempting install [{plugin.SubProductName}] as it's not OOTB: {{{plugin.ShippedByDefaultAsOf}}} and valid for {v}: {{{plugin.IsValid(v)}}}"); - if (!Directory.Exists(fs.ConfigPath)) Directory.CreateDirectory(fs.ConfigPath); + var homeConfigPath = Path.Combine(fs.OpenSearchHome, "config"); + + if (!Directory.Exists(homeConfigPath)) Directory.CreateDirectory(homeConfigPath); + + var env = new Dictionary + { + { fs.ConfigEnvironmentVariableName, homeConfigPath } + }; + ExecuteBinary( cluster.ClusterConfiguration, cluster.Writer, fs.PluginBinary, $"install opensearch plugin: {plugin.SubProductName}", + env, "install --batch", GetPluginLocation(plugin, v)); CopyConfigDirectoryToHomeCacheConfigDirectory(cluster, plugin);