puppetlabs-onceover 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.devcontainer/devcontainer.json +31 -0
- data/.gitattributes +2 -0
- data/.github/workflows/ci.yml +81 -0
- data/.github/workflows/mend.yml +14 -0
- data/.github/workflows/nightly.yml +66 -0
- data/.github/workflows/release.yaml +16 -0
- data/.github/workflows/release_prep.yml +20 -0
- data/.gitignore +19 -0
- data/.rubocop.yml +19 -0
- data/.rubocop_todo.yml +804 -0
- data/.vscode/extensions.json +4 -0
- data/ARCHIVE.md +395 -0
- data/CHANGELOG.md +25 -0
- data/CODEOWNERS +2 -0
- data/Gemfile +65 -0
- data/LICENSE +202 -0
- data/README.md +965 -0
- data/Rakefile +86 -0
- data/bin/puppetlabs-onceover +17 -0
- data/cucumber.yml +1 -0
- data/factsets/AIX-6.1-powerpc.json +210 -0
- data/factsets/AIX-7.1-powerpc.json +215 -0
- data/factsets/Amazon-2018.03.json +420 -0
- data/factsets/CentOS-5.11-32.json +263 -0
- data/factsets/CentOS-5.11-64.json +263 -0
- data/factsets/CentOS-6.6-32.json +306 -0
- data/factsets/CentOS-6.6-64.json +342 -0
- data/factsets/CentOS-7.0-64.json +352 -0
- data/factsets/CentOS-8.3.2011-64.json +485 -0
- data/factsets/Debian-10.4-64.json +476 -0
- data/factsets/Debian-6.0.10-32.json +322 -0
- data/factsets/Debian-6.0.10-64.json +322 -0
- data/factsets/Debian-7.8-32.json +338 -0
- data/factsets/Debian-7.8-64.json +338 -0
- data/factsets/Debian-8.11-64.json +480 -0
- data/factsets/Debian-9.12-64.json +476 -0
- data/factsets/RHEL-6.7.json +415 -0
- data/factsets/RHEL-7.4.json +489 -0
- data/factsets/SLES-11.3-64.json +317 -0
- data/factsets/SLES-12.1-64.json +353 -0
- data/factsets/Ubuntu-12.04-32.json +328 -0
- data/factsets/Ubuntu-12.04-64.json +328 -0
- data/factsets/Ubuntu-14.04-32.json +337 -0
- data/factsets/Ubuntu-14.04-64.json +373 -0
- data/factsets/Ubuntu-18.04-64.json +556 -0
- data/factsets/Ubuntu-20.04-64.json +504 -0
- data/factsets/Windows_Server-2008r2-64.json +184 -0
- data/factsets/Windows_Server-2012r2-64.json +165 -0
- data/factsets/solaris-10_u9-sparc-64.json +769 -0
- data/factsets/solaris-11.2-sparc-64.json +774 -0
- data/factsets/windows-10-64.json +104 -0
- data/features/auto_vendored.feature +27 -0
- data/features/cache.feature +38 -0
- data/features/factsets.feature +48 -0
- data/features/formatting.feature +36 -0
- data/features/help.feature +14 -0
- data/features/init.feature +18 -0
- data/features/show.feature +28 -0
- data/features/step_definitions/cache.rb +38 -0
- data/features/step_definitions/common.rb +123 -0
- data/features/step_definitions/formatter.rb +41 -0
- data/features/step_definitions/init.rb +17 -0
- data/features/step_definitions/run.rb +17 -0
- data/features/support/cache_helper.rb +54 -0
- data/features/support/command_helper.rb +32 -0
- data/features/support/controlrepo_helper.rb +36 -0
- data/features/support/env.rb +2 -0
- data/features/windows.feature +35 -0
- data/features/zzz_run.feature +93 -0
- data/lib/puppetlabs-onceover/beaker/spec_helper.rb +71 -0
- data/lib/puppetlabs-onceover/beaker.rb +241 -0
- data/lib/puppetlabs-onceover/class.rb +56 -0
- data/lib/puppetlabs-onceover/cli/init.rb +34 -0
- data/lib/puppetlabs-onceover/cli/plugins.rb +10 -0
- data/lib/puppetlabs-onceover/cli/run.rb +85 -0
- data/lib/puppetlabs-onceover/cli/show.rb +79 -0
- data/lib/puppetlabs-onceover/cli/update.rb +48 -0
- data/lib/puppetlabs-onceover/cli.rb +47 -0
- data/lib/puppetlabs-onceover/controlrepo.rb +688 -0
- data/lib/puppetlabs-onceover/deploy.rb +171 -0
- data/lib/puppetlabs-onceover/group.rb +78 -0
- data/lib/puppetlabs-onceover/logger.rb +32 -0
- data/lib/puppetlabs-onceover/node.rb +72 -0
- data/lib/puppetlabs-onceover/rake_tasks.rb +95 -0
- data/lib/puppetlabs-onceover/rspec/formatters.rb +315 -0
- data/lib/puppetlabs-onceover/runner.rb +139 -0
- data/lib/puppetlabs-onceover/test.rb +135 -0
- data/lib/puppetlabs-onceover/testconfig.rb +315 -0
- data/lib/puppetlabs-onceover/vendored_modules.rb +202 -0
- data/lib/puppetlabs-onceover/version.rb +5 -0
- data/puppetlabs-onceover.gemspec +40 -0
- data/spec/fixtures/controlrepos/basic/Puppetfile +17 -0
- data/spec/fixtures/controlrepos/basic/environment.conf +7 -0
- data/spec/fixtures/controlrepos/basic/hieradata/common.yaml +2 -0
- data/spec/fixtures/controlrepos/basic/hieradata/nodes/example-node.yaml +1 -0
- data/spec/fixtures/controlrepos/basic/manifests/site.pp +32 -0
- data/spec/fixtures/controlrepos/basic/manifests_alternate/site.pp +2 -0
- data/spec/fixtures/controlrepos/basic/site/profile/manifests/base.pp +5 -0
- data/spec/fixtures/controlrepos/basic/site/profile/manifests/example.pp +3 -0
- data/spec/fixtures/controlrepos/basic/site/role/manifests/database_server.pp +7 -0
- data/spec/fixtures/controlrepos/basic/site/role/manifests/example.pp +3 -0
- data/spec/fixtures/controlrepos/basic/site/role/manifests/webserver.pp +7 -0
- data/spec/fixtures/controlrepos/caching/.gitignore +1 -0
- data/spec/fixtures/controlrepos/caching/.travis.yml +2 -0
- data/spec/fixtures/controlrepos/caching/Gemfile +5 -0
- data/spec/fixtures/controlrepos/caching/Puppetfile +17 -0
- data/spec/fixtures/controlrepos/caching/Rakefile +1 -0
- data/spec/fixtures/controlrepos/caching/deleteme.txt +0 -0
- data/spec/fixtures/controlrepos/caching/environment.conf +2 -0
- data/spec/fixtures/controlrepos/caching/hieradata/common.yaml +2 -0
- data/spec/fixtures/controlrepos/caching/hieradata/nodes/example-node.yaml +1 -0
- data/spec/fixtures/controlrepos/caching/manifests/site.pp +33 -0
- data/spec/fixtures/controlrepos/caching/site/profile/manifests/base.pp +5 -0
- data/spec/fixtures/controlrepos/caching/site/profile/manifests/example.pp +3 -0
- data/spec/fixtures/controlrepos/caching/site/role/manifests/database_server.pp +7 -0
- data/spec/fixtures/controlrepos/caching/site/role/manifests/example.pp +3 -0
- data/spec/fixtures/controlrepos/caching/site/role/manifests/webserver.pp +7 -0
- data/spec/fixtures/controlrepos/caching/spec/factsets/Debian-10-facter-4.json +1091 -0
- data/spec/fixtures/controlrepos/caching/spec/factsets/README.md +7 -0
- data/spec/fixtures/controlrepos/caching/spec/onceover.yaml +55 -0
- data/spec/fixtures/controlrepos/caching/spec/pre_conditions/README.md +24 -0
- data/spec/fixtures/controlrepos/caching/spec/pre_conditions/escaping.pp +7 -0
- data/spec/fixtures/controlrepos/caching/spec/r10k.yaml +3 -0
- data/spec/fixtures/controlrepos/control_branch/Puppetfile +18 -0
- data/spec/fixtures/controlrepos/control_branch/environment.conf +2 -0
- data/spec/fixtures/controlrepos/custom_puppetfile/Puppetfile.custom +3 -0
- data/spec/fixtures/controlrepos/custom_puppetfile/environment.conf +7 -0
- data/spec/fixtures/controlrepos/factsets/environment.conf +1 -0
- data/spec/fixtures/controlrepos/factsets/site/profile/manifests/base.pp +6 -0
- data/spec/fixtures/controlrepos/factsets/site/role/manifests/example.pp +4 -0
- data/spec/fixtures/controlrepos/factsets/site/role/manifests/trusted_extensions.pp +6 -0
- data/spec/fixtures/controlrepos/factsets/site/role/manifests/trusted_external.pp +6 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/README.md +7 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos7_notrusted.json +530 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos7_trusted_extensions_nested.json +535 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos7_trusted_extensions_top.json +533 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos7_trusted_external_nested.json +537 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos7_trusted_external_top.json +535 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos_7_facter_4.json +706 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos_with_env.json +353 -0
- data/spec/fixtures/controlrepos/function_mocking/.gitignore +1 -0
- data/spec/fixtures/controlrepos/function_mocking/Puppetfile +4 -0
- data/spec/fixtures/controlrepos/function_mocking/Rakefile +1 -0
- data/spec/fixtures/controlrepos/function_mocking/environment.conf +2 -0
- data/spec/fixtures/controlrepos/function_mocking/site/profile/functions/fail_puppet.pp +5 -0
- data/spec/fixtures/controlrepos/function_mocking/site/profile/lib/puppet/functions/profile/fail_ruby.rb +9 -0
- data/spec/fixtures/controlrepos/function_mocking/site/profile/manifests/base.pp +10 -0
- data/spec/fixtures/controlrepos/function_mocking/site/role/manifests/fail.pp +7 -0
- data/spec/fixtures/controlrepos/function_mocking/site/role/manifests/test_data_return.pp +19 -0
- data/spec/fixtures/controlrepos/function_mocking/site/role/manifests/test_new_functions.pp +12 -0
- data/spec/fixtures/controlrepos/function_mocking/spec/onceover.yaml +50 -0
- data/spec/fixtures/controlrepos/minimal/environment.conf +2 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/.atom-build.json +9 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/.gitignore +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/.ruby-version +1 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/.travis.yml +13 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/Gemfile +22 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/Jenkinsfile +50 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/Puppetfile +102 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/README.md +4 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/Rakefile +33 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/common.yaml +558 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/datacenter/melbourne.yaml +12 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/datacenter/singapore.yaml +12 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/environments/development.yaml +3 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/environments/production.yaml +3 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/size/vol.large.yaml +27 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/environment.conf +3 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/hiera.yaml +25 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/manifests/site.pp +11 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/code_manager_config_version.rb +19 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/config_version.rb +25 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/config_version.sh +12 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/count_changed_classes.rb +26 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/get_changed_classes.rb +26 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/functions/user/token.pp +10 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/manifests/init.pp +14 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/manifests/user.pp +35 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/deployments/lib/puppet/functions/deployments/generate.rb +15 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/deployments/plans/signed_deployment.pp +126 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/facts.d/test.sh +2 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/artifactory/config_descriptor.xml +265 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/autosign.sh +23 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/hudson.tasks.Shell.xml +4 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/motd +4 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/polar_clock/index.html +198 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/apt.pp +9 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/aws_nodes.pp +54 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/aws.pp +9 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/rhel.pp +50 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/windows/hardening.pp +57 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/windows.pp +52 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base.pp +79 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/artifactory.pp +64 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/connection.pp +95 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/haproxy.pp +65 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/replicated.pp +53 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/compile/balancer.pp +28 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/compile/master.pp +19 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/dns/host_record.pp +16 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/dns/server.pp +66 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/docker.pp +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/base.pp +43 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/core/database_connection.pp +42 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/core.pp +72 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/ctrl.pp +57 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/database.pp +32 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/exec.pp +11 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/file_sync/client.pp +165 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/file_sync/master_patch.pp +37 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/grafana/dashboard.pp +17 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/haproxy.pp +43 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/init.pp +3 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jenkins/plugins.pp +87 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jenkins.pp +65 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/aio.pp +39 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/app.pp +27 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/db.pp +25 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/collectd/compile.pp +82 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/collectd.pp +28 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/dashboard.pp +28 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/mysql_server.pp +7 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/nginx.pp +24 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/polar_clock.pp +55 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/api_auth.pp +82 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/autosign.pp +33 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/aws.pp +58 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/tuning.pp +139 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster.pp +139 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/rvm.pp +13 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/sumologic.pp +11 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/sunburst/windows.pp +104 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/vagrant.pp +25 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/windows/webserver.pp +27 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/cd4pe/connection_script.sh.epp +110 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/controlrepo_deploy_jenkins_job.xml.epp +51 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/dashboard.json.epp +403 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/jenkins_secret_text.json.epp +1 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/onceover_jenkins_job.xml.epp +51 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/userdata.epp +17 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/cd4pe.pp +29 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/clock.pp +16 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/compile/balancer.pp +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/compile/master.pp +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/aio.pp +10 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/controller.pp +10 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/database.pp +7 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/exec.pp +6 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/init.pp +3 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/lb.pp +14 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/metrics.pp +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/mysql.pp +13 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/windows/base.pp +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/windows/webserver.pp +6 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/.gitignore +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/acceptance/nodesets/onceover-nodes.yml +94 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/classes/test_spec.rb +8 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64-master-2017.3.2.json +531 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64-master.json +429 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64.json +353 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/Windows_Server-2008r2-64.json +184 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/Windows_Server-2012r2-64.json +165 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/hiera.yaml +18 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/matchers/file_matchers.rb +16 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/onceover.yaml +54 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/pre_conditions/site.pp +150 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/r10k.yaml +2 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/shared_examples/helper.rb +91 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/00_parse_spec.rb +76 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/01_linting_spec_example.rb +69 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/03_puppetfile_spec_example.rb +35 -0
- data/spec/fixtures/controlrepos/vendored/Puppetfile +3 -0
- data/spec/fixtures/controlrepos/vendored/Puppetfile.cron +5 -0
- data/spec/fixtures/controlrepos/vendored/environment.conf +1 -0
- data/spec/fixtures/controlrepos/vendored/site-modules/role/manifests/cron.pp +9 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/augeas_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/augeas_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/cron_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/cron_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/host_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/host_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/mount_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/mount_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/repo_tree-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/repo_tree-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/scheduled_task-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/scheduled_task-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/selinux_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/selinux_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/sshkeys_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/sshkeys_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/yumrepo_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/yumrepo_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zfs_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zfs_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zone_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zone_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/windows/Gemfile +3 -0
- data/spec/fixtures/controlrepos/windows/Puppetfile +8 -0
- data/spec/fixtures/controlrepos/windows/environment.conf +1 -0
- data/spec/fixtures/controlrepos/windows/site/role/manifests/groups.pp +8 -0
- data/spec/fixtures/controlrepos/windows/site/role/manifests/users.pp +9 -0
- data/spec/fixtures/controlrepos/windows/site-modules/role/manifests/acl.pp +12 -0
- data/spec/fixtures/controlrepos/windows/site-modules/role/manifests/choco.pp +9 -0
- data/spec/fixtures/controlrepos/windows/site-modules/role/manifests/groups.pp +8 -0
- data/spec/fixtures/controlrepos/windows/site-modules/role/manifests/users.pp +9 -0
- data/spec/fixtures/controlrepos/windows/spec/onceover.yaml +24 -0
- data/spec/puppetlabs-onceover/controlrepo_spec.rb +18 -0
- data/spec/spec_helper.rb +8 -0
- data/templates/.fixtures.yml.erb +24 -0
- data/templates/Gemfile.erb +3 -0
- data/templates/Rakefile.erb +1 -0
- data/templates/acceptance_test_spec.rb.erb +66 -0
- data/templates/controlrepo.yaml.erb +38 -0
- data/templates/error_summary.yaml.erb +17 -0
- data/templates/factsets_README.md.erb +10 -0
- data/templates/nodeset.yaml.erb +12 -0
- data/templates/pre_conditions_README.md.erb +24 -0
- data/templates/spec_helper.rb.erb +35 -0
- data/templates/spec_helper_acceptance.rb.erb +1 -0
- data/templates/test_spec.rb.erb +150 -0
- data/templates/testconfig_Rakefile.erb +47 -0
- metadata +602 -0
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
require 'r10k/puppetfile'
|
|
2
|
+
require 'erb'
|
|
3
|
+
require 'yaml'
|
|
4
|
+
require 'find'
|
|
5
|
+
require 'pathname'
|
|
6
|
+
require 'multi_json'
|
|
7
|
+
require 'puppetlabs-onceover/beaker'
|
|
8
|
+
require 'puppetlabs-onceover/logger'
|
|
9
|
+
include PuppetlabsOnceover::Logger
|
|
10
|
+
|
|
11
|
+
class PuppetlabsOnceover
|
|
12
|
+
class Controlrepo
|
|
13
|
+
# This exists for caching. Each time a new one of these objects is created
|
|
14
|
+
# it gets dumped in here so that it's values can be called without
|
|
15
|
+
# reference to the initial object itself
|
|
16
|
+
@@existing_controlrepo = nil
|
|
17
|
+
|
|
18
|
+
attr_accessor :root
|
|
19
|
+
attr_accessor :puppetfile
|
|
20
|
+
attr_accessor :facts_files
|
|
21
|
+
attr_accessor :environmentpath
|
|
22
|
+
attr_accessor :role_regex
|
|
23
|
+
attr_accessor :profile_regex
|
|
24
|
+
attr_accessor :spec_dir
|
|
25
|
+
attr_accessor :temp_modulepath
|
|
26
|
+
attr_accessor :nodeset_file
|
|
27
|
+
attr_accessor :manifest
|
|
28
|
+
attr_accessor :tempdir
|
|
29
|
+
attr_accessor :onceover_yaml
|
|
30
|
+
attr_accessor :opts
|
|
31
|
+
|
|
32
|
+
# Create methods on self so that we can access these basic things without
|
|
33
|
+
# having to actually instantiate the class, I'm debating how much stuff
|
|
34
|
+
# I should be putting in here, we don't reeeally need to instantiate the
|
|
35
|
+
# object unless we want to modify it's parameters, so maybe everything.
|
|
36
|
+
# We shall see...
|
|
37
|
+
#
|
|
38
|
+
# And yeah I know this makes little sense, but it will look nicer to type, promise
|
|
39
|
+
#
|
|
40
|
+
# Also it's probably pretty memory hungry, but let's be honest, how many
|
|
41
|
+
# times would be be calling this? If we call it over and over you can just
|
|
42
|
+
# instantiate it anyway
|
|
43
|
+
def self.root
|
|
44
|
+
@@existing_controlrepo.root
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.puppetfile
|
|
48
|
+
@@existing_controlrepo.puppetfile
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.facts_files
|
|
52
|
+
@@existing_controlrepo.facts_files
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.classes
|
|
56
|
+
@@existing_controlrepo.classes
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def self.roles
|
|
60
|
+
@@existing_controlrepo.roles
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.profiles
|
|
64
|
+
@@existing_controlrepo.profiles
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.config
|
|
68
|
+
@@existing_controlrepo.config
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.facts(filter = nil)
|
|
72
|
+
@@existing_controlrepo.facts(filter, 'values')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.trusted_facts(filter = nil)
|
|
76
|
+
@@existing_controlrepo.facts(filter, 'trusted')
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def self.trusted_external_facts(filter = nil)
|
|
80
|
+
@@existing_controlrepo.facts(filter, 'trusted_external')
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def self.hiera_config_file
|
|
84
|
+
@@existing_controlrepo.hiera_config_file
|
|
85
|
+
end
|
|
86
|
+
#
|
|
87
|
+
# End class methods
|
|
88
|
+
#
|
|
89
|
+
|
|
90
|
+
def initialize(opts = {})
|
|
91
|
+
# When we initialize the object it is going to set some instance vars
|
|
92
|
+
|
|
93
|
+
# We want people to be able to run this from anywhere within the repo
|
|
94
|
+
# so traverse up until we think we are in a controlrepo.
|
|
95
|
+
if opts[:path]
|
|
96
|
+
@root = opts[:path]
|
|
97
|
+
else
|
|
98
|
+
@root = Dir.pwd
|
|
99
|
+
until File.exist?(File.expand_path('./environment.conf', @root)) do
|
|
100
|
+
# Throw an exception if we can't go any further up
|
|
101
|
+
throw "Could not file root of the controlrepo anywhere above #{Dir.pwd}" if @root == File.expand_path('../', @root)
|
|
102
|
+
|
|
103
|
+
# Step up and try again
|
|
104
|
+
@root = File.expand_path('../', @root)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
@onceover_yaml = ENV['ONCEOVER_YAML'] || opts[:onceover_yaml] || File.expand_path("#{@root}/spec/onceover.yaml")
|
|
109
|
+
|
|
110
|
+
if File.exist?(@onceover_yaml) && _data = YAML.load_file(@onceover_yaml)
|
|
111
|
+
opts.merge!(_data.fetch('opts',{})||{})
|
|
112
|
+
end
|
|
113
|
+
opts.fetch(:facts_dir,'').sub!(%r{^[^/.].+} ){|path| File.expand_path(path, @root)}
|
|
114
|
+
opts.fetch(:facts_files,[]).map!{|path| path =~ %r{^[/.]} ? path : File.expand_path(path, @root)}
|
|
115
|
+
|
|
116
|
+
@environmentpath = opts[:environmentpath] || 'etc/puppetlabs/code/environments'
|
|
117
|
+
@puppetfile = opts[:puppetfile] || File.expand_path('./Puppetfile', @root)
|
|
118
|
+
@environment_conf = opts[:environment_conf] || File.expand_path('./environment.conf', @root)
|
|
119
|
+
@spec_dir = opts[:spec_dir] || File.expand_path('./spec', @root)
|
|
120
|
+
@facts_dir = opts[:facts_dir] || File.expand_path('factsets', @spec_dir)
|
|
121
|
+
_facts_dirs = [@facts_dir, File.expand_path('../../factsets', __dir__)]
|
|
122
|
+
_facts_files = opts[:facts_files] || _facts_dirs.map{|d| File.join(d, '*.json')}
|
|
123
|
+
@facts_files = _facts_files.map{|_path| Dir[_path]}.flatten
|
|
124
|
+
|
|
125
|
+
@nodeset_file = opts[:nodeset_file] || File.expand_path('./spec/acceptance/nodesets/onceover-nodes.yml', @root)
|
|
126
|
+
@role_regex = opts[:role_regex] ? Regexp.new(opts[:role_regex]) : /role[s]?:{2}/
|
|
127
|
+
@profile_regex = opts[:profile_regex] ? Regexp.new(opts[:profile_regex]) : /profile[s]?:{2}/
|
|
128
|
+
@tempdir = opts[:tempdir] || File.expand_path('./.onceover', @root)
|
|
129
|
+
$temp_modulepath = nil
|
|
130
|
+
@opts = opts
|
|
131
|
+
logger.level = :debug if @opts[:debug]
|
|
132
|
+
@@existing_controlrepo = self
|
|
133
|
+
|
|
134
|
+
# Set the manifest option to the fully expanded path if it's used,
|
|
135
|
+
# default to nil
|
|
136
|
+
manifest = opts[:manifest] || config['manifest'] || nil
|
|
137
|
+
if manifest
|
|
138
|
+
@manifest = File.expand_path(manifest, @root)
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def to_s
|
|
143
|
+
require 'colored'
|
|
144
|
+
|
|
145
|
+
<<-REPO.gsub(/^\s{4}/,'')
|
|
146
|
+
#{'puppetfile'.green} #{@puppetfile}
|
|
147
|
+
#{'environment_conf'.green} #{@environment_conf}
|
|
148
|
+
#{'facts_dir'.green} #{@facts_dir}
|
|
149
|
+
#{'spec_dir'.green} #{@spec_dir}
|
|
150
|
+
#{'facts_files'.green} #{@facts_files}
|
|
151
|
+
#{'nodeset_file'.green} #{@nodeset_file}
|
|
152
|
+
#{'roles'.green} #{roles}
|
|
153
|
+
#{'profiles'.green} #{profiles}
|
|
154
|
+
#{'onceover.yaml'.green} #{@onceover_yaml}
|
|
155
|
+
REPO
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def roles
|
|
159
|
+
classes.keep_if { |c| c =~ @role_regex }
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def profiles
|
|
163
|
+
classes.keep_if { |c| c =~ @profile_regex }
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def classes
|
|
167
|
+
logger.debug('scanning for classes specified in onceover.yaml')
|
|
168
|
+
|
|
169
|
+
# Get all of the possible places for puppet code and look for classes
|
|
170
|
+
code_dirs = self.config['modulepath']
|
|
171
|
+
# Remove interpolated references
|
|
172
|
+
code_dirs.delete_if { |dir| dir[0] == '$'}
|
|
173
|
+
|
|
174
|
+
# Include all r10k-downloaded modules to support vendored and/or separate
|
|
175
|
+
# role and profile classes
|
|
176
|
+
code_dirs << "#{@tempdir}/#{@environmentpath}/production/modules"
|
|
177
|
+
|
|
178
|
+
# Make sure that the paths are relative to the controlrepo root
|
|
179
|
+
code_dirs.map! do |dir|
|
|
180
|
+
File.expand_path(dir, @root)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Get all the classes from all of the manifests
|
|
184
|
+
classes = code_dirs.map do |dir|
|
|
185
|
+
get_classes(dir)
|
|
186
|
+
end
|
|
187
|
+
classes.flatten
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def facts(filter = nil, key = 'values')
|
|
191
|
+
# Returns an array facts hashes
|
|
192
|
+
all_facts = []
|
|
193
|
+
logger.debug "Reading factsets"
|
|
194
|
+
@facts_files.each do |file|
|
|
195
|
+
facts_from_file = read_facts(file)
|
|
196
|
+
# Facter 4 removed the top level key 'values' and, instead, puts facts
|
|
197
|
+
# at the top level. The conditional below accounts for this.
|
|
198
|
+
if (key.eql?('values') and facts_from_file.has_key?('values')) or !key.eql?('values')
|
|
199
|
+
all_facts << facts_from_file[key]
|
|
200
|
+
else
|
|
201
|
+
all_facts << facts_from_file
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
if filter
|
|
205
|
+
# Allow us to pass a hash of facts to filter by
|
|
206
|
+
raise "Filter param must be a hash" unless filter.is_a?(Hash)
|
|
207
|
+
|
|
208
|
+
all_facts.keep_if do |hash|
|
|
209
|
+
matches = filter.map do |filter_fact,value|
|
|
210
|
+
keypair_is_in_hash(hash,filter_fact,value)
|
|
211
|
+
end
|
|
212
|
+
!matches.include? false
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
return all_facts
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def print_puppetfile_table
|
|
219
|
+
require 'terminal-table'
|
|
220
|
+
require 'versionomy'
|
|
221
|
+
require 'colored'
|
|
222
|
+
require 'r10k/puppetfile'
|
|
223
|
+
|
|
224
|
+
# Load up the Puppetfile using R10k
|
|
225
|
+
logger.debug "Reading puppetfile from #{@root}"
|
|
226
|
+
puppetfile = R10K::Puppetfile.new(@root)
|
|
227
|
+
logger.debug "Loading modules from Puppetfile"
|
|
228
|
+
puppetfile.load!
|
|
229
|
+
|
|
230
|
+
output_array = []
|
|
231
|
+
error_array = []
|
|
232
|
+
threads = puppetfile.modules.map do |mod|
|
|
233
|
+
Thread.new do
|
|
234
|
+
begin
|
|
235
|
+
row = []
|
|
236
|
+
logger.debug "Loading data for #{mod.full_name}"
|
|
237
|
+
row << mod.full_name
|
|
238
|
+
if mod.is_a?(R10K::Module::Forge)
|
|
239
|
+
row << mod.expected_version
|
|
240
|
+
row << mod.v3_module.current_release.version
|
|
241
|
+
|
|
242
|
+
# Configure a custom version format to support modern Puppet Forge versions.
|
|
243
|
+
# (major.minor.tiny-patchlevel-patchlevel_minor)
|
|
244
|
+
# e.g. 8.5.0-0-2
|
|
245
|
+
puppetforge_format = Versionomy.default_format.modified_copy do
|
|
246
|
+
field(:patchlevel_minor) do
|
|
247
|
+
recognize_number(:default_value_optional => true,
|
|
248
|
+
:delimiter_regexp => '-',
|
|
249
|
+
:default_delimiter => '-')
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
current = puppetforge_format.parse(mod.expected_version)
|
|
254
|
+
latest = puppetforge_format.parse(mod.v3_module.current_release.version)
|
|
255
|
+
row << if current.major < latest.major
|
|
256
|
+
"Major".red
|
|
257
|
+
elsif current.minor < latest.minor
|
|
258
|
+
"Minor".yellow
|
|
259
|
+
elsif current.tiny < latest.tiny
|
|
260
|
+
"Tiny".green
|
|
261
|
+
elsif current.patchlevel < latest.patchlevel
|
|
262
|
+
"PatchLevel".green
|
|
263
|
+
elsif current.patchlevel_minor < latest.patchlevel_minor
|
|
264
|
+
"PatchLevel_minor".green
|
|
265
|
+
else
|
|
266
|
+
"No".green
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
row << mod.v3_module.endorsement
|
|
270
|
+
superseded_by = mod.v3_module.superseded_by
|
|
271
|
+
row << (superseded_by.nil? ? '' : superseded_by[:slug])
|
|
272
|
+
else
|
|
273
|
+
row << "N/A"
|
|
274
|
+
row << "N/A"
|
|
275
|
+
row << "N/A"
|
|
276
|
+
row << "N/A"
|
|
277
|
+
row << "N/A"
|
|
278
|
+
end
|
|
279
|
+
output_array << row
|
|
280
|
+
rescue RuntimeError => e
|
|
281
|
+
error = []
|
|
282
|
+
error << mod.full_name
|
|
283
|
+
error << mod.expected_version
|
|
284
|
+
error << mod.v3_module.current_release.version
|
|
285
|
+
error << e.message
|
|
286
|
+
error_array << error
|
|
287
|
+
logger.debug "Error loading module #{mod.full_name} - #{e.inspect}"
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
threads.map(&:join)
|
|
293
|
+
|
|
294
|
+
output_array.sort_by! { |line| line[0] }
|
|
295
|
+
error_array.sort_by! { |line| line[0] } unless error_array.empty?
|
|
296
|
+
|
|
297
|
+
puts Terminal::Table.new(headings: ["Full Name", "Current Version", "Latest Version", "Out of Date?", "Endorsement", "Superseded by"], rows: output_array)
|
|
298
|
+
puts Terminal::Table.new(headings: ["Issue assessing module", "Current", "Latest", "Error"], rows: error_array) unless error_array.empty?
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
def update_puppetfile
|
|
302
|
+
require 'r10k/puppetfile'
|
|
303
|
+
|
|
304
|
+
# Read in the Puppetfile as a string and as an object
|
|
305
|
+
puppetfile_string = File.read(@puppetfile).split("\n")
|
|
306
|
+
puppetfile = R10K::Puppetfile.new(@root)
|
|
307
|
+
puppetfile.load!
|
|
308
|
+
|
|
309
|
+
# TODO: Make sure we can deal with :latest
|
|
310
|
+
|
|
311
|
+
# Create threading resources
|
|
312
|
+
queue = Queue.new
|
|
313
|
+
queue.push(puppetfile_string)
|
|
314
|
+
|
|
315
|
+
puppetfile.modules.keep_if {|m| m.is_a?(R10K::Module::Forge)}
|
|
316
|
+
threads = puppetfile.modules.map do |mod|
|
|
317
|
+
Thread.new do
|
|
318
|
+
logger.debug "Getting latest version of #{mod.full_name}"
|
|
319
|
+
latest_version = mod.v3_module.current_release.version
|
|
320
|
+
|
|
321
|
+
# Get the data off the queue, or wait if something else is using it
|
|
322
|
+
puppetfile_string_temp = queue.pop
|
|
323
|
+
line_index = puppetfile_string_temp.index {|l| l =~ /^\s*[^#]*#{mod.owner}[\/-]#{mod.name}/}
|
|
324
|
+
puppetfile_string_temp[line_index].gsub!(mod.expected_version,latest_version)
|
|
325
|
+
|
|
326
|
+
# Put the data back into the queue once we are done with it
|
|
327
|
+
queue.push(puppetfile_string_temp)
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
threads.map(&:join)
|
|
332
|
+
puppetfile_string = queue.pop
|
|
333
|
+
|
|
334
|
+
File.open(@puppetfile, 'w') {|f| f.puts(puppetfile_string.join("\n")) }
|
|
335
|
+
puts "#{'changed'.yellow} #{@puppetfile}"
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def fixtures
|
|
339
|
+
# Load up the Puppetfile using R10k
|
|
340
|
+
puppetfile = R10K::Puppetfile.new(@root)
|
|
341
|
+
fail 'Could not load Puppetfile' unless puppetfile.load
|
|
342
|
+
|
|
343
|
+
modules = puppetfile.modules
|
|
344
|
+
|
|
345
|
+
# Iterate over everything and seperate it out for the sake of readability
|
|
346
|
+
symlinks = []
|
|
347
|
+
forge_modules = []
|
|
348
|
+
repositories = []
|
|
349
|
+
|
|
350
|
+
modules.each do |mod|
|
|
351
|
+
logger.debug "Converting #{mod.to_s} to .fixtures.yml format"
|
|
352
|
+
# This logic could probably be cleaned up. A lot.
|
|
353
|
+
if mod.is_a? R10K::Module::Forge
|
|
354
|
+
if mod.expected_version.is_a?(Hash)
|
|
355
|
+
# Set it up as a symlink, because we are using local files in the Puppetfile
|
|
356
|
+
symlinks << {
|
|
357
|
+
'name' => mod.name,
|
|
358
|
+
'dir' => mod.expected_version[:path]
|
|
359
|
+
}
|
|
360
|
+
elsif mod.expected_version.is_a?(String)
|
|
361
|
+
# Set it up as a normal forge module
|
|
362
|
+
forge_modules << {
|
|
363
|
+
'name' => mod.name,
|
|
364
|
+
'repo' => mod.title,
|
|
365
|
+
'ref' => mod.expected_version
|
|
366
|
+
}
|
|
367
|
+
end
|
|
368
|
+
elsif mod.is_a? R10K::Module::Git
|
|
369
|
+
# Set it up as a git repo
|
|
370
|
+
repositories << {
|
|
371
|
+
'name' => mod.name,
|
|
372
|
+
# I know I shouldn't be doing this, but trust me, there are no methods
|
|
373
|
+
# anywhere that expose this value, I looked.
|
|
374
|
+
'repo' => mod.instance_variable_get(:@remote),
|
|
375
|
+
'ref' => mod.version
|
|
376
|
+
}
|
|
377
|
+
end
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
# also add synlinks for anything that is in environment.conf
|
|
381
|
+
code_dirs = self.config['modulepath']
|
|
382
|
+
code_dirs.delete_if { |dir| dir[0] == '$'}
|
|
383
|
+
code_dirs.each do |dir|
|
|
384
|
+
# We need to traverse down into these directories and create a symlink for each
|
|
385
|
+
# module we find because fixtures.yml is expecting the module's root not the
|
|
386
|
+
# root of modulepath
|
|
387
|
+
Dir["#{dir}/*"].each do |mod|
|
|
388
|
+
symlinks << {
|
|
389
|
+
'name' => File.basename(mod),
|
|
390
|
+
'dir' => Pathname.new(File.expand_path(mod)).relative_path_from(Pathname.new(@root))#File.expand_path(mod)
|
|
391
|
+
}
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
# Use an ERB template to write the files
|
|
396
|
+
PuppetlabsOnceover::Controlrepo.evaluate_template('.fixtures.yml.erb', binding)
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
def hiera_config_file
|
|
400
|
+
case
|
|
401
|
+
when File.exist?(File.expand_path('./hiera.yaml', @spec_dir))
|
|
402
|
+
File.expand_path('./hiera.yaml', @spec_dir)
|
|
403
|
+
when File.exist?(File.expand_path('./hiera.yaml', @root))
|
|
404
|
+
File.expand_path('./hiera.yaml', @root)
|
|
405
|
+
else
|
|
406
|
+
nil
|
|
407
|
+
end
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
def hiera_config_file_relative_path
|
|
411
|
+
Pathname.new(hiera_config_file).relative_path_from(Pathname.new(root)).to_s if hiera_config_file
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
def hiera_config
|
|
415
|
+
begin
|
|
416
|
+
YAML.load_file(hiera_config_file)
|
|
417
|
+
rescue TypeError
|
|
418
|
+
puts "WARNING: Could not find hiera config file, continuing"
|
|
419
|
+
nil
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
def hiera_config=(data)
|
|
424
|
+
File.write(hiera_config_file,data.to_yaml)
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
def hiera_data
|
|
428
|
+
# This is going to try to find your hiera data directory, if you have named it something
|
|
429
|
+
# unexpected it won't work
|
|
430
|
+
possibe_datadirs = Dir["#{@root}/*/"]
|
|
431
|
+
possibe_datadirs.keep_if { |dir| dir =~ /hiera(?:.*data)?/i }
|
|
432
|
+
raise "There were too many directories that looked like hiera data: #{possibe_datadirs}" if possibe_datadirs.count > 1
|
|
433
|
+
|
|
434
|
+
File.expand_path(possibe_datadirs[0])
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
def config
|
|
438
|
+
logger.debug "Reading #{@environment_conf}"
|
|
439
|
+
env_conf = File.read(@environment_conf)
|
|
440
|
+
env_conf = env_conf.split("\n")
|
|
441
|
+
|
|
442
|
+
# Delete commented out lines
|
|
443
|
+
env_conf.delete_if { |l| l =~ /^\s*#/}
|
|
444
|
+
|
|
445
|
+
# Map the lines into a hash
|
|
446
|
+
environment_config = {}
|
|
447
|
+
env_conf.each do |line|
|
|
448
|
+
if matches = line.match(/^(\S+)\s*=(.*)$/)
|
|
449
|
+
environment_config[matches[1]] = matches[2].strip
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
# Finally, split the modulepath values and return
|
|
454
|
+
begin
|
|
455
|
+
environment_config['modulepath'] = environment_config['modulepath'].split(':')
|
|
456
|
+
rescue StandardError
|
|
457
|
+
raise "modulepath was not found in environment.conf, don't know where to look for roles & profiles"
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
environment_config
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
def r10k_config_file
|
|
464
|
+
case
|
|
465
|
+
when File.exist?(File.expand_path('./r10k.yaml', @spec_dir))
|
|
466
|
+
File.expand_path('./r10k.yaml', @spec_dir)
|
|
467
|
+
when File.exist?(File.expand_path('./r10k.yaml', @root))
|
|
468
|
+
File.expand_path('./r10k.yaml', @root)
|
|
469
|
+
else
|
|
470
|
+
nil
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
def r10k_config
|
|
475
|
+
YAML.load_file(r10k_config_file)
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
def r10k_config=(data)
|
|
479
|
+
File.write(r10k_config_file, data.to_yaml)
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
def temp_manifest
|
|
483
|
+
@manifest
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
def self.init(repo)
|
|
487
|
+
# This code will initialise a controlrepo with all of the config
|
|
488
|
+
# that it needs
|
|
489
|
+
require 'pathname'
|
|
490
|
+
require 'colored'
|
|
491
|
+
|
|
492
|
+
PuppetlabsOnceover::Controlrepo.init_write_file(generate_onceover_yaml(repo), repo.onceover_yaml)
|
|
493
|
+
# [DEPRECATION] Writing nodesets is deprecated due to the removal of Beaker"
|
|
494
|
+
#PuppetlabsOnceover::Controlrepo.init_write_file(generate_nodesets(repo),repo.nodeset_file)
|
|
495
|
+
init_write_file(
|
|
496
|
+
evaluate_template('pre_conditions_README.md.erb', binding),
|
|
497
|
+
File.expand_path('./pre_conditions/README.md', repo.spec_dir)
|
|
498
|
+
)
|
|
499
|
+
init_write_file(
|
|
500
|
+
evaluate_template('factsets_README.md.erb', binding),
|
|
501
|
+
File.expand_path('./factsets/README.md', repo.spec_dir)
|
|
502
|
+
)
|
|
503
|
+
init_write_file(
|
|
504
|
+
evaluate_template('Rakefile.erb', binding),
|
|
505
|
+
File.expand_path('./Rakefile', repo.root)
|
|
506
|
+
)
|
|
507
|
+
init_write_file(
|
|
508
|
+
evaluate_template('Gemfile.erb', binding),
|
|
509
|
+
File.expand_path('./Gemfile', repo.root)
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
# Add .onceover to Gitignore
|
|
513
|
+
gitignore_path = File.expand_path('.gitignore', repo.root)
|
|
514
|
+
if File.exist? gitignore_path
|
|
515
|
+
gitignore_content = (File.read(gitignore_path)).split("\n")
|
|
516
|
+
message = "#{'changed'.green}"
|
|
517
|
+
else
|
|
518
|
+
message = "#{'created'.green}"
|
|
519
|
+
gitignore_content = []
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
unless gitignore_content.include?(".onceover")
|
|
523
|
+
gitignore_content << ".onceover\n"
|
|
524
|
+
File.write(gitignore_path, gitignore_content.join("\n"))
|
|
525
|
+
puts "#{message} #{Pathname.new(gitignore_path).relative_path_from(Pathname.new(Dir.pwd)).to_s}"
|
|
526
|
+
end
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
def self.generate_onceover_yaml(repo)
|
|
530
|
+
# This will return a controlrepo.yaml that can be written to a file
|
|
531
|
+
evaluate_template('controlrepo.yaml.erb', binding)
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
def self.generate_nodesets(repo)
|
|
535
|
+
warn "[DEPRECATION] #{__method__} is deprecated due to the removal of Beaker"
|
|
536
|
+
|
|
537
|
+
require 'puppetlabs-onceover/beaker'
|
|
538
|
+
require 'multi_json'
|
|
539
|
+
require 'net/http'
|
|
540
|
+
|
|
541
|
+
hosts_hash = {}
|
|
542
|
+
|
|
543
|
+
repo.facts.each do |fact_set|
|
|
544
|
+
node_name = File.basename(repo.facts_files[repo.facts.index(fact_set)], '.json')
|
|
545
|
+
boxname = PuppetlabsOnceover::Beaker.facts_to_vagrant_box(fact_set)
|
|
546
|
+
platform = PuppetlabsOnceover::Beaker.facts_to_platform(fact_set)
|
|
547
|
+
|
|
548
|
+
logger.debug "Querying hashicorp API for Vagrant box that matches #{boxname}"
|
|
549
|
+
|
|
550
|
+
uri = URI("https://atlas.hashicorp.com:443/api/v1/box/#{boxname}")
|
|
551
|
+
request = Net::HTTP.new(uri.host, uri.port)
|
|
552
|
+
request.use_ssl = true
|
|
553
|
+
response = request.get(uri)
|
|
554
|
+
|
|
555
|
+
url = 'URL goes here'
|
|
556
|
+
|
|
557
|
+
if response.code == "404"
|
|
558
|
+
comment_out = true
|
|
559
|
+
else
|
|
560
|
+
comment_out = false
|
|
561
|
+
box_info = MultiJson.load(response.body)
|
|
562
|
+
box_info['current_version']['providers'].each do |provider|
|
|
563
|
+
if provider['name'] == 'virtualbox'
|
|
564
|
+
url = provider['original_url']
|
|
565
|
+
end
|
|
566
|
+
end
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
# Add the resulting info to the hosts hash. This is what the
|
|
570
|
+
# template will output
|
|
571
|
+
hosts_hash[node_name] = {
|
|
572
|
+
:platform => platform,
|
|
573
|
+
:boxname => boxname,
|
|
574
|
+
:url => url,
|
|
575
|
+
:comment_out => comment_out
|
|
576
|
+
}
|
|
577
|
+
end
|
|
578
|
+
|
|
579
|
+
# Use an ERB template
|
|
580
|
+
evaluate_template('nodeset.yaml.erb', binding)
|
|
581
|
+
end
|
|
582
|
+
|
|
583
|
+
def self.create_dirs_and_log(dir)
|
|
584
|
+
Pathname.new(dir).descend do |folder|
|
|
585
|
+
unless folder.directory?
|
|
586
|
+
FileUtils.mkdir(folder)
|
|
587
|
+
puts "#{'created'.green} #{folder.relative_path_from(Pathname.new(Dir.pwd)).to_s}"
|
|
588
|
+
end
|
|
589
|
+
end
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
def self.evaluate_template(template_name, bind)
|
|
593
|
+
logger.debug "Evaluating template #{template_name}"
|
|
594
|
+
template_dir = File.expand_path('../../templates', File.dirname(__FILE__))
|
|
595
|
+
if File.file?(File.expand_path("./spec/templates/#{template_name}", @root))
|
|
596
|
+
puts "Using Custom #{template_name}"
|
|
597
|
+
template = File.read(File.expand_path("./spec/templates/#{template_name}", @root))
|
|
598
|
+
else
|
|
599
|
+
template = File.read(File.expand_path("./#{template_name}", template_dir))
|
|
600
|
+
end
|
|
601
|
+
ERB.new(template, trim_mode: '-').result(bind)
|
|
602
|
+
end
|
|
603
|
+
|
|
604
|
+
def self.init_write_file(contents, out_file)
|
|
605
|
+
create_dirs_and_log(File.dirname(out_file))
|
|
606
|
+
if File.exist?(out_file)
|
|
607
|
+
puts "#{'skipped'.yellow} #{Pathname.new(out_file).relative_path_from(Pathname.new(Dir.pwd)).to_s} #{'(exists)'.yellow}"
|
|
608
|
+
else
|
|
609
|
+
File.write(out_file, contents)
|
|
610
|
+
puts "#{'created'.green} #{Pathname.new(out_file).relative_path_from(Pathname.new(Dir.pwd)).to_s}"
|
|
611
|
+
end
|
|
612
|
+
end
|
|
613
|
+
|
|
614
|
+
# Returns the deduplicted and verified output of testconfig.spec_tests for
|
|
615
|
+
# use in Rspec tests so that we don't have to deal with more than one object
|
|
616
|
+
def spec_tests(&block)
|
|
617
|
+
require 'puppetlabs-onceover/testconfig'
|
|
618
|
+
|
|
619
|
+
# Load up all of the tests and deduplicate them
|
|
620
|
+
testconfig = PuppetlabsOnceover::TestConfig.new(@onceover_yaml, @opts)
|
|
621
|
+
testconfig.spec_tests.each { |tst| testconfig.verify_spec_test(self, tst) }
|
|
622
|
+
tests = testconfig.run_filters(PuppetlabsOnceover::Test.deduplicate(testconfig.spec_tests))
|
|
623
|
+
|
|
624
|
+
# Loop over each test, executing the user's block on each
|
|
625
|
+
tests.each do |tst|
|
|
626
|
+
block.call(tst.classes[0].name, tst.nodes[0].name, tst.nodes[0].fact_set, tst.nodes[0].trusted_set, tst.nodes[0].trusted_external_set, testconfig.pre_condition)
|
|
627
|
+
end
|
|
628
|
+
end
|
|
629
|
+
|
|
630
|
+
private
|
|
631
|
+
|
|
632
|
+
def read_facts(facts_file)
|
|
633
|
+
file = File.read(facts_file)
|
|
634
|
+
begin
|
|
635
|
+
result = MultiJson.load(file)
|
|
636
|
+
rescue MultiJson::ParseError
|
|
637
|
+
raise "Could not parse the file #{facts_file}, check that it is valid JSON and that the encoding is correct"
|
|
638
|
+
end
|
|
639
|
+
result
|
|
640
|
+
end
|
|
641
|
+
|
|
642
|
+
def keypair_is_in_hash(first_hash, key, value)
|
|
643
|
+
matches = []
|
|
644
|
+
if first_hash.has_key?(key)
|
|
645
|
+
if value.is_a?(Hash)
|
|
646
|
+
value.each do |k, v|
|
|
647
|
+
matches << keypair_is_in_hash(first_hash[key], k, v)
|
|
648
|
+
end
|
|
649
|
+
else
|
|
650
|
+
if first_hash[key] == value
|
|
651
|
+
matches << true
|
|
652
|
+
else
|
|
653
|
+
matches << false
|
|
654
|
+
end
|
|
655
|
+
end
|
|
656
|
+
else
|
|
657
|
+
matches << false
|
|
658
|
+
end
|
|
659
|
+
!matches.include? false
|
|
660
|
+
end
|
|
661
|
+
|
|
662
|
+
def get_classes(dir)
|
|
663
|
+
classes = []
|
|
664
|
+
# Recurse over all the pp files under the dir we are given
|
|
665
|
+
logger.debug "Searching puppet code for roles and profiles"
|
|
666
|
+
Dir["#{dir}/**/*.pp"].each do |manifest|
|
|
667
|
+
classname = find_classname(manifest)
|
|
668
|
+
# Add it to the array as long as it is not nil
|
|
669
|
+
classes << classname if classname
|
|
670
|
+
end
|
|
671
|
+
classes
|
|
672
|
+
end
|
|
673
|
+
|
|
674
|
+
def find_classname(filename)
|
|
675
|
+
file = File.new(filename, "r")
|
|
676
|
+
while (line = file.gets)
|
|
677
|
+
begin
|
|
678
|
+
if line =~ /^class (\w+(?:::\w+)*)/
|
|
679
|
+
return $1
|
|
680
|
+
end
|
|
681
|
+
rescue ArgumentError => e
|
|
682
|
+
logger.error "ignoring invalid line in file: #{filename} (#{e.message}) - line: '#{line}'"
|
|
683
|
+
end
|
|
684
|
+
end
|
|
685
|
+
return nil
|
|
686
|
+
end
|
|
687
|
+
end
|
|
688
|
+
end
|