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

[Cloud Security] [Agentless] Add the creation of an agentless agent via Agentless API in the GHA Create Environment (new) #2493

Merged
merged 25 commits into from
Nov 25, 2024

Conversation

seanrathier
Copy link
Contributor

@seanrathier seanrathier commented Sep 10, 2024

Summary of your changes

This change refactors the CreateEnvironment workflow to create an agentless-agent using the Agentless-API.

This should only be merged when production Serverless projects in the test region have the Agentless-API configuration in Kibana.

We enable this for ESS by simply setting the TEST_AGENTLESS to true.

Testing

To test this run the CreateEnvironment workflow with the following parameters

  • Workflow branch: 10463-create-agentless-agent
  • Stack version: 8.16.0-SNAPSHOT
  • Select Run UI sanity tests after provision checkbox
  • Kibana UI test branch: 10269-gha-sanity-tests-for-agentless-ess-deployments

(First time doing Python, be gentle 😄 )

Related Issues

Checklist

  • I have added tests that prove my fix is effective or that my feature works
    • not sure if this is needed for workflow changes

@seanrathier seanrathier added Team:Cloud Security Cloud Security team related automation labels Sep 10, 2024
@seanrathier seanrathier force-pushed the 10463-create-agentless-agent branch 2 times, most recently from cad275c to 3febb2e Compare September 11, 2024 20:35
@elastic elastic deleted a comment from mergify bot Sep 11, 2024
@elastic elastic deleted a comment from mergify bot Sep 11, 2024
@elastic elastic deleted a comment from mergify bot Sep 11, 2024
@seanrathier seanrathier marked this pull request as ready for review September 11, 2024 22:43
@seanrathier seanrathier requested a review from a team as a code owner September 11, 2024 22:43
Comment on lines +97 to +103
logger.info(f"Starting installation of agentless-agent {INTEGRATION_NAME} integration.")
agent_data, package_data = load_data(
cfg=cnfg.elk_config,
agent_input=AGENTLESS_INPUT,
package_input=integration_data,
stream_name="cloud_security_posture.findings",
)
package_policy["force"] = True

logger.info(f"Creating {package_policy}")
logger.info("Create agentless-agent policy")
agent_policy_id = create_agent_policy(cfg=cnfg.elk_config, json_policy=agent_data)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since creating an agentless-agent policy is a new feature, we need to handle both cases: when an agentless policy already exists and when it needs to be installed (as is the case for you now).
There are a couple of options for this:

  • We could rely on an environment variable to determine if the agentless-agent policy should be installed.
  • Alternatively, we could retrieve all installed agent policies from the Fleet and check if any are already agentless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I understand what you are saying, if I am not then please correct me.

By the time this PR gets merged, Serverless production we should not be using the older preconfigured Agentless policy solution so I don't think we need check for either solution.

When ESS production has the new Agentless API configuration we should only need to set TEST_AGENTLESS to true

@seanrathier seanrathier requested review from kubasobon, orestisfl, amirbenun and a team and removed request for kubasobon, orestisfl and amirbenun September 23, 2024 13:00
@@ -135,15 +135,15 @@ jobs:
TF_VAR_ess_region: ${{ inputs.ess-region }}
DEPLOYMENT_NAME: ${{ inputs.deployment_name }}
TF_VAR_serverless_mode: ${{ inputs.serverless_mode }}
TEST_AGENTLESS: ${{ inputs.serverless_mode }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be missing something, but this seems to be committed by mistake. We should keep it conditional based on the workflow input value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to deploy agentless for both ESS and Serverless now. I left the environment variable there in case we disable it a briefly (bugs, changes, etc).

@seanrathier seanrathier force-pushed the 10463-create-agentless-agent branch from de0969c to 993a139 Compare October 1, 2024 15:41
Copy link

mergify bot commented Nov 20, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b 10463-create-agentless-agent upstream/10463-create-agentless-agent
git merge upstream/main
git push upstream 10463-create-agentless-agent

@seanrathier seanrathier merged commit cd0feeb into main Nov 25, 2024
11 checks passed
@seanrathier seanrathier deleted the 10463-create-agentless-agent branch November 25, 2024 15:25
mergify bot pushed a commit that referenced this pull request Dec 10, 2024
…ia Agentless API in the GHA Create Environment (new) (#2493)

(cherry picked from commit cd0feeb)
oren-zohar pushed a commit that referenced this pull request Dec 10, 2024
…f an agentless agent via Agentless API in the GHA Create Environment (new) (#2827)

[Cloud Security] [Agentless] Add the creation of an agentless agent via Agentless API in the GHA Create Environment (new) (#2493)

(cherry picked from commit cd0feeb)

Co-authored-by: seanrathier <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants