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

Add agent name to the deployment command #4739

Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to the Wazuh app project will be documented in this file.

- Added the option to sort by the agents count in the group table. [#4323](https://github.com/wazuh/wazuh-kibana-app/pull/4323)
- Added agent synchronization status in the agent module. [#3874](https://github.com/wazuh/wazuh-kibana-app/pull/3874)
- The input name was added and when the user adds a value the variable WAZUH_AGENT_NAME with its value appears in the installation command. [#4739](https://github.com/wazuh/wazuh-kibana-app/pull/4739)

### Changed

Expand Down
94 changes: 68 additions & 26 deletions public/controllers/agent/components/register-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const RegisterAgent = withErrorBoundary(
version: '',
wazuhVersion: '',
serverAddress: '',
agentName: '',
wazuhPassword: '',
groups: [],
selectedGroup: [],
Expand Down Expand Up @@ -218,6 +219,10 @@ export const RegisterAgent = withErrorBoundary(
this.setState({ serverAddress: event.target.value });
}

setAgentName(event) {
this.setState({ agentName: event.target.value });
}

setGroupName(selectedGroup) {
this.setState({ selectedGroup });
}
Expand Down Expand Up @@ -262,7 +267,7 @@ export const RegisterAgent = withErrorBoundary(
optionalDeploymentVariables() {
let deployment = `WAZUH_MANAGER='${this.state.serverAddress}' `;
const protocol = false

Machi3mfl marked this conversation as resolved.
Show resolved Hide resolved
if (this.state.selectedOS == 'win') {
deployment += `WAZUH_REGISTRATION_SERVER='${this.state.serverAddress}' `;
}
Expand All @@ -289,6 +294,16 @@ export const RegisterAgent = withErrorBoundary(
return deployment;
}

agentNameVariable() {
let agentName = `WAZUH_AGENT_NAME='${this.state.agentName}' `;
Machi3mfl marked this conversation as resolved.
Show resolved Hide resolved

if(this.state.selectedArchitecture && this.state.agentName !== '') {
return agentName
Machi3mfl marked this conversation as resolved.
Show resolved Hide resolved
} else {
return ''
}
}

resolveRPMPackage() {
switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) {
case 'redhat5-i386':
Expand Down Expand Up @@ -716,21 +731,29 @@ export const RegisterAgent = withErrorBoundary(
</EuiText>
);

const agentName = (
<EuiFieldText
placeholder="Name agent"
value={this.state.agentName}
onChange={(event) => this.setAgentName(event)}
// readOnly={!this.state.groups.length ? true : false}
Machi3mfl marked this conversation as resolved.
Show resolved Hide resolved
/>
);
const groupInput = (
<>
{!this.state.groups.length && (
<>
<EuiCallOut
<EuiCallOut style={{marginTop: '1.5rem'}}
color="warning"
title='This section could not be configured because you do not have permission to read groups.'
iconType="iInCircle"
/>
<EuiSpacer />
{/* <EuiSpacer /> */}
</>
)}
<EuiText>
<p>Select one or more existing groups</p>
<EuiComboBox
{/* <EuiText>
Machi3mfl marked this conversation as resolved.
Show resolved Hide resolved
<p>Select one or more existing groups</p> */}
{/* <EuiComboBox
placeholder={!this.state.groups.length ? "Default" : "Select group"}
options={this.state.groups}
selectedOptions={this.state.selectedGroup}
Expand All @@ -740,11 +763,30 @@ export const RegisterAgent = withErrorBoundary(
isDisabled={!this.state.groups.length}
isClearable={true}
data-test-subj="demoComboBox"
/>
</EuiText>
/> */}
{/* </EuiText> */}
</>
);



const agentGroup = (
<EuiText style={{marginTop: '1.5rem'}}>
<p>Select one or more existing groups</p>
<EuiComboBox
placeholder={!this.state.groups.length ? "Default" : "Select group"}
options={this.state.groups}
selectedOptions={this.state.selectedGroup}
onChange={(group) => {
this.setGroupName(group);
}}
isDisabled={!this.state.groups.length}
isClearable={true}
data-test-subj="demoComboBox"
/>
</EuiText>
)
console.log(this.state.groups.length, 'gr')
Machi3mfl marked this conversation as resolved.
Show resolved Hide resolved
const passwordInput = (
<EuiFieldText
placeholder="Wazuh password"
Expand All @@ -757,31 +799,31 @@ export const RegisterAgent = withErrorBoundary(
zIndex: '100',
};
const customTexts = {
Machi3mfl marked this conversation as resolved.
Show resolved Hide resolved
rpmText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
centText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
rpmText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
centText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
debText: `curl -so wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb`,
ubuText: `curl -so wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb`,
macosText: `curl -so wazuh-agent-${this.state.wazuhVersion
}.pkg https://packages.wazuh.com/4.x/macos/wazuh-agent-${this.state.wazuhVersion
}-1.pkg && sudo launchctl setenv ${this.optionalDeploymentVariables()} && sudo installer -pkg ./wazuh-agent-${this.state.wazuhVersion
}-1.pkg && sudo launchctl setenv ${this.optionalDeploymentVariables()}${this.agentNameVariable()}&& sudo installer -pkg ./wazuh-agent-${this.state.wazuhVersion
}.pkg -target /`,
winText: `Invoke-WebRequest -Uri https://packages.wazuh.com/4.x/windows/wazuh-agent-${this.state.wazuhVersion
}-1.msi -OutFile \${env:tmp}\\wazuh-agent-${this.state.wazuhVersion}.msi; msiexec.exe /i \${env:tmp}\\wazuh-agent-${this.state.wazuhVersion
}.msi /q ${this.optionalDeploymentVariables()}`,
openText: `sudo rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH && sudo ${this.optionalDeploymentVariables()} zypper install -y ${this.optionalPackages()}`,
solText: `sudo curl -so ${this.optionalPackages()} && ${this.state.selectedVersion == 'solaris11' ? 'pkg install -g wazuh-agent.p5p wazuh-agent' : 'pkgadd -d wazuh-agent.pkg'}`,
aixText: `sudo ${this.optionalDeploymentVariables()} rpm -ivh ${this.optionalPackages()}`,
hpText: `cd / && sudo curl -so ${this.optionalPackages()} && sudo groupadd wazuh && sudo useradd -G wazuh wazuh && sudo tar -xvf wazuh-agent.tar`,
amazonlinuxText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
fedoraText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
oraclelinuxText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
suseText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
}.msi /q ${this.optionalDeploymentVariables()}${this.agentNameVariable()}`,
openText: `sudo rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()} zypper install -y ${this.optionalPackages()}`,
solText: `sudo curl -so ${this.optionalPackages()} && sudo ${this.agentNameVariable()}&& ${this.state.selectedVersion == 'solaris11' ? 'pkg install -g wazuh-agent.p5p wazuh-agent' : 'pkgadd -d wazuh-agent.pkg'}`,
aixText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}rpm -ivh ${this.optionalPackages()}`,
hpText: `cd / && sudo curl -so ${this.optionalPackages()} && sudo ${this.agentNameVariable()}groupadd wazuh && sudo useradd -G wazuh wazuh && sudo tar -xvf wazuh-agent.tar`,
amazonlinuxText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
fedoraText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
oraclelinuxText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
suseText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
raspbianText: `curl -so wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb`,
};

Expand Down Expand Up @@ -1327,8 +1369,8 @@ export const RegisterAgent = withErrorBoundary(
]
: []),
{
title: 'Assign the agent to a group',
children: <Fragment>{groupInput}</Fragment>,
title: 'Assign a name and a group to the agent',
children: <Fragment>{agentName}{groupInput}{agentGroup}</Fragment>,
},
{
title: 'Install and enroll the agent',
Expand Down Expand Up @@ -1468,4 +1510,4 @@ export const RegisterAgent = withErrorBoundary(
);
}
}
);
);