Skip to content

Commit e519fb8

Browse files
authored
st1105 addition (#80)
* st1105 added, master port check task * new lines added at end of files * rubocop changes * lines shortened manually for rubocop * perms update * ports array removed * pdk template update
1 parent 9e65ed6 commit e519fb8

File tree

9 files changed

+98
-15
lines changed

9 files changed

+98
-15
lines changed

.rubocop.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ GetText/DecorateString:
2727
Description: We don't want to decorate test output.
2828
Exclude:
2929
- spec/**/*
30+
Enabled: false
3031
RSpec/BeforeAfterAll:
3132
Description: Beware of using after(:all) as it may cause state to leak between tests.
3233
A necessary evil in acceptance testing.
@@ -88,6 +89,12 @@ Style/MethodCalledOnDoEndBlock:
8889
Enabled: true
8990
Style/StringMethods:
9091
Enabled: true
92+
GetText/DecorateFunctionMessage:
93+
Enabled: false
94+
GetText/DecorateStringFormattingUsingInterpolation:
95+
Enabled: false
96+
GetText/DecorateStringFormattingUsingPercent:
97+
Enabled: false
9198
Layout/EndOfLine:
9299
Enabled: false
93100
Layout/IndentHeredoc:

.travis.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
---
2+
os: linux
23
dist: xenial
34
language: ruby
45
cache: bundler
56
before_install:
67
- bundle -v
78
- rm -f Gemfile.lock
8-
- yes | gem update --system $RUBYGEMS_VERSION
9+
- "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner"
10+
- "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used"
11+
- "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set"
12+
- '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION'
913
- gem --version
1014
- bundle -v
1115
script:
1216
- 'bundle exec rake $CHECK'
1317
bundler_args: --without system_tests
1418
rvm:
15-
- 2.5.3
19+
- 2.5.7
1620
env:
1721
global:
1822
- SHELLCHECK_OPTS="-e SC1117"
@@ -23,15 +27,16 @@ stages:
2327
-
2428
if: tag =~ ^v\d
2529
name: deploy
26-
matrix:
30+
jobs:
2731
fast_finish: true
2832
include:
2933
-
3034
env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint"
3135
stage: static
3236
-
33-
env: DEPLOY_TO_FORGE=yes
34-
stage: deploy
37+
env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec
38+
rvm: 2.5.7
39+
stage: spec
3540
-
3641
env: CHECK="shellcheck tasknames"
3742
stage: static
@@ -58,7 +63,7 @@ matrix:
5863
dist: trusty
5964
env: ["PLATFORMS=el_puppet5", "PROVISION_LIST=litmus_el", "PUPPET_VERSION=puppet5"]
6065
rvm: 2.5.1
61-
script: ["bundle exec rake \"litmus:provision_list[${PROVISION_LIST}]\"", "bundle exec rake \"litmus:install_agent[${PUPPET_VERSION}]\"", "bundle exec rake litmus:install_module", "bundle exec rake litmus:acceptance:parallel"]
66+
script: ["bundle exec rake \"litmus:provision_list[${PROVISION_LIST}]\"", "bundle exec rake \"litmus:install_agent[${PUPPET_VERSION}]\"", "bundle exec rake litmus:install_module", "travis_wait 45 bundle exec rake litmus:acceptance:parallel"]
6267
services: docker
6368
stage: acceptance
6469
sudo: required
@@ -67,10 +72,13 @@ matrix:
6772
dist: trusty
6873
env: ["PLATFORMS=el_puppet6", "PROVISION_LIST=litmus_el", "PUPPET_VERSION=puppet6"]
6974
rvm: 2.5.1
70-
script: ["bundle exec rake \"litmus:provision_list[${PROVISION_LIST}]\"", "bundle exec rake \"litmus:install_agent[${PUPPET_VERSION}]\"", "bundle exec rake litmus:install_module", "bundle exec rake litmus:acceptance:parallel"]
75+
script: ["bundle exec rake \"litmus:provision_list[${PROVISION_LIST}]\"", "bundle exec rake \"litmus:install_agent[${PUPPET_VERSION}]\"", "bundle exec rake litmus:install_module", "travis_wait 45 bundle exec rake litmus:acceptance:parallel"]
7176
services: docker
7277
stage: acceptance
7378
sudo: required
79+
-
80+
env: DEPLOY_TO_FORGE=yes
81+
stage: deploy
7482
branches:
7583
only:
7684
- master
@@ -80,7 +88,7 @@ notifications:
8088
email: false
8189
deploy:
8290
provider: puppetforge
83-
user: puppetlabs
91+
username: puppetlabs
8492
password:
8593
secure: "ChaeM/FvQKwbznBtKkxky2jFSmbWDhlnChRqnXK+tA6D2FjIbdnIlbP66R6pPiQ1vH8MRFnCnsuPvY7yRjMdVWWRkRS1jPBb2r2iNLCAcKVW7SOlT6HuzKjbVdOqgDRMEWFrQ5NFywN5YDN+H5UqS/WWPIGT8P+72w0ennOws1Ie4xcVt1foYymuaaxGC27KT0Wn2xplAX6/quTINtEXibEtIMuBq5Y1Uh5OJr7UFZ5SOzgoTV15xVMKqFNVG+FJ3mg2PEu8XRsFK6pho6+n3x7x30pVt1/JgLWF2wngtQ14QSL2d8XrHFT8w7uxrxWMMzFu4MRYNZh9Mvt8giHl4VxzX63YWWq5uKvut6Cw0xotwGesNjrubSnKoOLGCnKAB4FWs2xli1NIQHuPFRLiv/1E5obrls6Bea43s53gGjHdeHMbK6U7sHY15z77z+xjFJBdTdlMe2dDKg7s5awDkeas62OpclmnFBVqKQ5FEFlVaRrVzjpd1zp8V3CaSnztlLSLxvmix40avsZ8fALkwKy1c369nzlwFKLMeWL1lD2IHLClhibLlL/U+6dvCp8wqGArq/c82WYIK1k4L6iNVLHGzIdTvfuBatO0et5zG5yOpjC8EoaZ2y1K1IxVd0I/tQypV9URwCUfM1I+JMNdPW0aqUmTT7MNTGu52S4mHLg="
8694
on:

Gemfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ group :development do
2424
gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
2525
gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
2626
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
27-
gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
28-
gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
29-
gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw]
30-
gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw]
27+
gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby]
28+
gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby]
29+
gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw]
30+
gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw]
3131
end
3232
group :system_tests do
3333
gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby]

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any?
24
require 'puppetlabs_spec_helper/rake_tasks'
35
require 'puppet-syntax/tasks/puppet-syntax'

metadata.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"version_requirement": ">= 5.3.2 < 7.0.0"
9494
}
9595
],
96-
"pdk-version": "1.14.1",
97-
"template-url": "https://github.com/puppetlabs/pdk-templates#1.13.0",
98-
"template-ref": "1.13.0-0-g66e1443"
96+
"pdk-version": "1.17.0",
97+
"template-url": "https://github.com/puppetlabs/pdk-templates#1.17.0",
98+
"template-ref": "tags/1.17.0-0-gd3a4319"
9999
}

spec/default_facts.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
# Facts specified here will override the values provided by rspec-puppet-facts.
44
---
55
ipaddress: "172.16.254.254"
6+
ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA"
67
is_pe: false
78
macaddress: "AA:AA:AA:AA:AA:AA"

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'puppetlabs_spec_helper/module_spec_helper'
24
require 'rspec-puppet-facts'
35

tasks/st1105_master_port_check.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"puppet_task_version": 1,
3+
"description": "Task to test TCP port connectivity of the Puppet Master",
4+
"supports_noop": false
5+
}

tasks/st1105_master_port_check.rb

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/opt/puppetlabs/puppet/bin/ruby
2+
3+
# st1105_master_port_check
4+
# Checks the port requirements for a puppet master and prints a short description of the port and it's status.
5+
# PE only and this is to be run against the Puppet Master.
6+
7+
require 'socket'
8+
require 'json'
9+
10+
destination = Socket.gethostbyname(Socket.gethostname).first
11+
portdesc = {
12+
'8140' => "The master uses this port to accept inbound traffic/requests from agents.
13+
The console sends requests to the master on this port. Certificate requests are passed over this port unless ca_port is set differently.
14+
Puppet Server status checks are sent over this port.",
15+
'443' => 'This port provides host access to the console. The console accepts HTTPS traffic from end users on this port.',
16+
'4433' => 'This port is used as a classifier/console services API endpoint. The master communicates with the console over this port.',
17+
'8081' => 'PuppetDB accepts traffic/requests on this port. The master and console send traffic to PuppetDB on this port. PuppetDB status checks are sent over this port.',
18+
'8142' => 'Orchestrator and the Run Puppet button use this port on the master of masters to accept inbound traffic/responses from agents via the Puppet Execution Protocol agent.',
19+
'8143' => 'Orchestrator uses this port to accept connections from Puppet Communications Protocol brokers to relay communications.
20+
The orchestrator client also uses this port to communicate with the orchestration services running on the master of masters.
21+
If you install the client on a workstation, this port must be available on the workstation.',
22+
'5432' => 'This port is used in a High Availability configuration to replicate data between the master and replica.',
23+
'8170' => 'Code Manager uses this port to deploy environments, run webhooks, and make API calls.',
24+
}
25+
26+
def port_test(dest, port)
27+
begin
28+
Socket.tcp(dest, port, connect_timeout: 5)
29+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ETIMEDOUT
30+
return false
31+
end
32+
true
33+
end
34+
35+
results_json = []
36+
37+
portdesc.keys.each do |port_no|
38+
# If port is open
39+
result = if port_test(destination, port_no)
40+
{
41+
'destination' => destination.to_s,
42+
'port' => port_no,
43+
'result' => 'pass',
44+
'description' => portdesc[port_no],
45+
}
46+
# If port is closed
47+
else
48+
{
49+
'destination' => destination.to_s,
50+
'port' => port_no,
51+
'result' => 'fail',
52+
'description' => portdesc[port_no],
53+
}
54+
end
55+
results_json << result
56+
end
57+
58+
puts JSON.pretty_generate(results_json)

0 commit comments

Comments
 (0)