Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove config.yml after deployment and rename to wazuh-config.yml #1679

Merged
merged 8 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ solaris/packer/sol-10-u11-ga-x86-dvd.iso
solaris/packer/sol-11_3-text-x86.iso
unattended_installer/certs*
unattended_installer/configurations*
unattended_installer/config.yml
unattended_installer/wazuh-config.yml
unattended_installer/.vscode
unattended_installer/wazuh-install-files*
unattended_installer/wazuh-install.sh
Expand Down
26 changes: 13 additions & 13 deletions tests/unattended/unit/suites/test-certFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ test-14-generateKibanacertificates-two-nodes-assert() {

function load-cert_readConfig() {
@load_function "${base_dir}/wazuh-cert-tool.sh" cert_readConfig
config_file="${base_path}/config.yml"
config_file="${base_path}/wazuh-config.yml"
}

test-ASSERT-FAIL-15-cert_readConfig-empty-file() {
Expand All @@ -256,7 +256,7 @@ test-ASSERT-FAIL-17-cert_readConfig-duplicated-elastic-node-names() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1 wazuh2"
Expand Down Expand Up @@ -303,7 +303,7 @@ test-ASSERT-FAIL-18-cert_readConfig-duplicated-elastic-node-ips() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1 wazuh2"
Expand Down Expand Up @@ -350,7 +350,7 @@ test-ASSERT-FAIL-19-cert_readConfig-duplicated-wazuh-node-names() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1 wazuh2"
Expand Down Expand Up @@ -396,7 +396,7 @@ test-ASSERT-FAIL-20-cert_readConfig-duplicated-wazuh-node-ips() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1 wazuh2"
Expand Down Expand Up @@ -443,7 +443,7 @@ test-ASSERT-FAIL-21-cert_readConfig-duplicated-kibana-node-names() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1 wazuh2"
Expand Down Expand Up @@ -490,7 +490,7 @@ test-ASSERT-FAIL-22-cert_readConfig-duplicated-kibana-node-ips() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1 wazuh2"
Expand Down Expand Up @@ -536,7 +536,7 @@ test-ASSERT-FAIL-23-cert_readConfig-different-number-of-wazuh-names-and-ips() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1"
Expand Down Expand Up @@ -582,7 +582,7 @@ test-ASSERT-FAIL-24-cert_readConfig-incorrect-wazuh-node-type() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1 wazuh2"
Expand Down Expand Up @@ -629,7 +629,7 @@ test-ASSERT-FAIL-25-cert_readConfig-wazuh-node-type-one-node() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1"
Expand Down Expand Up @@ -675,7 +675,7 @@ test-ASSERT-FAIL-26-cert_readConfig-less-wazuh-node-types-than-nodes() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1 wazuh2"
Expand Down Expand Up @@ -722,7 +722,7 @@ test-ASSERT-FAIL-27-cert_readConfig-different-number-of-kibana-names-and-ips() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1 wazuh2"
Expand Down Expand Up @@ -769,7 +769,7 @@ test-28-cert_readConfig-everything-correct() {
@touch "${config_file}"
@echo "config_file" > "${config_file}"

@mock cert_parseYaml /tmp/wazuh-cert-tool/config.yml === @out
@mock cert_parseYaml /tmp/wazuh-cert-tool/wazuh-config.yml === @out
@mock grep nodes_elasticsearch_name === @out "elastic1 elastic2"
@mock sed 's/nodes_elasticsearch_name=//'
@mock grep nodes_wazuh_servers_name === @out "wazuh1 wazuh2"
Expand Down
6 changes: 3 additions & 3 deletions tests/unattended/unit/suites/test-installCommon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test-03-installCommon_getConfig() {
@mocktrue echo certificate/config_aio.yml
@mock sed 's|/|_|g;s|.yml||' === @out "certificate_config_aio"
@mock echo === @echo "Hello World"
installCommon_getConfig certificate/config_aio.yml ./config.yml
installCommon_getConfig certificate/config_aio.yml ./wazuh-config.yml
}

test-03-installCommon_getConfig-assert() {
Expand All @@ -39,7 +39,7 @@ test-04-installCommon_getConfig-error() {
@mocktrue echo certificate/config_aio.yml
@mock sed 's|/|_|g;s|.yml||' === @out "certificate_config_aio"
@mock echo === @echo ""
installCommon_getConfig certificate/config_aio.yml ./config.yml
installCommon_getConfig certificate/config_aio.yml ./wazuh-config.yml
}

test-04-installCommon_getConfig-error-assert() {
Expand Down Expand Up @@ -908,7 +908,7 @@ test-45-installCommon_createCertificates-aio() {
}

test-45-installCommon_createCertificates-aio-assert() {
installCommon_getConfig certificate/config_aio.yml /tmp/config.yml
installCommon_getConfig certificate/config_aio.yml /tmp/wazuh-config.yml

cert_readConfig

Expand Down
1 change: 1 addition & 0 deletions unattended_installer/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function buildInstaller() {
configuration_files=($(find "${resources_config}" -type f))
config_file_name=($(eval "echo "${configuration_files[@]}" | sed 's|${resources_config}||g;s|/|_|g;s|.yml||g'"))
for index in "${!config_file_name[@]}"; do
config_file_name[$index]=$(echo "${config_file_name[$index]}" | sed 's|-|_|g')
echo "config_file${config_file_name[$index]}=\"$(cat "${configuration_files[$index]}" | sed 's|\"|\\\"|g;s|\$|\\\$|g')\"" >> "${output_script_path}"
echo >> "${output_script_path}"
done
Expand Down
4 changes: 2 additions & 2 deletions unattended_installer/cert_tool/certFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,6 @@ function cert_convertCRLFtoLF() {
mkdir "/tmp/wazuh-install-files"
fi
eval "chmod -R 755 /tmp/wazuh-install-files ${debug}"
eval "tr -d '\015' < $1 > /tmp/wazuh-install-files/new_config.yml"
eval "mv /tmp/wazuh-install-files/new_config.yml $1"
eval "tr -d '\015' < $1 > /tmp/wazuh-install-files/new-wazuh-config.yml"
eval "mv /tmp/wazuh-install-files/new-wazuh-config.yml $1"
}
2 changes: 1 addition & 1 deletion unattended_installer/cert_tool/certVariables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
# Foundation.

readonly base_path="$(dirname "$(readlink -f "$0")")"
readonly config_file="${base_path}/config.yml"
readonly config_file="${base_path}/wazuh-config.yml"
readonly logfile=""
debug=">> /dev/null 2>&1"
2 changes: 1 addition & 1 deletion unattended_installer/install_functions/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function checks_health() {

}

# This function ensures different names in the config.yml file.
# This function ensures different names in the wazuh-config.yml file.
function checks_names() {

if [ -n "${indxname}" ] && [ -n "${dashname}" ] && [ "${indxname}" == "${dashname}" ]; then
Expand Down
9 changes: 5 additions & 4 deletions unattended_installer/install_functions/installCommon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,11 @@ function installCommon_createInstallFiles() {
gen_file="/tmp/wazuh-install-files/wazuh-passwords.txt"
passwords_generatePasswordFile
# Using cat instead of simple cp because OpenSUSE unknown error.
eval "cat '${config_file}' > '/tmp/wazuh-install-files/config.yml'"
eval "cat '${config_file}' > '/tmp/wazuh-install-files/wazuh-config.yml'"
eval "chown root:root /tmp/wazuh-install-files/*"
eval "tar -zcf '${tar_file}' -C '/tmp/' wazuh-install-files/ ${debug}"
eval "rm -rf '/tmp/wazuh-install-files' ${debug}"
eval "rm -rf ${config_file} ${debug}"
common_logger "Created ${tar_file_name}. It contains the Wazuh cluster key, certificates, and passwords necessary for installation."
else
common_logger -e "Unable to create /tmp/wazuh-install-files"
Expand Down Expand Up @@ -234,11 +235,11 @@ function installCommon_changePasswords() {

function installCommon_extractConfig() {

if ! $(tar -tf "${tar_file}" | grep -q wazuh-install-files/config.yml); then
common_logger -e "There is no config.yml file in ${tar_file}."
if ! $(tar -tf "${tar_file}" | grep -q wazuh-install-files/wazuh-config.yml); then
common_logger -e "There is no wazuh-config.yml file in ${tar_file}."
exit 1
fi
eval "tar -xf ${tar_file} -C /tmp wazuh-install-files/config.yml ${debug}"
eval "tar -xf ${tar_file} -C /tmp wazuh-install-files/wazuh-config.yml ${debug}"

}

Expand Down
6 changes: 3 additions & 3 deletions unattended_installer/install_functions/installMain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function getHelp() {
echo -e " Install and configure Wazuh server, Wazuh indexer, Wazuh dashboard."
echo -e ""
echo -e " -c, --config-file <path-to-config-yml>"
echo -e " Path to the configuration file used to generate wazuh-install-files.tar file containing the files that will be needed for installation. By default, the Wazuh installation assistant will search for a file named config.yml in the same path as the script."
echo -e " Path to the configuration file used to generate wazuh-install-files.tar file containing the files that will be needed for installation. By default, the Wazuh installation assistant will search for a file named wazuh-config.yml in the same path as the script."
echo -e ""
echo -e " -dw, --download-wazuh <deb|rpm>"
echo -e " Download all the packages necessary for offline installation."
Expand All @@ -29,7 +29,7 @@ function getHelp() {
echo -e " Force Wazuh dashboard installation to continue even when it is not capable of connecting to the Wazuh indexer."
echo -e ""
echo -e " -g, --generate-config-files"
echo -e " Generate wazuh-install-files.tar file containing the files that will be needed for installation from config.yml. In distributed deployments you will need to copy this file to all hosts."
echo -e " Generate wazuh-install-files.tar file containing the files that will be needed for installation from wazuh-config.yml. In distributed deployments you will need to copy this file to all hosts."
echo -e ""
echo -e " -h, --help"
echo -e " Display this help and exit."
Expand Down Expand Up @@ -242,7 +242,7 @@ function main() {

if [ -z "${configurations}" ] && [ -z "${download}" ]; then
installCommon_extractConfig
config_file="/tmp/wazuh-install-files/config.yml"
config_file="/tmp/wazuh-install-files/wazuh-config.yml"
cert_readConfig
fi

Expand Down
2 changes: 1 addition & 1 deletion unattended_installer/install_functions/installVariables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ readonly wazuh_install_vesion="0.1"
readonly resources="https://${bucket}/${wazuh_major}"
readonly base_url="https://${bucket}/${repository}"
readonly base_path="$(dirname $(readlink -f "$0"))"
config_file="${base_path}/config.yml"
config_file="${base_path}/wazuh-config.yml"
readonly tar_file_name="wazuh-install-files.tar"
tar_file="${base_path}/${tar_file_name}"

Expand Down