-
Notifications
You must be signed in to change notification settings - Fork 56
PE-38801 Task added to fetch rules for PE Infrastructure Agent group and warn user that they will be replaced #510
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a06d27e
PE-38801 Task added to fetch rules for PE Infrastructure Agent group …
AaronShannon b4574c7
PE-38801 Linting errors fixed
AaronShannon e83c741
PE-38801 Warning text moved to applicable plans
AaronShannon 962c7b3
PE-38801 Fixed formatting of rules in warning message
AaronShannon feca2fd
PE-38801 Specs updated
AaronShannon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "description": "Run on a PE primary node to return the rules currently applied to the PE Infrastructure Agent group, along with a warning that they will be overwritten", | ||
| "parameters": { }, | ||
| "input_method": "stdin" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/opt/puppetlabs/puppet/bin/ruby | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'json' | ||
| require 'net/http' | ||
| require 'puppet' | ||
|
|
||
| # GetInfrastructureAgentGroupRules task class | ||
| class GetInfrastructureAgentGroupRules | ||
| def execute! | ||
| infrastructure_agent_group = groups.find { |obj| obj['name'] == 'PE Infrastructure Agent' } | ||
| if infrastructure_agent_group | ||
| puts 'WARNING: The following existing rules on the PE Infrastructure Agent group will be overwritten with default values:' | ||
| puts JSON.pretty_generate(infrastructure_agent_group['rule']) | ||
| else | ||
| puts JSON.pretty_generate({ 'error' => 'PE Infrastructure Agent group does not exist' }) | ||
| end | ||
| end | ||
|
|
||
| def groups | ||
| net = https(4433) | ||
| res = net.get('/classifier-api/v1/groups') | ||
| JSON.parse(res.body) | ||
| end | ||
|
|
||
| def https(port) | ||
| https = Net::HTTP.new(Puppet.settings[:certname], port) | ||
| https.use_ssl = true | ||
| https.cert = OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert])) | ||
| https.key = OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey])) | ||
| https.verify_mode = OpenSSL::SSL::VERIFY_PEER | ||
| https.ca_file = Puppet.settings[:localcacert] | ||
| https | ||
| end | ||
| end | ||
|
|
||
| # Run the task unless an environment flag has been set, signaling not to. The | ||
| # environment flag is used to disable auto-execution and enable Ruby unit | ||
| # testing of this task. | ||
| unless ENV['RSPEC_UNIT_TEST_MODE'] | ||
| Puppet.initialize_settings | ||
| GetInfrastructureAgentGroupRules.new.execute! | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.