Use external utility for agents deployment
This commit is contained in:
parent
210ef60b69
commit
3776f10bc7
|
@ -1,5 +1,6 @@
|
|||
START TRANSACTION;
|
||||
|
||||
-- Add new columns in tdeployment_hosts
|
||||
ALTER TABLE `tdeployment_hosts` ADD COLUMN `deploy_method` ENUM('SSH', 'HTTP', 'HTTPS') DEFAULT 'SSH';
|
||||
ALTER TABLE `tdeployment_hosts` ADD COLUMN `deploy_port` INT UNSIGNED NOT NULL DEFAULT 22;
|
||||
ALTER TABLE `tdeployment_hosts` ADD COLUMN `server_port` INT UNSIGNED NOT NULL DEFAULT 41121;
|
||||
|
@ -14,6 +15,23 @@ SET
|
|||
WHERE
|
||||
`tdeployment_hosts`.`id_os` = `tconfig_os`.`id_os` AND `tconfig_os`.`name` = 'Windows' AND `tdeployment_hosts`.`deployed` = 0;
|
||||
|
||||
-- Find the name of the foreign key constraint
|
||||
SELECT @constraint_name := `constraint_name`
|
||||
FROM `information_schema`.`key_column_usage`
|
||||
WHERE `table_name` = 'tdeployment_hosts' AND `column_name` = 'id_os';
|
||||
|
||||
-- Drop the foreign key constraint using dynamic SQL
|
||||
SET @drop_fk_query = CONCAT('ALTER TABLE `tdeployment_hosts` DROP FOREIGN KEY ', @constraint_name);
|
||||
PREPARE stmt FROM @drop_fk_query;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- Drop unused columns in tdeployment_hosts
|
||||
ALTER TABLE `tdeployment_hosts` DROP COLUMN `id_os`;
|
||||
ALTER TABLE `tdeployment_hosts` DROP COLUMN `os_version`;
|
||||
ALTER TABLE `tdeployment_hosts` DROP COLUMN `arch`;
|
||||
|
||||
-- Update all deployment recon tasks port
|
||||
UPDATE `trecon_task` SET `field4` = 41121 WHERE `type` = 9;
|
||||
|
||||
COMMIT;
|
|
@ -3940,9 +3940,6 @@ CREATE TABLE IF NOT EXISTS `tdeployment_hosts` (
|
|||
`id` SERIAL,
|
||||
`id_cs` VARCHAR(100),
|
||||
`ip` VARCHAR(100) NOT NULL UNIQUE,
|
||||
`id_os` INT UNSIGNED DEFAULT 0,
|
||||
`os_version` VARCHAR(100) DEFAULT '' COMMENT 'OS version in STR format',
|
||||
`arch` ENUM('x64', 'x86') DEFAULT 'x64',
|
||||
`current_agent_version` VARCHAR(100) DEFAULT '' COMMENT 'String latest installed agent',
|
||||
`target_agent_version_id` BIGINT UNSIGNED,
|
||||
`deployed` BIGINT NOT NULL DEFAULT 0 COMMENT 'When it was deployed',
|
||||
|
@ -3955,8 +3952,6 @@ CREATE TABLE IF NOT EXISTS `tdeployment_hosts` (
|
|||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store`(`identifier`)
|
||||
ON UPDATE CASCADE ON DELETE SET NULL,
|
||||
FOREIGN KEY (`id_os`) REFERENCES `tconfig_os`(`id_os`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`target_agent_version_id`) REFERENCES `tagent_repository`(`id`)
|
||||
ON UPDATE CASCADE ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
|
|
@ -556,6 +556,8 @@ sub pandora_load_config {
|
|||
$pa_config->{'ncmserver_threads'} = 1; # 7.0.758
|
||||
$pa_config->{'ncm_ssh_utility'} = '/usr/share/pandora_server/util/ncm_ssh_extension'; # 7.0.758
|
||||
|
||||
$pa_config->{'agent_deployer_utility'} = '/usr/share/pandora_server/util/pandora_agent_deployer'; # 7.0.777
|
||||
|
||||
$pa_config->{"pandora_service_cmd"} = 'service pandora_server'; # 7.0.761
|
||||
$pa_config->{"tentacle_service_cmd"} = 'service tentacle_serverd'; # 7.0.761
|
||||
$pa_config->{"tentacle_service_watchdog"} = 1; # 7.0.761
|
||||
|
@ -1336,6 +1338,9 @@ sub pandora_load_config {
|
|||
elsif ($parametro =~ m/^ncm_ssh_utility\s+(.*)/i) {
|
||||
$pa_config->{'ncm_ssh_utility'}= clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^agent_deployer_utility\s+(.*)/i) {
|
||||
$pa_config->{'agent_deployer_utility'}= clean_blank($1);
|
||||
}
|
||||
|
||||
# Pandora HA extra
|
||||
elsif ($parametro =~ m/^ha_mode\s(.*)/i) {
|
||||
|
|
|
@ -148,21 +148,23 @@ sub data_producer ($) {
|
|||
WHERE id_recon_server = ?
|
||||
AND disabled = 0
|
||||
AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1)
|
||||
OR (status < 0 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id);
|
||||
OR (status < 0 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))
|
||||
OR (status < 0 AND utimestamp = 0 AND interval_sweep = 0)', $server_id);
|
||||
} else {
|
||||
@rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
|
||||
WHERE (id_recon_server = ? OR id_recon_server NOT IN (SELECT id_server FROM tserver WHERE status = 1 AND server_type = ?))
|
||||
AND disabled = 0
|
||||
AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1)
|
||||
OR (status < 0 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id, DISCOVERYSERVER);
|
||||
OR (status < 0 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))
|
||||
OR (status < 0 AND utimestamp = 0 AND interval_sweep = 0)', $server_id, DISCOVERYSERVER);
|
||||
}
|
||||
|
||||
foreach my $row (@rows) {
|
||||
|
||||
# Discovery apps must be fully set up.
|
||||
# Discovery apps must be fully set up.
|
||||
if ($row->{'type'} == DISCOVERY_APP && $row->{'setup_complete'} != 1) {
|
||||
logger($pa_config, 'Setup for recon app task ' . $row->{'id_app'} . ' not complete.', 10);
|
||||
next;
|
||||
next;
|
||||
}
|
||||
|
||||
# Update task status
|
||||
|
|
Loading…
Reference in New Issue