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 the ability to configure a proxy #6

Merged
merged 1 commit into from Jun 3, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .devcontainer/Dockerfile
Expand Up @@ -3,4 +3,3 @@ FROM puppet/pdk:latest
# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

30 changes: 9 additions & 21 deletions .devcontainer/devcontainer.json
@@ -1,23 +1,11 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet
{
"name": "Puppet Development Kit (Community)",
"dockerFile": "Dockerfile",

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"puppet.puppet-vscode",
"rebornix.Ruby"
]

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pdk --version",
"name": "Puppet Development Kit (Community)",
"dockerFile": "Dockerfile",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"puppet.puppet-vscode",
"rebornix.Ruby"
]
}
2 changes: 2 additions & 0 deletions .fixtures.yml
Expand Up @@ -7,5 +7,7 @@ fixtures:
repo: 'puppet/logrotate'
stdlib:
repo: 'puppetlabs/stdlib'
augeas_core:
repo: 'puppetlabs/augeas_core'
symlinks:
qualys_agent: "#{source_dir}"
2 changes: 1 addition & 1 deletion .github_changelog_generator
@@ -1,4 +1,4 @@
pr-wo-labels=false
project=puppet-sentinelone_agent
unreleased=false
unreleased=true
user=broadinstitute
1 change: 1 addition & 0 deletions .pdkignore
Expand Up @@ -42,3 +42,4 @@
/spec/
/.vscode/
/.sync.yml
/.devcontainer/
2 changes: 2 additions & 0 deletions .sync.yml
@@ -1,6 +1,8 @@
---
appveyor.yml:
delete: true
.devcontainer/devcontainer.json:
unmanaged: true
.gitignore:
required:
- '/.librarian'
Expand Down
17 changes: 10 additions & 7 deletions CHANGELOG.md
@@ -1,21 +1,24 @@
# Change log
# Changelog

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
## [0.1.1](https://github.com/broadinstitute/puppet-sentinelone_agent/tree/0.1.1) (2021-04-02)

## [0.1.0](https://github.com/broadinstitute/puppet-sentinelone_agent/tree/0.1.0) (2021-04-02)

[Full Changelog](https://github.com/broadinstitute/puppet-sentinelone_agent/compare/0.1.0...0.1.0)
[Full Changelog](https://github.com/broadinstitute/puppet-sentinelone_agent/compare/0.1.0...0.1.1)

### Fixed
**Fixed bugs:**

- Fix service name bug [\#4](https://github.com/broadinstitute/puppet-sentinelone_agent/pull/4) ([coreone](https://github.com/coreone))

## [0.1.0](https://github.com/broadinstitute/puppet-sentinelone_agent/tree/0.1.0) (2021-04-02)

[Full Changelog](https://github.com/broadinstitute/puppet-sentinelone_agent/compare/7e0f427cd6f07e71541a6771b26a36b53ca37598...0.1.0)

### Added
**Implemented enhancements:**

- Initial release [\#1](https://github.com/broadinstitute/puppet-sentinelone_agent/pull/1) ([coreone](https://github.com/coreone))

**Merged pull requests:**

- Add badge for Actions [\#3](https://github.com/broadinstitute/puppet-sentinelone_agent/pull/3) ([coreone](https://github.com/coreone))
- Update CHANGELOG for release [\#2](https://github.com/broadinstitute/puppet-sentinelone_agent/pull/2) ([coreone](https://github.com/coreone))

\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
10 changes: 0 additions & 10 deletions Gemfile
Expand Up @@ -45,16 +45,6 @@ gems['puppet'] = location_for(puppet_version)
gems['facter'] = location_for(facter_version) if facter_version
gems['hiera'] = location_for(hiera_version) if hiera_version

if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)}
# If we're using a Puppet gem on Windows which handles its own win32-xxx gem
# dependencies (>= 3.5.0), set the maximum versions (see PUP-6445).
gems['win32-dir'] = ['<= 0.4.9', require: false]
gems['win32-eventlog'] = ['<= 0.6.5', require: false]
gems['win32-process'] = ['<= 0.7.5', require: false]
gems['win32-security'] = ['<= 0.2.5', require: false]
gems['win32-service'] = ['0.8.8', require: false]
end

gems.each do |gem_name, gem_params|
gem gem_name, *gem_params
end
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Expand Up @@ -89,4 +89,3 @@ Gemfile:
EOM
end
end

1 change: 1 addition & 0 deletions data/common.yaml
Expand Up @@ -5,6 +5,7 @@ sentinelone_agent::manage_package: true
sentinelone_agent::manage_service: true
sentinelone_agent::package_ensure: 'installed'
sentinelone_agent::package_name: 'SentinelAgent'
sentinelone_agent::proxy_url: ~
sentinelone_agent::service_enable: true
sentinelone_agent::service_ensure: 'running'
sentinelone_agent::service_name: 'sentinelone'
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Expand Up @@ -24,6 +24,9 @@
# @param package_name
# The name of the SentinelOne agent package (default: 'SentinelAgent').
#
# @param proxy_url
# The URL to use as an HTTP proxy
#
# @param service_enable
# Decide whether to enable the service (default: true).
#
Expand All @@ -43,6 +46,7 @@
Boolean $manage_service,
Variant[Enum['absent', 'installed', 'latest'], Pattern[/^(\d+\.){3}\d+$/]] $package_ensure,
String $package_name,
Optional[String] $proxy_url,
Boolean $service_enable,
Enum['running', 'stopped'] $service_ensure,
String $service_name,
Expand Down
12 changes: 12 additions & 0 deletions manifests/service.pp
Expand Up @@ -31,6 +31,18 @@
user => 'root',
}

if $sentinelone_agent::proxy_url {
# Use Augeas to get around password prompts on proxy URL change
augeas { 'sentinelone_agent_proxy':
changes => "set dict/entry[.= 'mgmt_proxy_url']/string '${sentinelone_agent::proxy_url}'",
context => '/files/opt/sentinelone/configuration/basic.conf',
incl => '/opt/sentinelone/configuration/basic.conf',
lens => 'Json.lns',
onlyif => "get dict/entry[.= 'mgmt_proxy_url']/string != '${sentinelone_agent::proxy_url}'",
notify => Service['sentinelone_agent_service'],
}
}

if $sentinelone_agent::manage_logrotate {
logrotate::rule { 'sentinelone_agent':
ensure => $sentinelone_agent::logrotate_ensure,
Expand Down
10 changes: 7 additions & 3 deletions metadata.json
@@ -1,13 +1,17 @@
{
"name": "broadinstitute-sentinelone_agent",
"version": "0.1.1",
"version": "0.1.2",
"author": "broadinstitute",
"summary": "Puppet module to manage the SentinelOne agent",
"license": "BSD-3-Clause",
"source": "https://github.com/broadinstitute/puppet-sentinelone_agent",
"project_page": "https://github.com/broadinstitute/puppet-sentinelone_agent",
"issues_url": "https://github.com/broadinstitute/puppet-sentinelone_agent/issues",
"dependencies": [
{
"name": "puppetlabs-augeas_core",
"version_requirement": "< 2.0.0"
},
{
"name": "puppetlabs-stdlib",
"version_requirement": ">= 1.0.0 < 7.0.0"
Expand Down Expand Up @@ -62,6 +66,6 @@
}
],
"pdk-version": "2.0.0",
"template-url": "https://github.com/puppetlabs/pdk-templates#2.0.0",
"template-ref": "2.0.0-0-ge838f1d"
"template-url": "https://github.com/puppetlabs/pdk-templates#2.1.0",
"template-ref": "tags/2.1.0-0-ga675ea5"
}
24 changes: 24 additions & 0 deletions spec/classes/init_spec.rb
Expand Up @@ -42,6 +42,9 @@
require: 'Package[sentinelone_agent_package]',
)
end
it do
is_expected.not_to contain_exec('sentinelone_agent_proxy')
end
it do
is_expected.to contain_exec('sentinelone_agent_token').with(
command: '/usr/bin/sentinelctl management token set eyJ1cmwiOiAiaHR0cDovL2V4YW1wbGUub3JnIiwgInNpdGVfa2V5IjogImFiYzEyMyJ9',
Expand Down Expand Up @@ -248,6 +251,27 @@
end
end

context 'with proxy_url set to http://example.com:9999' do
let(:params) do
{ proxy_url: 'http://example.com:9999' }
end

it do
is_expected.to compile.with_all_deps
end

it do
is_expected.to contain_augeas('sentinelone_agent_proxy').with(
changes: "set dict/entry[.= 'mgmt_proxy_url']/string 'http://example.com:9999'",
context: '/files/opt/sentinelone/configuration/basic.conf',
incl: '/opt/sentinelone/configuration/basic.conf',
lens: 'Json.lns',
onlyif: "get dict/entry[.= 'mgmt_proxy_url']/string != 'http://example.com:9999'",
notify: 'Service[sentinelone_agent_service]',
)
end
end

context 'with token set to new value' do
let(:params) do
{ token: 'eyJ1cmwiOiAiaHR0cDovL25ldy5leGFtcGxlLm9yZyIsICJzaXRlX2tleSI6ICJ4eXozMjEifQ==' }
Expand Down