diff --git a/acceptance/tests/modules/install/already_installed.rb b/acceptance/tests/modules/install/already_installed.rb index ab7d467b8..aa4cca9d6 100644 --- a/acceptance/tests/modules/install/already_installed.rb +++ b/acceptance/tests/modules/install/already_installed.rb @@ -1,63 +1,63 @@ begin test_name "puppet module install (already installed)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" apply_manifest_on master, <<-PP file { [ '/etc/puppet/modules/nginx', ]: ensure => directory; '/etc/puppet/modules/nginx/metadata.json': content => '{ "name": "pmtacceptance/nginx", "version": "0.0.1", "source": "", "author": "pmtacceptance", "license": "MIT", "dependencies": [] }'; } PP step "Try to install a module that is already installed" on master, puppet("module install pmtacceptance-nginx"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-nginx' (latest) STDERR> Module 'pmtacceptance-nginx' (v0.0.1) is already installed STDERR> Use `puppet module upgrade` to install a different version STDERR> Use `puppet module install --force` to re-install only this module\e[0m OUTPUT end on master, '[ -d /etc/puppet/modules/nginx ]' step "Try to install a specific version of a module that is already installed" on master, puppet("module install pmtacceptance-nginx --version 1.x"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-nginx' (v1.x) STDERR> Module 'pmtacceptance-nginx' (v0.0.1) is already installed STDERR> Use `puppet module upgrade` to install a different version STDERR> Use `puppet module install --force` to re-install only this module\e[0m OUTPUT end on master, '[ -d /etc/puppet/modules/nginx ]' step "Install a module that is already installed (with --force)" on master, puppet("module install pmtacceptance-nginx --force") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-nginx (\e[0;36mv0.0.1\e[0m) OUTPUT end on master, '[ -d /etc/puppet/modules/nginx ]' ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { '/etc/puppet/modules': recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/install/already_installed_elsewhere.rb b/acceptance/tests/modules/install/already_installed_elsewhere.rb index aef9ce5fc..4ea93456d 100644 --- a/acceptance/tests/modules/install/already_installed_elsewhere.rb +++ b/acceptance/tests/modules/install/already_installed_elsewhere.rb @@ -1,66 +1,66 @@ begin test_name "puppet module install (already installed elsewhere)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" apply_manifest_on master, <<-PP file { [ '/etc/puppet/modules', '/usr/share/puppet', '/usr/share/puppet/modules', '/usr/share/puppet/modules/nginx', ]: ensure => directory; '/usr/share/puppet/modules/nginx/metadata.json': content => '{ "name": "pmtacceptance/nginx", "version": "0.0.1", "source": "", "author": "pmtacceptance", "license": "MIT", "dependencies": [] }'; } PP step "Try to install a module that is already installed" on master, puppet("module install pmtacceptance-nginx"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-nginx' (latest) STDERR> Module 'pmtacceptance-nginx' (v0.0.1) is already installed STDERR> Use `puppet module upgrade` to install a different version STDERR> Use `puppet module install --force` to re-install only this module\e[0m OUTPUT end on master, '[ ! -d /etc/puppet/modules/nginx ]' step "Try to install a specific version of a module that is already installed" on master, puppet("module install pmtacceptance-nginx --version 1.x"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-nginx' (v1.x) STDERR> Module 'pmtacceptance-nginx' (v0.0.1) is already installed STDERR> Use `puppet module upgrade` to install a different version STDERR> Use `puppet module install --force` to re-install only this module\e[0m OUTPUT end on master, '[ ! -d /etc/puppet/modules/nginx ]' step "Install a module that is already installed (with --force)" on master, puppet("module install pmtacceptance-nginx --force") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-nginx (\e[0;36mv0.0.1\e[0m) OUTPUT end on master, '[ -d /etc/puppet/modules/nginx ]' ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { '/etc/puppet/modules': recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/install/already_installed_with_local_changes.rb b/acceptance/tests/modules/install/already_installed_with_local_changes.rb index 9e97b8d6b..ee76dc0b0 100644 --- a/acceptance/tests/modules/install/already_installed_with_local_changes.rb +++ b/acceptance/tests/modules/install/already_installed_with_local_changes.rb @@ -1,70 +1,70 @@ begin test_name "puppet module install (already installed with local changes)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" apply_manifest_on master, <<-PP file { [ '/etc/puppet/modules/nginx', ]: ensure => directory; '/etc/puppet/modules/nginx/metadata.json': content => '{ "name": "pmtacceptance/nginx", "version": "0.0.1", "source": "", "author": "pmtacceptance", "license": "MIT", "checksums": { "README": "2a3adc3b053ef1004df0a02cefbae31f" }, "dependencies": [] }'; '/etc/puppet/modules/nginx/README': content => 'Nginx module'; } PP step "Try to install a module that is already installed" on master, puppet("module install pmtacceptance-nginx"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-nginx' (latest) STDERR> Module 'pmtacceptance-nginx' (v0.0.1) is already installed STDERR> Installed module has had changes made locally STDERR> Use `puppet module upgrade` to install a different version STDERR> Use `puppet module install --force` to re-install only this module\e[0m OUTPUT end on master, '[ -d /etc/puppet/modules/nginx ]' step "Try to install a specific version of a module that is already installed" on master, puppet("module install pmtacceptance-nginx --version 1.x"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-nginx' (v1.x) STDERR> Module 'pmtacceptance-nginx' (v0.0.1) is already installed STDERR> Installed module has had changes made locally STDERR> Use `puppet module upgrade` to install a different version STDERR> Use `puppet module install --force` to re-install only this module\e[0m OUTPUT end on master, '[ -d /etc/puppet/modules/nginx ]' step "Install a module that is already installed (with --force)" on master, puppet("module install pmtacceptance-nginx --force") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-nginx (\e[0;36mv0.0.1\e[0m) OUTPUT end on master, '[ -d /etc/puppet/modules/nginx ]' ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { '/etc/puppet/modules': recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/install/force_ignores_dependencies.rb b/acceptance/tests/modules/install/force_ignores_dependencies.rb index 8ca013a5d..7177a1be5 100644 --- a/acceptance/tests/modules/install/force_ignores_dependencies.rb +++ b/acceptance/tests/modules/install/force_ignores_dependencies.rb @@ -1,40 +1,40 @@ begin test_name "puppet module install (force ignores dependencies)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" step "Try to install an unsatisfiable module" on master, puppet("module install pmtacceptance-php"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-php' (latest: v0.0.2) STDERR> No version of 'pmtacceptance-php' will satisfy dependencies STDERR> You specified 'pmtacceptance-php' (latest: v0.0.2), STDERR> which depends on 'pmtacceptance-apache' (v0.0.1), STDERR> which depends on 'pmtacceptance-php' (v0.0.1) STDERR> Use `puppet module install --force` to install this module anyway\e[0m OUTPUT end on master, '[ ! -d /etc/puppet/modules/php ]' on master, '[ ! -d /etc/puppet/modules/apache ]' step "Install an unsatisfiable module with force" on master, puppet("module install pmtacceptance-php --force") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-php (\e[0;36mv0.0.2\e[0m) OUTPUT end on master, '[ -d /etc/puppet/modules/php ]' on master, '[ ! -d /etc/puppet/modules/apache ]' ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { '/etc/puppet/modules': recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/install/ignoring_dependencies.rb b/acceptance/tests/modules/install/ignoring_dependencies.rb index 5f82ffe63..0b76b3dd7 100644 --- a/acceptance/tests/modules/install/ignoring_dependencies.rb +++ b/acceptance/tests/modules/install/ignoring_dependencies.rb @@ -1,24 +1,24 @@ begin test_name "puppet module install (ignoring dependencies)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" step "Install a module, but ignore dependencies" on master, puppet("module install pmtacceptance-java --ignore-dependencies") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-java (\e[0;36mv1.7.1\e[0m) OUTPUT end on master, '[ -d /etc/puppet/modules/java ]' on master, '[ ! -d /etc/puppet/modules/stdlib ]' ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { '/etc/puppet/modules': recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/install/with_cycles.rb b/acceptance/tests/modules/install/with_cycles.rb index de68ee3c8..1033e0d20 100644 --- a/acceptance/tests/modules/install/with_cycles.rb +++ b/acceptance/tests/modules/install/with_cycles.rb @@ -1,32 +1,32 @@ begin test_name "puppet module install (with cycles)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" step "Install a module with cycles" on master, puppet("module install pmtacceptance-php --version 0.0.1") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └─┬ pmtacceptance-php (\e[0;36mv0.0.1\e[0m) └── pmtacceptance-apache (\e[0;36mv0.0.1\e[0m) OUTPUT end on master, puppet('module list') do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-apache (\e[0;36mv0.0.1\e[0m) └── pmtacceptance-php (\e[0;36mv0.0.1\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/install/with_dependencies.rb b/acceptance/tests/modules/install/with_dependencies.rb index 0f41c7ef1..34c89833a 100644 --- a/acceptance/tests/modules/install/with_dependencies.rb +++ b/acceptance/tests/modules/install/with_dependencies.rb @@ -1,25 +1,25 @@ begin test_name "puppet module install (with dependencies)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" step "Install a module with dependencies" on master, puppet("module install pmtacceptance-java") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └─┬ pmtacceptance-java (\e[0;36mv1.7.1\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end on master, '[ -d /etc/puppet/modules/java ]' on master, '[ -d /etc/puppet/modules/stdlib ]' ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/install/with_existing_module_directory.rb b/acceptance/tests/modules/install/with_existing_module_directory.rb index 10fe9d31e..391103434 100644 --- a/acceptance/tests/modules/install/with_existing_module_directory.rb +++ b/acceptance/tests/modules/install/with_existing_module_directory.rb @@ -1,96 +1,96 @@ begin test_name "puppet module install (with existing module directory)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" apply_manifest_on master, <<-PP file { [ '/etc/puppet/modules/nginx', '/etc/puppet/modules/apache', ]: ensure => directory; '/etc/puppet/modules/nginx/metadata.json': content => '{ "name": "notpmtacceptance/nginx", "version": "0.0.3", "source": "", "author": "notpmtacceptance", "license": "MIT", "dependencies": [] }'; [ '/etc/puppet/modules/nginx/extra.json', '/etc/puppet/modules/apache/extra.json', ]: content => ''; } PP step "Try to install an module with a name collision" on master, puppet("module install pmtacceptance-nginx"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-nginx' (latest: v0.0.1) STDERR> Installation would overwrite /etc/puppet/modules/nginx STDERR> Currently, 'notpmtacceptance-nginx' (v0.0.3) is installed to that directory STDERR> Use `puppet module install --dir ` to install modules elsewhere STDERR> Use `puppet module install --force` to install this module anyway\e[0m OUTPUT end on master, '[ -f /etc/puppet/modules/nginx/extra.json ]' step "Try to install an module with a path collision" on master, puppet("module install pmtacceptance-apache"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-apache' (latest: v0.0.1) STDERR> Installation would overwrite /etc/puppet/modules/apache STDERR> Use `puppet module install --dir ` to install modules elsewhere STDERR> Use `puppet module install --force` to install this module anyway\e[0m OUTPUT end on master, '[ -f /etc/puppet/modules/apache/extra.json ]' step "Try to install an module with a dependency that has collides" on master, puppet("module install pmtacceptance-php --version 0.0.1"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-php' (v0.0.1) STDERR> Dependency 'pmtacceptance-apache' (v0.0.1) would overwrite /etc/puppet/modules/apache STDERR> Use `puppet module install --dir ` to install modules elsewhere STDERR> Use `puppet module install --ignore-dependencies` to install only this module\e[0m OUTPUT end on master, '[ -f /etc/puppet/modules/apache/extra.json ]' step "Install an module with a name collision by using --force" on master, puppet("module install pmtacceptance-nginx --force"), :acceptable_exit_codes => [0] do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-nginx (\e[0;36mv0.0.1\e[0m) OUTPUT end on master, '[ ! -f /etc/puppet/modules/nginx/extra.json ]' step "Install an module with a name collision by using --force" on master, puppet("module install pmtacceptance-apache --force"), :acceptable_exit_codes => [0] do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-apache (\e[0;36mv0.0.1\e[0m) OUTPUT end on master, '[ ! -f /etc/puppet/modules/apache/extra.json ]' ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { '/etc/puppet/modules': recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/install/with_necessary_upgrade.rb b/acceptance/tests/modules/install/with_necessary_upgrade.rb index 0e6915cc0..42d929e53 100644 --- a/acceptance/tests/modules/install/with_necessary_upgrade.rb +++ b/acceptance/tests/modules/install/with_necessary_upgrade.rb @@ -1,55 +1,55 @@ begin test_name "puppet module install (with necessary dependency upgrade)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" step "Install an older module version" on master, puppet("module install pmtacceptance-java --version 1.6.0") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └─┬ pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end on master, puppet('module list --tree') do assert_output <<-OUTPUT /etc/puppet/modules └─┬ pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end step "Install a module that requires the older module dependency be upgraded" on master, puppet("module install pmtacceptance-apollo") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └─┬ pmtacceptance-apollo (\e[0;36mv0.0.1\e[0m) └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) OUTPUT end on master, puppet('module list') do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-apollo (\e[0;36mv0.0.1\e[0m) ├── pmtacceptance-java (\e[0;36mv1.7.1\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/install/with_no_dependencies.rb b/acceptance/tests/modules/install/with_no_dependencies.rb index 24f202d64..5054a483a 100644 --- a/acceptance/tests/modules/install/with_no_dependencies.rb +++ b/acceptance/tests/modules/install/with_no_dependencies.rb @@ -1,23 +1,23 @@ begin test_name "puppet module install (with no dependencies)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" step "Install a module with no dependencies" on master, puppet("module install pmtacceptance-nginx") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-nginx (\e[0;36mv0.0.1\e[0m) OUTPUT end on master, '[ -d /etc/puppet/modules/nginx ]' ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/install/with_unnecessary_upgrade.rb b/acceptance/tests/modules/install/with_unnecessary_upgrade.rb index d6f63c80d..fe4559f03 100644 --- a/acceptance/tests/modules/install/with_unnecessary_upgrade.rb +++ b/acceptance/tests/modules/install/with_unnecessary_upgrade.rb @@ -1,54 +1,54 @@ begin test_name "puppet module install (with unnecessary dependency upgrade)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" step "Install an older module version" on master, puppet("module install pmtacceptance-java --version 1.7.0") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └─┬ pmtacceptance-java (\e[0;36mv1.7.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end on master, puppet('module list') do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-java (\e[0;36mv1.7.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end step "Install a module that depends on a dependency that could be upgraded, but already satisfies constraints" on master, puppet("module install pmtacceptance-apollo") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-apollo (\e[0;36mv0.0.1\e[0m) OUTPUT end on master, puppet('module list') do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-apollo (\e[0;36mv0.0.1\e[0m) ├── pmtacceptance-java (\e[0;36mv1.7.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/install/with_unsatisfied_constraints.rb b/acceptance/tests/modules/install/with_unsatisfied_constraints.rb index 50c0f54d5..0d581e8ac 100644 --- a/acceptance/tests/modules/install/with_unsatisfied_constraints.rb +++ b/acceptance/tests/modules/install/with_unsatisfied_constraints.rb @@ -1,97 +1,97 @@ begin test_name "puppet module install (with unsatisfied constraints)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" apply_manifest_on master, <<-PP file { [ '/etc/puppet/modules/crakorn', ]: ensure => directory; '/etc/puppet/modules/crakorn/metadata.json': content => '{ "name": "jimmy/crakorn", "version": "0.0.1", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "pmtacceptance/stdlib", "version_requirement": "1.x" } ] }'; } PP step "Try to install a module that has an unsatisfiable dependency" on master, puppet("module install pmtacceptance-git"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-git' (latest: v0.0.1) STDERR> No version of 'pmtacceptance-stdlib' will satisfy dependencies STDERR> 'jimmy-crakorn' (v0.0.1) requires 'pmtacceptance-stdlib' (v1.x) STDERR> 'pmtacceptance-git' (v0.0.1) requires 'pmtacceptance-stdlib' (>= 2.0.0) STDERR> Use `puppet module install --ignore-dependencies` to install only this module\e[0m OUTPUT end on master, '[ ! -d /etc/puppet/modules/git ]' step "Install the module with an unsatisfiable dependency" on master, puppet("module install pmtacceptance-git --ignore-dependencies") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-git (\e[0;36mv0.0.1\e[0m) OUTPUT end on master, '[ -d /etc/puppet/modules/git ]' step "Try to install a specific version of the unsatisfiable dependency" on master, puppet("module install pmtacceptance-stdlib --version 1.x"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-stdlib' (v1.x) STDERR> No version of 'pmtacceptance-stdlib' will satisfy dependencies STDERR> You specified 'pmtacceptance-stdlib' (v1.x) STDERR> 'jimmy-crakorn' (v0.0.1) requires 'pmtacceptance-stdlib' (v1.x) STDERR> 'pmtacceptance-git' (v0.0.1) requires 'pmtacceptance-stdlib' (>= 2.0.0) STDERR> Use `puppet module install --force` to install this module anyway\e[0m OUTPUT end on master, '[ ! -d /etc/puppet/modules/stdlib ]' step "Try to install any version of the unsatisfiable dependency" on master, puppet("module install pmtacceptance-stdlib"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to install into /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not install module 'pmtacceptance-stdlib' (best: v1.0.0) STDERR> No version of 'pmtacceptance-stdlib' will satisfy dependencies STDERR> You specified 'pmtacceptance-stdlib' (best: v1.0.0) STDERR> 'jimmy-crakorn' (v0.0.1) requires 'pmtacceptance-stdlib' (v1.x) STDERR> 'pmtacceptance-git' (v0.0.1) requires 'pmtacceptance-stdlib' (>= 2.0.0) STDERR> Use `puppet module install --force` to install this module anyway\e[0m OUTPUT end on master, '[ ! -d /etc/puppet/modules/stdlib ]' step "Install the unsatisfiable dependency with --force" on master, puppet("module install pmtacceptance-stdlib --force") do assert_output <<-OUTPUT Preparing to install into /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Installing -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end on master, '[ -d /etc/puppet/modules/stdlib ]' ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { '/etc/puppet/modules': recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/search/by_description.rb b/acceptance/tests/modules/search/by_description.rb index b36494334..0fe3dbc76 100644 --- a/acceptance/tests/modules/search/by_description.rb +++ b/acceptance/tests/modules/search/by_description.rb @@ -1,28 +1,28 @@ begin test_name 'puppet module search should do substring matches on description' -step 'Stub http://forge.puppetlabs.com' +step 'Stub forge.puppetlabs.com' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" step 'Search for a module by description' on master, puppet("module search dummy") do assert_equal '', stderr # FIXME: The Forge does not presently match against description. # assert_equal <<-STDOUT, stdout -# Searching http://forge.puppetlabs.com ... +# Searching https://forge.puppetlabs.com ... # NAME DESCRIPTION AUTHOR KEYWORDS # pmtacceptance-nginx This is a dummy nginx mo... @pmtacceptance nginx # pmtacceptance-thin This is a dummy thin mod... @pmtacceptance ruby thin # pmtacceptance-apollo This is a dummy apollo m... @pmtacceptance stomp apollo # pmtacceptance-java This is a dummy java mod... @pmtacceptance java # pmtacceptance-stdlib This is a dummy stdlib m... @pmtacceptance stdlib libs # pmtacceptance-git This is a dummy git modu... @pmtacceptance git dvcs # pmtacceptance-apache This is a dummy apache m... @pmtacceptance apache php # pmtacceptance-php This is a dummy php modu... @pmtacceptance apache php # pmtacceptance-geordi This is a module that do... @pmtacceptance star trek # STDOUT end -ensure step 'Unstub http://forge.puppetlabs.com' +ensure step 'Unstub forge.puppetlabs.com' apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" end diff --git a/acceptance/tests/modules/search/by_keyword.rb b/acceptance/tests/modules/search/by_keyword.rb index 870d1fa19..ba7a19c60 100644 --- a/acceptance/tests/modules/search/by_keyword.rb +++ b/acceptance/tests/modules/search/by_keyword.rb @@ -1,29 +1,29 @@ begin test_name 'puppet module search should do exact keyword matches' -step 'Stub http://forge.puppetlabs.com' +step 'Stub forge.puppetlabs.com' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" step 'Search for a module by exact keyword' on master, puppet("module search github") do assert_equal '', stderr assert_equal <<-STDOUT, stdout -Searching http://forge.puppetlabs.com ... +Searching https://forge.puppetlabs.com ... NAME DESCRIPTION AUTHOR KEYWORDS pmtacceptance-git This is a dummy git module... @pmtacceptance git \e[0;32mgithub\e[0m STDOUT end # FIXME: The Forge presently matches partial keywords. # step 'Search for a module by partial keyword' # on master, puppet("module search hub") do # assert_equal '', stderr # assert_equal <<-STDOUT, stdout -# Searching http://forge.puppetlabs.com ... +# Searching https://forge.puppetlabs.com ... # No results found for 'hub'. # STDOUT # end -ensure step 'Unstub http://forge.puppetlabs.com' +ensure step 'Unstub forge.puppetlabs.com' apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" end diff --git a/acceptance/tests/modules/search/by_module_name.rb b/acceptance/tests/modules/search/by_module_name.rb index cd03ced09..d694a757c 100644 --- a/acceptance/tests/modules/search/by_module_name.rb +++ b/acceptance/tests/modules/search/by_module_name.rb @@ -1,40 +1,40 @@ begin test_name 'puppet module search should do substring matches on module name' -step 'Stub http://forge.puppetlabs.com' +step 'Stub forge.puppetlabs.com' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" step 'Search for modules by partial name' on master, puppet("module search geordi") do assert_equal '', stderr assert_equal <<-STDOUT, stdout -Searching http://forge.puppetlabs.com ... +Searching https://forge.puppetlabs.com ... NAME DESCRIPTION AUTHOR KEYWORDS pmtacceptance-\e[0;32mgeordi\e[0m This is a module that do... @pmtacceptance star trek STDOUT end # FIXME: The Forge does not presently support matches by dashed full name. # step 'Search for modules by partial full name (dashed)' # on master, puppet("module search tance-ge") do # assert_equal '', stderr # assert_equal <<-STDOUT, stdout -# Searching http://forge.puppetlabs.com ... +# Searching https://forge.puppetlabs.com ... # NAME DESCRIPTION AUTHOR KEYWORDS # pmtacceptance-geordi This is a module that do... @pmtacceptance star trek # STDOUT # end step 'Search for modules by partial full name (slashed)' on master, puppet("module search tance/ge") do assert_equal '', stderr assert_equal <<-STDOUT, stdout -Searching http://forge.puppetlabs.com ... +Searching https://forge.puppetlabs.com ... NAME DESCRIPTION AUTHOR KEYWORDS pmtaccep\e[0;32mtance-ge\e[0mordi This is a module that do... @pmtacceptance star trek STDOUT end -ensure step 'Unstub http://forge.puppetlabs.com' +ensure step 'Unstub forge.puppetlabs.com' apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" end diff --git a/acceptance/tests/modules/search/communication_error.rb b/acceptance/tests/modules/search/communication_error.rb index 83527b061..b8544b809 100644 --- a/acceptance/tests/modules/search/communication_error.rb +++ b/acceptance/tests/modules/search/communication_error.rb @@ -1,20 +1,20 @@ begin test_name 'puppet module search should print a reasonable message on communication errors' -step 'Stub http://forge.puppetlabs.com' +step 'Stub forge.puppetlabs.com' apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '127.0.0.2' }" step "Search against a non-existent Forge" on master, puppet("module search yup"), :acceptable_exit_codes => [1] do assert_match <<-STDOUT, stdout -Searching http://forge.puppetlabs.com ... +Searching https://forge.puppetlabs.com ... STDOUT - assert_match <<-STDERR, stderr -Error: Could not connect to http://forge.puppetlabs.com + assert_match <<-STDERR.chomp, stderr +Error: Could not connect to https://forge.puppetlabs.com There was a network communications problem Check your network connection and try again STDERR end -ensure step 'Unstub http://forge.puppetlabs.com' +ensure step 'Unstub forge.puppetlabs.com' apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" end diff --git a/acceptance/tests/modules/search/formatting.rb b/acceptance/tests/modules/search/formatting.rb index d5ab0f137..76530f895 100644 --- a/acceptance/tests/modules/search/formatting.rb +++ b/acceptance/tests/modules/search/formatting.rb @@ -1,22 +1,22 @@ begin test_name 'puppet module search output should be well structured' -step 'Stub http://forge.puppetlabs.com' +step 'Stub forge.puppetlabs.com' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" step 'Search results should line up by column' on master, puppet("module search apache") do assert_equal('', stderr) - assert_equal "Searching http://forge.puppetlabs.com ...\n", stdout.lines.first + assert_equal "Searching https://forge.puppetlabs.com ...\n", stdout.lines.first columns = stdout.lines.to_a[1].split(/\s{2}(?=\S)/) pattern = /^#{ columns.map { |c| c.chomp.gsub(/./, '.') }.join(' ') }$/ stdout.gsub(/\e.*?m/, '').lines.to_a[1..-1].each do |line| assert_match(pattern, line.chomp, 'columns were misaligned') end end -ensure step 'Unstub http://forge.puppetlabs.com' +ensure step 'Unstub forge.puppetlabs.com' apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" end diff --git a/acceptance/tests/modules/search/multiple_search_terms.rb b/acceptance/tests/modules/search/multiple_search_terms.rb index 468a22402..1f5d62cab 100644 --- a/acceptance/tests/modules/search/multiple_search_terms.rb +++ b/acceptance/tests/modules/search/multiple_search_terms.rb @@ -1,25 +1,25 @@ begin test_name 'puppet module search should handle multiple search terms sensibly' -step 'Stub http://forge.puppetlabs.com' +step 'Stub forge.puppetlabs.com' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" # FIXME: The Forge doesn't properly handle multi-term searches. # step 'Search for a module by description' # on master, puppet("module search 'notice here'") do # assert stdout !~ /'notice here'/ # end # # step 'Search for a module by name' # on master, puppet("module search 'ance-geo ance-std'") do # assert stdout !~ /'ance-geo ance-std'/ # end # # step 'Search for multiple keywords' # on master, puppet("module search 'star trek'") do # assert stdout !~ /'star trek'/ # end -ensure step 'Unstub http://forge.puppetlabs.com' +ensure step 'Unstub forge.puppetlabs.com' apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" end diff --git a/acceptance/tests/modules/search/no_results.rb b/acceptance/tests/modules/search/no_results.rb index 57a2cd2ac..c663ad2b7 100644 --- a/acceptance/tests/modules/search/no_results.rb +++ b/acceptance/tests/modules/search/no_results.rb @@ -1,18 +1,18 @@ begin test_name 'puppet module search should print a reasonable message for no results' -step 'Stub http://forge.puppetlabs.com' +step 'Stub forge.puppetlabs.com' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" step "Search for a module that doesn't exist" on master, puppet("module search module_not_appearing_in_this_forge") do assert_equal '', stderr assert_equal <<-STDOUT, stdout -Searching http://forge.puppetlabs.com ... +Searching https://forge.puppetlabs.com ... No results found for 'module_not_appearing_in_this_forge'. STDOUT end -ensure step 'Unstub http://forge.puppetlabs.com' +ensure step 'Unstub forge.puppetlabs.com' apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" end diff --git a/acceptance/tests/modules/search/ssl_errors.rb b/acceptance/tests/modules/search/ssl_errors.rb new file mode 100644 index 000000000..594b92cb7 --- /dev/null +++ b/acceptance/tests/modules/search/ssl_errors.rb @@ -0,0 +1,24 @@ +begin test_name 'puppet module search should print a reasonable message on ssl errors' + +step "Search against a website where the certificate is not signed by a public authority" + +# This might seem silly, but a master has a self-signed certificate and is a +# cheap way of testing against a web server without a publicly signed cert +with_master_running_on(master) do + on master, puppet("module search yup --module_repository=https://localhost:8140"), :acceptable_exit_codes => [1] do + assert_match <<-STDOUT, stdout +Searching https://localhost:8140 ... +STDOUT + assert_match <<-STDERR.chomp, stderr +Error: Unable to verify the SSL certificate at https://localhost:8140 + This could be because the certificate is invalid or that the CA bundle + installed with your version of OpenSSL is not available, not valid or + not up to date. +STDERR +end + +end + +ensure step 'Remove fake forge hostname' +apply_manifest_on master, "host { 'fake.fakeforge.com': ensure => absent }" +end diff --git a/acceptance/tests/modules/upgrade/in_a_secondary_directory.rb b/acceptance/tests/modules/upgrade/in_a_secondary_directory.rb index a72a80491..aca605c5e 100644 --- a/acceptance/tests/modules/upgrade/in_a_secondary_directory.rb +++ b/acceptance/tests/modules/upgrade/in_a_secondary_directory.rb @@ -1,42 +1,42 @@ begin test_name "puppet module upgrade (in a secondary directory)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, <<-'MANIFEST1' file { '/usr/share/puppet': ensure => directory, } file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true, } MANIFEST1 on master, puppet("module install pmtacceptance-java --version 1.6.0 --target-dir /usr/share/puppet/modules") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules (no modules installed) /usr/share/puppet/modules ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end step "Upgrade a module that has a more recent version published" on master, puppet("module upgrade pmtacceptance-java") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /usr/share/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /usr/share/puppet/modules └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/upgrade/introducing_new_dependencies.rb b/acceptance/tests/modules/upgrade/introducing_new_dependencies.rb index 4974d744a..2dde1b472 100644 --- a/acceptance/tests/modules/upgrade/introducing_new_dependencies.rb +++ b/acceptance/tests/modules/upgrade/introducing_new_dependencies.rb @@ -1,46 +1,46 @@ begin test_name "puppet module upgrade (introducing new dependencies)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, <<-'MANIFEST1' file { '/usr/share/puppet': ensure => directory, } file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true, } MANIFEST1 on master, puppet("module install pmtacceptance-stdlib --version 1.0.0") on master, puppet("module install pmtacceptance-java --version 1.7.0") on master, puppet("module install pmtacceptance-postgresql --version 0.0.2") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-java (\e[0;36mv1.7.0\e[0m) ├── pmtacceptance-postgresql (\e[0;36mv0.0.2\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end step "Upgrade a module to a version that introduces new dependencies" on master, puppet("module upgrade pmtacceptance-postgresql") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-postgresql' ... Found 'pmtacceptance-postgresql' (\e[0;36mv0.0.2\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └─┬ pmtacceptance-postgresql (\e[0;36mv0.0.2 -> v1.0.0\e[0m) └── pmtacceptance-geordi (\e[0;36mv0.0.1\e[0m) OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/upgrade/not_upgradable.rb b/acceptance/tests/modules/upgrade/not_upgradable.rb index 781eb02b8..f6c526133 100644 --- a/acceptance/tests/modules/upgrade/not_upgradable.rb +++ b/acceptance/tests/modules/upgrade/not_upgradable.rb @@ -1,92 +1,92 @@ begin test_name "puppet module upgrade (not upgradable)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, <<-'MANIFEST1' file { '/usr/share/puppet': ensure => directory, } file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true, } MANIFEST1 apply_manifest_on master, <<-PP file { [ '/etc/puppet/modules/nginx', '/etc/puppet/modules/unicorns', ]: ensure => directory; '/etc/puppet/modules/unicorns/metadata.json': content => '{ "name": "notpmtacceptance/unicorns", "version": "0.0.3", "source": "", "author": "notpmtacceptance", "license": "MIT", "dependencies": [] }'; } PP on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules ├── nginx (\e[0;36m???\e[0m) ├── notpmtacceptance-unicorns (\e[0;36mv0.0.3\e[0m) ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end step "Try to upgrade a module that is not installed" on master, puppet("module upgrade pmtacceptance-nginx"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to upgrade 'pmtacceptance-nginx' ... STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-nginx' STDERR> Module 'pmtacceptance-nginx' is not installed STDERR> Use `puppet module install` to install this module\e[0m OUTPUT end step "Try to upgrade a local module" on master, puppet("module upgrade nginx"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to upgrade 'nginx' ... STDOUT> Found 'nginx' (\e[0;36m???\e[0m) in /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not upgrade module 'nginx' (??? -> latest) - STDERR> Module 'nginx' does not exist on http://forge.puppetlabs.com\e[0m + STDERR> Module 'nginx' does not exist on https://forge.puppetlabs.com\e[0m OUTPUT end step "Try to upgrade a module that doesn't exist" on master, puppet("module upgrade notpmtacceptance-unicorns"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to upgrade 'notpmtacceptance-unicorns' ... STDOUT> Found 'notpmtacceptance-unicorns' (\e[0;36mv0.0.3\e[0m) in /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not upgrade module 'notpmtacceptance-unicorns' (v0.0.3 -> latest) - STDERR> Module 'notpmtacceptance-unicorns' does not exist on http://forge.puppetlabs.com\e[0m + STDERR> Module 'notpmtacceptance-unicorns' does not exist on https://forge.puppetlabs.com\e[0m OUTPUT end step "Try to upgrade an installed module to a version that doesn't exist" on master, puppet("module upgrade pmtacceptance-java --version 2.0.0"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to upgrade 'pmtacceptance-java' ... STDOUT> Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-java' (v1.6.0 -> v2.0.0) - STDERR> No version matching '2.0.0' exists on http://forge.puppetlabs.com\e[0m + STDERR> No version matching '2.0.0' exists on https://forge.puppetlabs.com\e[0m OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/upgrade/that_was_installed_twice.rb b/acceptance/tests/modules/upgrade/that_was_installed_twice.rb index 36fd5df27..daba742dd 100644 --- a/acceptance/tests/modules/upgrade/that_was_installed_twice.rb +++ b/acceptance/tests/modules/upgrade/that_was_installed_twice.rb @@ -1,57 +1,57 @@ begin test_name "puppet module upgrade (that was installed twice)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, <<-'MANIFEST1' file { '/usr/share/puppet': ensure => directory, } file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true, } MANIFEST1 on master, puppet("module install pmtacceptance-java --version 1.6.0 --modulepath /etc/puppet/modules") on master, puppet("module install pmtacceptance-java --version 1.7.0 --modulepath /usr/share/puppet/modules") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules ├── pmtacceptance-java (\e[0;36mv1.7.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end step "Try to upgrade a module that exists multiple locations in the module path" on master, puppet("module upgrade pmtacceptance-java"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to upgrade 'pmtacceptance-java' ... STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-java' STDERR> Module 'pmtacceptance-java' appears multiple places in the module path STDERR> 'pmtacceptance-java' (v1.6.0) was found in /etc/puppet/modules STDERR> 'pmtacceptance-java' (v1.7.0) was found in /usr/share/puppet/modules STDERR> Use the `--modulepath` option to limit the search to specific directories\e[0m OUTPUT end step "Upgrade a module that exists multiple locations by restricting the --modulepath" on master, puppet("module upgrade pmtacceptance-java --modulepath /etc/puppet/modules") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/upgrade/to_a_specific_version.rb b/acceptance/tests/modules/upgrade/to_a_specific_version.rb index ae5a416ff..6d39a2bf1 100644 --- a/acceptance/tests/modules/upgrade/to_a_specific_version.rb +++ b/acceptance/tests/modules/upgrade/to_a_specific_version.rb @@ -1,54 +1,54 @@ begin test_name "puppet module upgrade (to a specific version)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, <<-'MANIFEST1' file { '/usr/share/puppet': ensure => directory, } file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true, } MANIFEST1 on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end step "Upgrade a module to a specific (greater) version" on master, puppet("module upgrade pmtacceptance-java --version 1.7.0") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.0\e[0m) OUTPUT end step "Upgrade a module to a specific (lesser) version" on master, puppet("module upgrade pmtacceptance-java --version 1.6.0") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.7.0\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-java (\e[0;36mv1.7.0 -> v1.6.0\e[0m) OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/upgrade/to_installed_version.rb b/acceptance/tests/modules/upgrade/to_installed_version.rb index b3a62071f..3bdfd5d70 100644 --- a/acceptance/tests/modules/upgrade/to_installed_version.rb +++ b/acceptance/tests/modules/upgrade/to_installed_version.rb @@ -1,91 +1,91 @@ begin test_name "puppet module upgrade (to installed version)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, <<-'MANIFEST1' file { '/usr/share/puppet': ensure => directory, } file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true, } MANIFEST1 on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end step "Try to upgrade a module to the current version" on master, puppet("module upgrade pmtacceptance-java --version 1.6.x"), :acceptable_exit_codes => [0] do assert_output <<-OUTPUT STDOUT> Preparing to upgrade 'pmtacceptance-java' ... STDOUT> Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-java' (v1.6.0 -> v1.6.x) STDERR> The installed version is already the best fit for the current dependencies STDERR> You specified 'pmtacceptance-java' (v1.6.x) STDERR> Use `puppet module install --force` to re-install this module\e[0m OUTPUT end step "Upgrade a module to the current version with --force" on master, puppet("module upgrade pmtacceptance-java --version 1.6.x --force") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.6.0\e[0m) OUTPUT end step "Upgrade to the latest version" on master, puppet("module upgrade pmtacceptance-java") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) OUTPUT end step "Try to upgrade a module to the latest version with the latest version installed" on master, puppet("module upgrade pmtacceptance-java"), :acceptable_exit_codes => [0] do assert_output <<-OUTPUT STDOUT> Preparing to upgrade 'pmtacceptance-java' ... STDOUT> Found 'pmtacceptance-java' (\e[0;36mv1.7.1\e[0m) in /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-java' (v1.7.1 -> latest: v1.7.1) STDERR> The installed version is already the latest version STDERR> Use `puppet module install --force` to re-install this module\e[0m OUTPUT end step "Upgrade a module to the latest version with --force" on master, puppet("module upgrade pmtacceptance-java --force") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.7.1\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-java (\e[0;36mv1.7.1 -> v1.7.1\e[0m) OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/upgrade/with_constraints_on_it.rb b/acceptance/tests/modules/upgrade/with_constraints_on_it.rb index 2d33fd339..4e29abac2 100644 --- a/acceptance/tests/modules/upgrade/with_constraints_on_it.rb +++ b/acceptance/tests/modules/upgrade/with_constraints_on_it.rb @@ -1,58 +1,58 @@ begin test_name "puppet module upgrade (with constraints on it)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, <<-'MANIFEST1' file { '/usr/share/puppet': ensure => directory, } file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true, } MANIFEST1 on master, puppet("module install pmtacceptance-java --version 1.7.0") on master, puppet("module install pmtacceptance-apollo") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-apollo (\e[0;36mv0.0.1\e[0m) ├── pmtacceptance-java (\e[0;36mv1.7.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end step "Upgrade a version-constrained module that has an upgrade" on master, puppet("module upgrade pmtacceptance-java") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.7.0\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-java (\e[0;36mv1.7.0 -> v1.7.1\e[0m) OUTPUT end step "Try to upgrade a version-constrained module that has no upgrade" on master, puppet("module upgrade pmtacceptance-stdlib"), :acceptable_exit_codes => [0] do assert_output <<-OUTPUT STDOUT> Preparing to upgrade 'pmtacceptance-stdlib' ... STDOUT> Found 'pmtacceptance-stdlib' (\e[0;36mv1.0.0\e[0m) in /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-stdlib' (v1.0.0 -> best: v1.0.0) STDERR> The installed version is already the best fit for the current dependencies STDERR> 'pmtacceptance-apollo' (v0.0.1) requires 'pmtacceptance-stdlib' (>= 1.0.0) STDERR> 'pmtacceptance-java' (v1.7.1) requires 'pmtacceptance-stdlib' (v1.0.0) STDERR> Use `puppet module install --force` to re-install this module\e[0m OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/upgrade/with_constraints_on_its_dependencies.rb b/acceptance/tests/modules/upgrade/with_constraints_on_its_dependencies.rb index d11fb3588..d03d6d3bd 100644 --- a/acceptance/tests/modules/upgrade/with_constraints_on_its_dependencies.rb +++ b/acceptance/tests/modules/upgrade/with_constraints_on_its_dependencies.rb @@ -1,100 +1,100 @@ begin test_name "puppet module upgrade (with constraints on its dependencies)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, <<-'MANIFEST1' file { '/usr/share/puppet': ensure => directory, } file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true, } MANIFEST1 apply_manifest_on master, <<-PP file { [ '/etc/puppet/modules/unicorns', ]: ensure => directory; '/etc/puppet/modules/unicorns/metadata.json': content => '{ "name": "notpmtacceptance/unicorns", "version": "0.0.3", "source": "", "author": "notpmtacceptance", "license": "MIT", "dependencies": [ { "name": "pmtacceptance/stdlib", "version_requirement": "0.0.2" } ] }'; } PP on master, puppet("module install pmtacceptance-stdlib --version 0.0.2") on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules ├── notpmtacceptance-unicorns (\e[0;36mv0.0.3\e[0m) ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv0.0.2\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end step "Try to upgrade a module with constraints on its dependencies that cannot be met" on master, puppet("module upgrade pmtacceptance-java"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to upgrade 'pmtacceptance-java' ... STDOUT> Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /etc/puppet/modules ... - STDOUT> Downloading from http://forge.puppetlabs.com ... + STDOUT> Downloading from https://forge.puppetlabs.com ... STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-java' (v1.6.0 -> latest: v1.7.1) STDERR> No version of 'pmtacceptance-stdlib' will satisfy dependencies STDERR> 'notpmtacceptance-unicorns' (v0.0.3) requires 'pmtacceptance-stdlib' (v0.0.2) STDERR> 'pmtacceptance-java' (v1.7.1) requires 'pmtacceptance-stdlib' (v1.0.0) STDERR> Use `puppet module upgrade --ignore-dependencies` to upgrade only this module\e[0m OUTPUT end step "Relax constraints" on master, puppet("module uninstall notpmtacceptance-unicorns") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv0.0.2\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end step "Upgrade a single module, ignoring its dependencies" on master, puppet("module upgrade pmtacceptance-java --version 1.7.0 --ignore-dependencies") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.0\e[0m) OUTPUT end step "Upgrade a module with constraints on its dependencies that can be met" on master, puppet("module upgrade pmtacceptance-java") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.7.0\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └─┬ pmtacceptance-java (\e[0;36mv1.7.0 -> v1.7.1\e[0m) └── pmtacceptance-stdlib (\e[0;36mv0.0.2 -> v1.0.0\e[0m) OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/upgrade/with_local_changes.rb b/acceptance/tests/modules/upgrade/with_local_changes.rb index 6d2f4a07d..4ec4e783c 100644 --- a/acceptance/tests/modules/upgrade/with_local_changes.rb +++ b/acceptance/tests/modules/upgrade/with_local_changes.rb @@ -1,63 +1,63 @@ begin test_name "puppet module upgrade (with local changes)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, <<-'MANIFEST1' file { '/usr/share/puppet': ensure => directory, } file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true, } MANIFEST1 on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end apply_manifest_on master, <<-PP file { '/etc/puppet/modules/java/README': content => "I CHANGE MY READMES"; '/etc/puppet/modules/java/NEWFILE': content => "I don't exist.'"; } PP step "Try to upgrade a module with local changes" on master, puppet("module upgrade pmtacceptance-java"), :acceptable_exit_codes => [1] do assert_output <<-OUTPUT STDOUT> Preparing to upgrade 'pmtacceptance-java' ... STDOUT> Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /etc/puppet/modules ... STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-java' (v1.6.0 -> latest) STDERR> Installed module has had changes made locally STDERR> Use `puppet module upgrade --force` to upgrade this module anyway\e[0m OUTPUT end on master, '[[ "$(cat /etc/puppet/modules/java/README)" == "I CHANGE MY READMES" ]]' on master, '[ -f /etc/puppet/modules/java/NEWFILE ]' step "Upgrade a module with local changes with --force" on master, puppet("module upgrade pmtacceptance-java --force") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) OUTPUT end on master, '[[ "$(cat /etc/puppet/modules/java/README)" != "I CHANGE MY READMES" ]]' on master, '[ ! -f /etc/puppet/modules/java/NEWFILE ]' ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/upgrade/with_scattered_dependencies.rb b/acceptance/tests/modules/upgrade/with_scattered_dependencies.rb index 29526fe5b..a50218e18 100644 --- a/acceptance/tests/modules/upgrade/with_scattered_dependencies.rb +++ b/acceptance/tests/modules/upgrade/with_scattered_dependencies.rb @@ -1,48 +1,48 @@ begin test_name "puppet module upgrade (with scattered dependencies)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, <<-'MANIFEST1' file { '/usr/share/puppet': ensure => directory, } file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true, } MANIFEST1 on master, puppet("module install pmtacceptance-stdlib --version 0.0.2 --target-dir /usr/share/puppet/modules") on master, puppet("module install pmtacceptance-java --version 1.6.0 --target-dir /etc/puppet/modules --ignore-dependencies") on master, puppet("module install pmtacceptance-postgresql --version 0.0.1 --target-dir /etc/puppet/modules --ignore-dependencies") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-postgresql (\e[0;36mv0.0.1\e[0m) /usr/share/puppet/modules └── pmtacceptance-stdlib (\e[0;36mv0.0.2\e[0m) OUTPUT end step "Upgrade a module that has a more recent version published" on master, puppet("module upgrade pmtacceptance-postgresql --version 0.0.2") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-postgresql' ... Found 'pmtacceptance-postgresql' (\e[0;36mv0.0.1\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └─┬ pmtacceptance-postgresql (\e[0;36mv0.0.1 -> v0.0.2\e[0m) ├─┬ pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.0\e[0m) │ └── pmtacceptance-stdlib (\e[0;36mv0.0.2 -> v1.0.0\e[0m) [/usr/share/puppet/modules] └── pmtacceptance-stdlib (\e[0;36mv0.0.2 -> v1.0.0\e[0m) [/usr/share/puppet/modules] OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/acceptance/tests/modules/upgrade/with_update_available.rb b/acceptance/tests/modules/upgrade/with_update_available.rb index 5a315e8c1..08dd41b5d 100644 --- a/acceptance/tests/modules/upgrade/with_update_available.rb +++ b/acceptance/tests/modules/upgrade/with_update_available.rb @@ -1,42 +1,42 @@ begin test_name "puppet module upgrade (with update available)" step 'Setup' require 'resolv'; ip = Resolv.getaddress('forge-dev.puppetlabs.lan') apply_manifest_on master, "host { 'forge.puppetlabs.com': ip => '#{ip}' }" apply_manifest_on master, <<-'MANIFEST1' file { '/usr/share/puppet': ensure => directory, } file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true, } MANIFEST1 on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list") do assert_output <<-OUTPUT /etc/puppet/modules ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) /usr/share/puppet/modules (no modules installed) OUTPUT end step "Upgrade a module that has a more recent version published" on master, puppet("module upgrade pmtacceptance-java") do assert_output <<-OUTPUT Preparing to upgrade 'pmtacceptance-java' ... Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[0m) in /etc/puppet/modules ... - Downloading from http://forge.puppetlabs.com ... + Downloading from https://forge.puppetlabs.com ... Upgrading -- do not interrupt ... /etc/puppet/modules └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) OUTPUT end ensure step "Teardown" apply_manifest_on master, "host { 'forge.puppetlabs.com': ensure => absent }" apply_manifest_on master, "file { ['/etc/puppet/modules', '/usr/share/puppet/modules']: ensure => directory, recurse => true, purge => true, force => true }" end diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 02893ebba..b2f99b356 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -1,1495 +1,1495 @@ # The majority of Puppet's configuration settings are set in this file. module Puppet ############################################################################################ # NOTE: For information about the available values for the ":type" property of settings, # see the docs for Settings.define_settings ############################################################################################ define_settings(:main, :confdir => { :default => nil, :type => :directory, :desc => "The main Puppet configuration directory. The default for this setting is calculated based on the user. If the process\n" + "is running as root or the user that Puppet is supposed to run as, it defaults to a system directory, but if it's running as any other user,\n" + "it defaults to being in the user's home directory.", }, :vardir => { :default => nil, :type => :directory, :desc => "Where Puppet stores dynamic and growing data. The default for this setting is calculated specially, like `confdir`_.", }, ### NOTE: this setting is usually being set to a symbol value. We don't officially have a ### setting type for that yet, but we might want to consider creating one. :name => { :default => nil, :desc => "The name of the application, if we are running as one. The\n" + "default is essentially $0 without the path or `.rb`.", }, ## This setting needs to go away. As a first step, we could just make it a first-class property of the Settings ## class, instead of treating it as a normal setting. There are places where the Settings class tries to use ## the value of run_mode to help in resolving other values, and that is no good for nobody. It would cause ## infinite recursion and stack overflows without some chicanery... so, it needs to be cleaned up. ## ## As a longer term goal I think we should be looking into getting rid of run_mode altogether, but that is going ## to be a larger undertaking, as it is being branched on in a lot of places in the current code. ## ## --cprice 2012-03-16 :run_mode => { :default => nil, :desc => "The effective 'run mode' of the application: master, agent, or user.", } ) define_settings(:main, :logdir => { :default => nil, :type => :directory, :mode => 0750, :owner => "service", :group => "service", :desc => "The directory in which to store log files", } ) define_settings(:main, :trace => { :default => false, :type => :boolean, :desc => "Whether to print stack traces on some errors", }, :autoflush => { :default => true, :type => :boolean, :desc => "Whether log files should always flush to disk.", :hook => proc { |value| Log.autoflush = value } }, :syslogfacility => { :default => "daemon", :desc => "What syslog facility to use when logging to\n" + "syslog. Syslog has a fixed list of valid facilities, and you must\n" + "choose one of those; you cannot just make one up." }, :statedir => { :default => "$vardir/state", :type => :directory, :mode => 01755, :desc => "The directory where Puppet state is stored. Generally, this directory can be removed without causing harm (although it might result in spurious service restarts)." }, :rundir => { :default => nil, :type => :directory, :mode => 01777, :desc => "Where Puppet PID files are kept." }, :genconfig => { :default => false, :type => :boolean, :desc => "Whether to just print a configuration to stdout and exit. Only makes\n" + "sense when used interactively. Takes into account arguments specified\n" + "on the CLI.", }, :genmanifest => { :default => false, :type => :boolean, :desc => "Whether to just print a manifest to stdout and exit. Only makes\n" + "sense when used interactively. Takes into account arguments specified\n" + "on the CLI.", }, :configprint => { :default => "", :desc => "Print the value of a specific configuration setting. If the name of a\n" + "setting is provided for this, then the value is printed and puppet\n" + "exits. Comma-separate multiple values. For a list of all values,\n" + "specify 'all'.", }, :color => { :default => "ansi", :type => :string, :desc => "Whether to use colors when logging to the console. Valid values are\n" + "`ansi` (equivalent to `true`), `html`, and `false`, which produces no color.\n" + "Defaults to false on Windows, as its console does not support ansi colors.", }, :mkusers => { :default => false, :type => :boolean, :desc => "Whether to create the necessary user and group that puppet agent will run as.", }, :manage_internal_file_permissions => { :default => true, :type => :boolean, :desc => "Whether Puppet should manage the owner, group, and mode of files it uses internally", }, :onetime => { :default => false, :type => :boolean, :desc => "Run the configuration once, rather than as a long-running\n" + "daemon. This is useful for interactively running puppetd.", :short => 'o', }, :path => { :default => "none", :desc => "The shell search path. Defaults to whatever is inherited\n" + "from the parent process.", :call_hook => :on_define_and_write, :hook => proc do |value| ENV["PATH"] = "" if ENV["PATH"].nil? ENV["PATH"] = value unless value == "none" paths = ENV["PATH"].split(File::PATH_SEPARATOR) %w{/usr/sbin /sbin}.each do |path| ENV["PATH"] += File::PATH_SEPARATOR + path unless paths.include?(path) end value end }, :libdir => { :type => :directory, :default => "$vardir/lib", :desc => "An extra search path for Puppet. This is only useful\n" + "for those files that Puppet will load on demand, and is only\n" + "guaranteed to work for those cases. In fact, the autoload\n" + "mechanism is responsible for making sure this directory\n" + "is in Ruby's search path\n", :call_hook => :on_initialize_and_write, :hook => proc do |value| $LOAD_PATH.delete(@oldlibdir) if defined?(@oldlibdir) and $LOAD_PATH.include?(@oldlibdir) @oldlibdir = value $LOAD_PATH << value end }, :ignoreimport => { :default => false, :type => :boolean, :desc => "If true, allows the parser to continue without requiring\n" + "all files referenced with `import` statements to exist. This setting was primarily\n" + "designed for use with commit hooks for parse-checking.", }, :authconfig => { :default => "$confdir/namespaceauth.conf", :desc => "The configuration file that defines the rights to the different\n" + "namespaces and methods. This can be used as a coarse-grained\n" + "authorization system for both `puppet agent` and `puppet master`.", }, :environment => { :default => "production", :desc => "The environment Puppet is running in. For clients\n" + "(e.g., `puppet agent`) this determines the environment itself, which\n" + "is used to find modules and much more. For servers (i.e., `puppet master`)\n" + "this provides the default environment for nodes we know nothing about." }, :diff_args => { :default => "-u", :desc => "Which arguments to pass to the diff command when printing differences between\n" + "files. The command to use can be chosen with the `diff` setting.", }, :diff => { :default => (Puppet.features.microsoft_windows? ? "" : "diff"), :desc => "Which diff command to use when printing differences between files. This setting\n" + "has no default value on Windows, as standard `diff` is not available, but Puppet can use many\n" + "third-party diff tools.", }, :show_diff => { :type => :boolean, :default => false, :desc => "Whether to log and report a contextual diff when files are being replaced. This causes\n" + "partial file contents to pass through Puppet's normal logging and reporting system, so this setting\n" + "should be used with caution if you are sending Puppet's reports to an insecure destination.\n" + "This feature currently requires the `diff/lcs` Ruby library.", }, :daemonize => { :type => :boolean, :default => (Puppet.features.microsoft_windows? ? false : true), :desc => "Whether to send the process into the background. This defaults to true on POSIX systems, and to false on Windows (where Puppet currently cannot daemonize).", :short => "D", :hook => proc do |value| if value and Puppet.features.microsoft_windows? raise "Cannot daemonize on Windows" end end }, :maximum_uid => { :default => 4294967290, :desc => "The maximum allowed UID. Some platforms use negative UIDs\n" + "but then ship with tools that do not know how to handle signed ints, so the UIDs show up as\n" + "huge numbers that can then not be fed back into the system. This is a hackish way to fail in a\n" + "slightly more useful way when that happens.", }, :route_file => { :default => "$confdir/routes.yaml", :desc => "The YAML file containing indirector route configuration.", }, :node_terminus => { :default => "plain", :desc => "Where to find information about nodes.", }, :data_binding_terminus => { :default => "hiera", :desc => "Where to retrive information about data.", }, :hiera_config => { :default => "$confdir/hiera.yaml", :desc => "The hiera configuration file", :type => :file, }, :catalog_terminus => { :default => "compiler", :desc => "Where to get node catalogs. This is useful to change if, for instance, you'd like to pre-compile catalogs and store them in memcached or some other easily-accessed store.", }, :facts_terminus => { :default => 'facter', :desc => "The node facts terminus.", :hook => proc do |value| require 'puppet/node/facts' # Cache to YAML if we're uploading facts away if %w[rest inventory_service].include? value.to_s Puppet::Node::Facts.indirection.cache_class = :yaml end end }, :inventory_terminus => { :default => "$facts_terminus", :desc => "Should usually be the same as the facts terminus", }, :default_file_terminus => { :default => "rest", :desc => "The default source for files if no server is given in a uri, e.g. puppet:///file. The default of `rest` causes the file to be retrieved using the `server` setting. When running `apply` the default is `file_server`, causing requests to be filled locally." }, :httplog => { :default => "$logdir/http.log", :type => :file, :owner => "root", :mode => 0640, :desc => "Where the puppet agent web server logs.", }, :http_proxy_host => { :default => "none", :desc => "The HTTP proxy host to use for outgoing connections. Note: You may need to use a FQDN for the server hostname when using a proxy.", }, :http_proxy_port => { :default => 3128, :desc => "The HTTP proxy port to use for outgoing connections", }, :filetimeout => { :default => 15, :desc => "The minimum time to wait (in seconds) between checking for updates in configuration files. This timeout determines how quickly Puppet checks whether a file (such as manifests or templates) has changed on disk.", }, :queue_type => { :default => "stomp", :desc => "Which type of queue to use for asynchronous processing.", }, :queue_type => { :default => "stomp", :desc => "Which type of queue to use for asynchronous processing.", }, :queue_source => { :default => "stomp://localhost:61613/", :desc => "Which type of queue to use for asynchronous processing. If your stomp server requires authentication, you can include it in the URI as long as your stomp client library is at least 1.1.1", }, :async_storeconfigs => { :default => false, :type => :boolean, :desc => "Whether to use a queueing system to provide asynchronous database integration. Requires that `puppet queue` be running and that 'PSON' support for ruby be installed.", :hook => proc do |value| if value # This reconfigures the terminii for Node, Facts, and Catalog Puppet.settings[:storeconfigs] = true # But then we modify the configuration Puppet::Resource::Catalog.indirection.cache_class = :queue else raise "Cannot disable asynchronous storeconfigs in a running process" end end }, :thin_storeconfigs => { :default => false, :type => :boolean, :desc => "Boolean; whether storeconfigs store in the database only the facts and exported resources. If true, then storeconfigs performance will be higher and still allow exported/collected resources, but other usage external to Puppet might not work", :hook => proc do |value| Puppet.settings[:storeconfigs] = true if value end }, :config_version => { :default => "", :desc => "How to determine the configuration version. By default, it will be the time that the configuration is parsed, but you can provide a shell script to override how the version is determined. The output of this script will be added to every log message in the reports, allowing you to correlate changes on your hosts to the source version on the server.", }, :zlib => { :default => true, :type => :boolean, :desc => "Boolean; whether to use the zlib library", }, :prerun_command => { :default => "", :desc => "A command to run before every agent run. If this command returns a non-zero return code, the entire Puppet run will fail.", }, :postrun_command => { :default => "", :desc => "A command to run after every agent run. If this command returns a non-zero return code, the entire Puppet run will be considered to have failed, even though it might have performed work during the normal run.", }, :freeze_main => { :default => false, :type => :boolean, :desc => "Freezes the 'main' class, disallowing any code to be added to it. This\n" + "essentially means that you can't have any code outside of a node, class, or definition other\n" + "than in the site manifest.", } ) Puppet.define_settings(:module_tool, :module_repository => { - :default => 'http://forge.puppetlabs.com', + :default => 'https://forge.puppetlabs.com', :desc => "The module repository", }, :module_working_dir => { :default => '$vardir/puppet-module', :desc => "The directory into which module tool data is stored", } ) Puppet.define_settings( :main, # We have to downcase the fqdn, because the current ssl stuff (as oppsed to in master) doesn't have good facilities for # manipulating naming. :certname => { :default => Puppet::Settings.default_certname.downcase, :desc => "The name to use when handling certificates. Defaults to the fully qualified domain name.", :call_hook => :on_define_and_write, # Call our hook with the default value, so we're always downcased :hook => proc { |value| raise(ArgumentError, "Certificate names must be lower case; see #1168") unless value == value.downcase }}, :certdnsnames => { :default => '', :hook => proc do |value| unless value.nil? or value == '' then Puppet.warning < < { :default => '', :desc => < { :default => "$ssldir/certs", :type => :directory, :owner => "service", :desc => "The certificate directory." }, :ssldir => { :default => "$confdir/ssl", :type => :directory, :mode => 0771, :owner => "service", :desc => "Where SSL certificates are kept." }, :publickeydir => { :default => "$ssldir/public_keys", :type => :directory, :owner => "service", :desc => "The public key directory." }, :requestdir => { :default => "$ssldir/certificate_requests", :type => :directory, :owner => "service", :desc => "Where host certificate requests are stored." }, :privatekeydir => { :default => "$ssldir/private_keys", :type => :directory, :mode => 0750, :owner => "service", :desc => "The private key directory." }, :privatedir => { :default => "$ssldir/private", :type => :directory, :mode => 0750, :owner => "service", :desc => "Where the client stores private certificate information." }, :passfile => { :default => "$privatedir/password", :type => :file, :mode => 0640, :owner => "service", :desc => "Where puppet agent stores the password for its private key. Generally unused." }, :hostcsr => { :default => "$ssldir/csr_$certname.pem", :type => :file, :mode => 0644, :owner => "service", :desc => "Where individual hosts store and look for their certificate requests." }, :hostcert => { :default => "$certdir/$certname.pem", :type => :file, :mode => 0644, :owner => "service", :desc => "Where individual hosts store and look for their certificates." }, :hostprivkey => { :default => "$privatekeydir/$certname.pem", :type => :file, :mode => 0600, :owner => "service", :desc => "Where individual hosts store and look for their private key." }, :hostpubkey => { :default => "$publickeydir/$certname.pem", :type => :file, :mode => 0644, :owner => "service", :desc => "Where individual hosts store and look for their public key." }, :localcacert => { :default => "$certdir/ca.pem", :type => :file, :mode => 0644, :owner => "service", :desc => "Where each client stores the CA certificate." }, :hostcrl => { :default => "$ssldir/crl.pem", :type => :file, :mode => 0644, :owner => "service", :desc => "Where the host's certificate revocation list can be found. This is distinct from the certificate authority's CRL." }, :certificate_revocation => { :default => true, :type => :boolean, :desc => "Whether certificate revocation should be supported by downloading a Certificate Revocation List (CRL) to all clients. If enabled, CA chaining will almost definitely not work.", } ) define_settings( :ca, :ca_name => { :default => "Puppet CA: $certname", :desc => "The name to use the Certificate Authority certificate.", }, :cadir => { :default => "$ssldir/ca", :type => :directory, :owner => "service", :group => "service", :mode => 0770, :desc => "The root directory for the certificate authority." }, :cacert => { :default => "$cadir/ca_crt.pem", :type => :file, :owner => "service", :group => "service", :mode => 0660, :desc => "The CA certificate." }, :cakey => { :default => "$cadir/ca_key.pem", :type => :file, :owner => "service", :group => "service", :mode => 0660, :desc => "The CA private key." }, :capub => { :default => "$cadir/ca_pub.pem", :type => :file, :owner => "service", :group => "service", :desc => "The CA public key." }, :cacrl => { :default => "$cadir/ca_crl.pem", :type => :file, :owner => "service", :group => "service", :mode => 0664, :desc => "The certificate revocation list (CRL) for the CA. Will be used if present but otherwise ignored.", :hook => proc do |value| if value == 'false' Puppet.deprecation_warning "Setting the :cacrl to 'false' is deprecated; Puppet will just ignore the crl if yours is missing" end end }, :caprivatedir => { :default => "$cadir/private", :type => :directory, :owner => "service", :group => "service", :mode => 0770, :desc => "Where the CA stores private certificate information." }, :csrdir => { :default => "$cadir/requests", :type => :directory, :owner => "service", :group => "service", :desc => "Where the CA stores certificate requests" }, :signeddir => { :default => "$cadir/signed", :type => :directory, :owner => "service", :group => "service", :mode => 0770, :desc => "Where the CA stores signed certificates." }, :capass => { :default => "$caprivatedir/ca.pass", :type => :file, :owner => "service", :group => "service", :mode => 0660, :desc => "Where the CA stores the password for the private key" }, :serial => { :default => "$cadir/serial", :type => :file, :owner => "service", :group => "service", :mode => 0644, :desc => "Where the serial number for certificates is stored." }, :autosign => { :default => "$confdir/autosign.conf", :type => :file, :mode => 0644, :desc => "Whether to enable autosign. Valid values are true (which autosigns any key request, and is a very bad idea), false (which never autosigns any key request), and the path to a file, which uses that configuration file to determine which keys to sign."}, :allow_duplicate_certs => { :default => false, :type => :boolean, :desc => "Whether to allow a new certificate request to overwrite an existing certificate.", }, :ca_days => { :default => "", :desc => "How long a certificate should be valid, in days. This setting is deprecated; use `ca_ttl` instead", }, :ca_ttl => { :default => "5y", :desc => "The default TTL for new certificates; valid values must be an integer, optionally followed by one of the units 'y' (years of 365 days), 'd' (days), 'h' (hours), or 's' (seconds). The unit defaults to seconds. If this setting is set, ca_days is ignored. Examples are '3600' (one hour) and '1825d', which is the same as '5y' (5 years) ", }, :ca_md => { :default => "md5", :desc => "The type of hash used in certificates.", }, :req_bits => { :default => 4096, :desc => "The bit length of the certificates.", }, :keylength => { :default => 4096, :desc => "The bit length of keys.", }, :cert_inventory => { :default => "$cadir/inventory.txt", :type => :file, :mode => 0644, :owner => "service", :group => "service", :desc => "A Complete listing of all certificates" } ) # Define the config default. define_settings(:application, :config_file_name => { :type => :string, :default => Puppet::Settings.default_config_file_name, :desc => "The name of the puppet config file.", }, :config => { :type => :file, :default => "$confdir/${config_file_name}", :desc => "The configuration file for the current puppet application", }, :pidfile => { :type => :file, :default => "$rundir/${run_mode}.pid", :desc => "The pid file", }, :bindaddress => { :default => "", :desc => "The address a listening server should bind to. Mongrel servers default to 127.0.0.1 and WEBrick defaults to 0.0.0.0.", }, :servertype => { :default => "webrick", :desc => "The type of server to use. Currently supported options are webrick and mongrel. If you use mongrel, you will need a proxy in front of the process or processes, since Mongrel cannot speak SSL.", :call_hook => :on_define_and_write, # Call our hook with the default value, so we always get the correct bind address set. :hook => proc { |value| value == "webrick" ? Puppet.settings[:bindaddress] = "0.0.0.0" : Puppet.settings[:bindaddress] = "127.0.0.1" if Puppet.settings[:bindaddress] == "" } } ) define_settings(:master, :user => { :default => "puppet", :desc => "The user puppet master should run as.", }, :group => { :default => "puppet", :desc => "The group puppet master should run as.", }, :manifestdir => { :default => "$confdir/manifests", :type => :directory, :desc => "Where puppet master looks for its manifests.", }, :manifest => { :default => "$manifestdir/site.pp", :type => :file, :desc => "The entry-point manifest for puppet master.", }, :code => { :default => "", :desc => "Code to parse directly. This is essentially only used by `puppet`, and should only be set if you're writing your own Puppet executable", }, :masterlog => { :default => "$logdir/puppetmaster.log", :type => :file, :owner => "service", :group => "service", :mode => 0660, :desc => "Where puppet master logs. This is generally not used, since syslog is the default log destination." }, :masterhttplog => { :default => "$logdir/masterhttp.log", :type => :file, :owner => "service", :group => "service", :mode => 0660, :create => true, :desc => "Where the puppet master web server logs." }, :masterport => { :default => 8140, :desc => "Which port puppet master listens on.", }, :node_name => { :default => "cert", :desc => "How the puppet master determines the client's identity and sets the 'hostname', 'fqdn' and 'domain' facts for use in the manifest, in particular for determining which 'node' statement applies to the client. Possible values are 'cert' (use the subject's CN in the client's certificate) and 'facter' (use the hostname that the client reported in its facts)", }, :bucketdir => { :default => "$vardir/bucket", :type => :directory, :mode => 0750, :owner => "service", :group => "service", :desc => "Where FileBucket files are stored." }, :rest_authconfig => { :default => "$confdir/auth.conf", :type => :file, :desc => "The configuration file that defines the rights to the different rest indirections. This can be used as a fine-grained authorization system for `puppet master`.", }, :ca => { :default => true, :type => :boolean, :desc => "Whether the master should function as a certificate authority.", }, :modulepath => { :default => "$confdir/modules#{File::PATH_SEPARATOR}/usr/share/puppet/modules", :type => :path, :desc => "The search path for modules, as a list of directories separated by the system path separator character. " + "(The POSIX path separator is ':', and the Windows path separator is ';'.)", }, :ssl_client_header => { :default => "HTTP_X_CLIENT_DN", :desc => "The header containing an authenticated client's SSL DN. Only used with Mongrel. This header must be set by the proxy to the authenticated client's SSL DN (e.g., `/CN=puppet.puppetlabs.com`). See http://projects.puppetlabs.com/projects/puppet/wiki/Using_Mongrel for more information.", }, :ssl_client_verify_header => { :default => "HTTP_X_CLIENT_VERIFY", :desc => "The header containing the status message of the client verification. Only used with Mongrel. This header must be set by the proxy to 'SUCCESS' if the client successfully authenticated, and anything else otherwise. See http://projects.puppetlabs.com/projects/puppet/wiki/Using_Mongrel for more information.", }, # To make sure this directory is created before we try to use it on the server, we need # it to be in the server section (#1138). :yamldir => { :default => "$vardir/yaml", :type => :directory, :owner => "service", :group => "service", :mode => "750", :desc => "The directory in which YAML data is stored, usually in a subdirectory."}, :server_datadir => { :default => "$vardir/server_data", :type => :directory, :owner => "service", :group => "service", :mode => "750", :desc => "The directory in which serialized data is stored, usually in a subdirectory."}, :reports => { :default => "store", :desc => "The list of reports to generate. All reports are looked for in `puppet/reports/name.rb`, and multiple report names should be comma-separated (whitespace is okay).", }, :reportdir => { :default => "$vardir/reports", :type => :directory, :mode => 0750, :owner => "service", :group => "service", :desc => "The directory in which to store reports received from the client. Each client gets a separate subdirectory."}, :reporturl => { :default => "http://localhost:3000/reports/upload", :desc => "The URL used by the http reports processor to send reports", }, :fileserverconfig => { :default => "$confdir/fileserver.conf", :type => :file, :desc => "Where the fileserver configuration is stored.", }, :strict_hostname_checking => { :default => false, :desc => "Whether to only search for the complete hostname as it is in the certificate when searching for node information in the catalogs.", } ) define_settings(:metrics, :rrddir => { :type => :directory, :default => "$vardir/rrd", :mode => 0750, :owner => "service", :group => "service", :desc => "The directory where RRD database files are stored. Directories for each reporting host will be created under this directory." }, :rrdinterval => { :default => "$runinterval", :desc => "How often RRD should expect data. This should match how often the hosts report back to the server.", } ) define_settings(:device, :devicedir => { :default => "$vardir/devices", :type => :directory, :mode => "750", :desc => "The root directory of devices' $vardir", }, :deviceconfig => { :default => "$confdir/device.conf", :desc => "Path to the device config file for puppet device", } ) define_settings(:agent, :node_name_value => { :default => "$certname", :desc => "The explicit value used for the node name for all requests the agent makes to the master. WARNING: This setting is mutually exclusive with node_name_fact. Changing this setting also requires changes to the default auth.conf configuration on the Puppet Master. Please see http://links.puppetlabs.com/node_name_value for more information." }, :node_name_fact => { :default => "", :desc => "The fact name used to determine the node name used for all requests the agent makes to the master. WARNING: This setting is mutually exclusive with node_name_value. Changing this setting also requires changes to the default auth.conf configuration on the Puppet Master. Please see http://links.puppetlabs.com/node_name_fact for more information.", :hook => proc do |value| if !value.empty? and Puppet[:node_name_value] != Puppet[:certname] raise "Cannot specify both the node_name_value and node_name_fact settings" end end }, :localconfig => { :default => "$statedir/localconfig", :type => :file, :owner => "root", :mode => 0660, :desc => "Where puppet agent caches the local configuration. An extension indicating the cache format is added automatically."}, :statefile => { :default => "$statedir/state.yaml", :type => :file, :mode => 0660, :desc => "Where puppet agent and puppet master store state associated with the running configuration. In the case of puppet master, this file reflects the state discovered through interacting with clients." }, :clientyamldir => { :default => "$vardir/client_yaml", :type => :directory, :mode => "750", :desc => "The directory in which client-side YAML data is stored." }, :client_datadir => { :default => "$vardir/client_data", :type => :directory, :mode => "750", :desc => "The directory in which serialized data is stored on the client." }, :classfile => { :default => "$statedir/classes.txt", :type => :file, :owner => "root", :mode => 0644, :desc => "The file in which puppet agent stores a list of the classes associated with the retrieved configuration. Can be loaded in the separate `puppet` executable using the `--loadclasses` option."}, :resourcefile => { :default => "$statedir/resources.txt", :type => :file, :owner => "root", :mode => 0644, :desc => "The file in which puppet agent stores a list of the resources associated with the retrieved configuration." }, :puppetdlog => { :default => "$logdir/puppetd.log", :type => :file, :owner => "root", :mode => 0640, :desc => "The log file for puppet agent. This is generally not used." }, :server => { :default => "puppet", :desc => "The server to which the puppet agent should connect" }, :use_srv_records => { :default => false, :type => :boolean, :desc => "Whether the server will search for SRV records in DNS for the current domain.", }, :srv_domain => { :default => "#{Puppet::Settings.domain_fact}", :desc => "The domain which will be queried to find the SRV records of servers to use.", }, :ignoreschedules => { :default => false, :type => :boolean, :desc => "Boolean; whether puppet agent should ignore schedules. This is useful for initial puppet agent runs.", }, :puppetport => { :default => 8139, :desc => "Which port puppet agent listens on.", }, :noop => { :default => false, :type => :boolean, :desc => "Whether puppet agent should be run in noop mode.", }, :runinterval => { :default => 1800, # 30 minutes :desc => "How often puppet agent applies the client configuration; in seconds. Note that a runinterval of 0 means \"run continuously\" rather than \"never run.\" If you want puppet agent to never run, you should start it with the `--no-client` option.", }, :listen => { :default => false, :type => :boolean, :desc => "Whether puppet agent should listen for connections. If this is true, then puppet agent will accept incoming REST API requests, subject to the default ACLs and the ACLs set in the `rest_authconfig` file. Puppet agent can respond usefully to requests on the `run`, `facts`, `certificate`, and `resource` endpoints.", }, :ca_server => { :default => "$server", :desc => "The server to use for certificate authority requests. It's a separate server because it cannot and does not need to horizontally scale.", }, :ca_port => { :default => "$masterport", :desc => "The port to use for the certificate authority.", }, :catalog_format => { :default => "", :desc => "(Deprecated for 'preferred_serialization_format') What format to use to dump the catalog. Only supports 'marshal' and 'yaml'. Only matters on the client, since it asks the server for a specific format.", :hook => proc { |value| if value Puppet.deprecation_warning "Setting 'catalog_format' is deprecated; use 'preferred_serialization_format' instead." Puppet.settings[:preferred_serialization_format] = value end } }, :preferred_serialization_format => { :default => "pson", :desc => "The preferred means of serializing ruby instances for passing over the wire. This won't guarantee that all instances will be serialized using this method, since not all classes can be guaranteed to support this format, but it will be used for all classes that support it.", }, :agent_pidfile => { :default => "$statedir/agent.pid", :type => :file, :desc => "A lock file to indicate that a puppet agent run is currently in progress. File contains the pid of the running process.", }, :agent_disabled_lockfile => { :default => "$statedir/agent_disabled.lock", :type => :file, :desc => "A lock file to indicate that puppet agent runs have been administratively disabled. File contains a JSON object with state information.", }, :usecacheonfailure => { :default => true, :type => :boolean, :desc => "Whether to use the cached configuration when the remote configuration will not compile. This option is useful for testing new configurations, where you want to fix the broken configuration rather than reverting to a known-good one.", }, :use_cached_catalog => { :default => false, :type => :boolean, :desc => "Whether to only use the cached catalog rather than compiling a new catalog on every run. Puppet can be run with this enabled by default and then selectively disabled when a recompile is desired.", }, :ignorecache => { :default => false, :type => :boolean, :desc => "Ignore cache and always recompile the configuration. This is useful for testing new configurations, where the local cache may in fact be stale even if the timestamps are up to date - if the facts change or if the server changes.", }, :downcasefacts => { :default => false, :type => :boolean, :desc => "Whether facts should be made all lowercase when sent to the server.", }, :dynamicfacts => { :default => "memorysize,memoryfree,swapsize,swapfree", :desc => "Facts that are dynamic; these facts will be ignored when deciding whether changed facts should result in a recompile. Multiple facts should be comma-separated.", }, :splaylimit => { :default => "$runinterval", :desc => "The maximum time to delay before runs. Defaults to being the same as the run interval.", }, :splay => { :default => false, :type => :boolean, :desc => "Whether to sleep for a pseudo-random (but consistent) amount of time before a run.", }, :clientbucketdir => { :default => "$vardir/clientbucket", :type => :directory, :mode => 0750, :desc => "Where FileBucket files are stored locally." }, :configtimeout => { :default => 120, :desc => "How long the client should wait for the configuration to be retrieved before considering it a failure. This can help reduce flapping if too many clients contact the server at one time.", }, :reportserver => { :default => "$server", :call_hook => :on_write_only, :desc => "(Deprecated for 'report_server') The server to which to send transaction reports.", :hook => proc do |value| Puppet.settings[:report_server] = value if value end }, :report_server => { :default => "$server", :desc => "The server to send transaction reports to.", }, :report_port => { :default => "$masterport", :desc => "The port to communicate with the report_server.", }, :inventory_server => { :default => "$server", :desc => "The server to send facts to.", }, :inventory_port => { :default => "$masterport", :desc => "The port to communicate with the inventory_server.", }, :report => { :default => true, :type => :boolean, :desc => "Whether to send reports after every transaction.", }, :lastrunfile => { :default => "$statedir/last_run_summary.yaml", :type => :file, :mode => 0644, :desc => "Where puppet agent stores the last run report summary in yaml format." }, :lastrunreport => { :default => "$statedir/last_run_report.yaml", :type => :file, :mode => 0644, :desc => "Where puppet agent stores the last run report in yaml format." }, :graph => { :default => false, :type => :boolean, :desc => "Whether to create dot graph files for the different configuration graphs. These dot files can be interpreted by tools like OmniGraffle or dot (which is part of ImageMagick).", }, :graphdir => { :default => "$statedir/graphs", :type => :directory, :desc => "Where to store dot-outputted graphs.", }, :http_compression => { :default => false, :type => :boolean, :desc => "Allow http compression in REST communication with the master. This setting might improve performance for agent -> master communications over slow WANs. Your puppet master needs to support compression (usually by activating some settings in a reverse-proxy in front of the puppet master, which rules out webrick). It is harmless to activate this settings if your master doesn't support compression, but if it supports it, this setting might reduce performance on high-speed LANs.", }, :waitforcert => { :default => 120, # 2 minutes :desc => "The time interval, specified in seconds, 'puppet agent' should connect to the server and ask it to sign a certificate request. This is useful for the initial setup of a puppet client. You can turn off waiting for certificates by specifying a time of 0.", } ) define_settings(:inspect, :archive_files => { :type => :boolean, :default => false, :desc => "During an inspect run, whether to archive files whose contents are audited to a file bucket.", }, :archive_file_server => { :default => "$server", :desc => "During an inspect run, the file bucket server to archive files to if archive_files is set.", } ) # Plugin information. define_settings( :main, :plugindest => { :type => :directory, :default => "$libdir", :desc => "Where Puppet should store plugins that it pulls down from the central server.", }, :pluginsource => { :default => "puppet://$server/plugins", :desc => "From where to retrieve plugins. The standard Puppet `file` type is used for retrieval, so anything that is a valid file source can be used here.", }, :pluginsync => { :default => true, :type => :boolean, :desc => "Whether plugins should be synced with the central server.", }, :pluginsignore => { :default => ".svn CVS .git", :desc => "What files to ignore when pulling down plugins.", } ) # Central fact information. define_settings( :main, :factpath => { :type => :path, :default => "$vardir/lib/facter#{File::PATH_SEPARATOR}$vardir/facts", :desc => "Where Puppet should look for facts. Multiple directories should be separated by the system path separator character. (The POSIX path separator is ':', and the Windows path separator is ';'.)", :call_hook => :on_initialize_and_write, # Call our hook with the default value, so we always get the value added to facter. :hook => proc { |value| Facter.search(value) if Facter.respond_to?(:search) }} ) define_settings( :tagmail, :tagmap => { :default => "$confdir/tagmail.conf", :desc => "The mapping between reporting tags and email addresses.", }, :sendmail => { :default => which('sendmail') || '', :desc => "Where to find the sendmail binary with which to send email.", }, :reportfrom => { :default => "report@" + [Facter["hostname"].value,Facter["domain"].value].join("."), :desc => "The 'from' email address for the reports.", }, :smtpserver => { :default => "none", :desc => "The server through which to send email reports.", } ) define_settings( :rails, :dblocation => { :default => "$statedir/clientconfigs.sqlite3", :type => :file, :mode => 0660, :owner => "service", :group => "service", :desc => "The database cache for client configurations. Used for querying within the language." }, :dbadapter => { :default => "sqlite3", :desc => "The type of database to use.", }, :dbmigrate => { :default => false, :type => :boolean, :desc => "Whether to automatically migrate the database.", }, :dbname => { :default => "puppet", :desc => "The name of the database to use.", }, :dbserver => { :default => "localhost", :desc => "The database server for caching. Only used when networked databases are used.", }, :dbport => { :default => "", :desc => "The database password for caching. Only used when networked databases are used.", }, :dbuser => { :default => "puppet", :desc => "The database user for caching. Only used when networked databases are used.", }, :dbpassword => { :default => "puppet", :desc => "The database password for caching. Only used when networked databases are used.", }, :dbconnections => { :default => '', :desc => "The number of database connections for networked databases. Will be ignored unless the value is a positive integer.", }, :dbsocket => { :default => "", :desc => "The database socket location. Only used when networked databases are used. Will be ignored if the value is an empty string.", }, :railslog => { :default => "$logdir/rails.log", :type => :file, :mode => 0600, :owner => "service", :group => "service", :desc => "Where Rails-specific logs are sent" }, :rails_loglevel => { :default => "info", :desc => "The log level for Rails connections. The value must be a valid log level within Rails. Production environments normally use `info` and other environments normally use `debug`.", } ) define_settings( :couchdb, :couchdb_url => { :default => "http://127.0.0.1:5984/puppet", :desc => "The url where the puppet couchdb database will be created", } ) define_settings( :transaction, :tags => { :default => "", :desc => "Tags to use to find resources. If this is set, then only resources tagged with the specified tags will be applied. Values must be comma-separated.", }, :evaltrace => { :default => false, :type => :boolean, :desc => "Whether each resource should log when it is being evaluated. This allows you to interactively see exactly what is being done.", }, :summarize => { :default => false, :type => :boolean, :desc => "Whether to print a transaction summary.", } ) define_settings( :main, :external_nodes => { :default => "none", :desc => "An external command that can produce node information. The command's output must be a YAML dump of a hash, and that hash must have a `classes` key and/or a `parameters` key, where `classes` is an array or hash and `parameters` is a hash. For unknown nodes, the command should exit with a non-zero exit code. This command makes it straightforward to store your node mapping information in other data sources like databases.", } ) define_settings( :ldap, :ldapnodes => { :default => false, :type => :boolean, :desc => "Whether to search for node configurations in LDAP. See http://projects.puppetlabs.com/projects/puppet/wiki/LDAP_Nodes for more information.", }, :ldapssl => { :default => false, :type => :boolean, :desc => "Whether SSL should be used when searching for nodes. Defaults to false because SSL usually requires certificates to be set up on the client side.", }, :ldaptls => { :default => false, :type => :boolean, :desc => "Whether TLS should be used when searching for nodes. Defaults to false because TLS usually requires certificates to be set up on the client side.", }, :ldapserver => { :default => "ldap", :desc => "The LDAP server. Only used if `ldapnodes` is enabled.", }, :ldapport => { :default => 389, :desc => "The LDAP port. Only used if `ldapnodes` is enabled.", }, :ldapstring => { :default => "(&(objectclass=puppetClient)(cn=%s))", :desc => "The search string used to find an LDAP node.", }, :ldapclassattrs => { :default => "puppetclass", :desc => "The LDAP attributes to use to define Puppet classes. Values should be comma-separated.", }, :ldapstackedattrs => { :default => "puppetvar", :desc => "The LDAP attributes that should be stacked to arrays by adding the values in all hierarchy elements of the tree. Values should be comma-separated.", }, :ldapattrs => { :default => "all", :desc => "The LDAP attributes to include when querying LDAP for nodes. All returned attributes are set as variables in the top-level scope. Multiple values should be comma-separated. The value 'all' returns all attributes.", }, :ldapparentattr => { :default => "parentnode", :desc => "The attribute to use to define the parent node.", }, :ldapuser => { :default => "", :desc => "The user to use to connect to LDAP. Must be specified as a full DN.", }, :ldappassword => { :default => "", :desc => "The password to use to connect to LDAP.", }, :ldapbase => { :default => "", :desc => "The search base for LDAP searches. It's impossible to provide a meaningful default here, although the LDAP libraries might have one already set. Generally, it should be the 'ou=Hosts' branch under your main directory.", } ) define_settings(:master, :storeconfigs => { :default => false, :type => :boolean, :desc => "Whether to store each client's configuration, including catalogs, facts, and related data. This also enables the import and export of resources in the Puppet language - a mechanism for exchange resources between nodes. By default this uses ActiveRecord and an SQL database to store and query the data; this, in turn, will depend on Rails being available. You can adjust the backend using the storeconfigs_backend setting.", # Call our hook with the default value, so we always get the libdir set. :call_hook => :on_initialize_and_write, :hook => proc do |value| require 'puppet/node' require 'puppet/node/facts' if value Puppet.settings[:async_storeconfigs] or Puppet::Resource::Catalog.indirection.cache_class = :store_configs Puppet::Node::Facts.indirection.cache_class = :store_configs Puppet::Node.indirection.cache_class = :store_configs Puppet::Resource.indirection.terminus_class = :store_configs end end }, :storeconfigs_backend => { :default => "active_record", :desc => "Configure the backend terminus used for StoreConfigs. By default, this uses the ActiveRecord store, which directly talks to the database from within the Puppet Master process." } ) # This doesn't actually work right now. define_settings( :parser, :lexical => { :default => false, :type => :boolean, :desc => "Whether to use lexical scoping (vs. dynamic).", }, :templatedir => { :default => "$vardir/templates", :type => :directory, :desc => "Where Puppet looks for template files. Can be a list of colon-separated directories.", } ) define_settings( :puppetdoc, :document_all => { :default => false, :type => :boolean, :desc => "Document all resources", } ) end diff --git a/lib/puppet/face/module/search.rb b/lib/puppet/face/module/search.rb index f047e6cba..72e06fa30 100644 --- a/lib/puppet/face/module/search.rb +++ b/lib/puppet/face/module/search.rb @@ -1,90 +1,94 @@ require 'puppet/util/terminal' require 'puppet/forge' Puppet::Face.define(:module, '1.0.0') do action(:search) do summary "Search the Puppet Forge for a module." description <<-EOT Searches a repository for modules whose names, descriptions, or keywords match the provided search term. EOT returns "Array of module metadata hashes" examples <<-EOT Search the Puppet Forge for a module: $ puppet module search puppetlabs NAME DESCRIPTION AUTHOR KEYWORDS bacula This is a generic Apache module @puppetlabs backups EOT arguments "" when_invoked do |term, options| Puppet::ModuleTool.set_option_defaults options Puppet::ModuleTool::Applications::Searcher.new(term, Puppet::Forge.new("PMT", self.version), options).run end when_rendering :console do |results, term, options| - return "No results found for '#{term}'." if results.empty? + if results[:result] == :failure + raise results[:error][:multiline] + end + + return "No results found for '#{term}'." if results[:answers].empty? padding = ' ' headers = { 'full_name' => 'NAME', 'desc' => 'DESCRIPTION', 'author' => 'AUTHOR', 'tag_list' => 'KEYWORDS', } min_widths = Hash[ *headers.map { |k,v| [k, v.length] }.flatten ] min_widths['full_name'] = min_widths['author'] = 12 min_width = min_widths.inject(0) { |sum,pair| sum += pair.last } + (padding.length * (headers.length - 1)) terminal_width = [Puppet::Util::Terminal.width, min_width].max - columns = results.inject(min_widths) do |hash, result| + columns = results[:answers].inject(min_widths) do |hash, result| { 'full_name' => [ hash['full_name'], result['full_name'].length ].max, 'desc' => [ hash['desc'], result['desc'].length ].max, 'author' => [ hash['author'], "@#{result['author']}".length ].max, 'tag_list' => [ hash['tag_list'], result['tag_list'].join(' ').length ].max, } end flex_width = terminal_width - columns['full_name'] - columns['author'] - (padding.length * (headers.length - 1)) - tag_lists = results.map { |r| r['tag_list'] } + tag_lists = results[:answers].map { |r| r['tag_list'] } while (columns['tag_list'] > flex_width / 3) longest_tag_list = tag_lists.sort_by { |tl| tl.join(' ').length }.last break if [ [], [term] ].include? longest_tag_list longest_tag_list.delete(longest_tag_list.sort_by { |t| t == term ? -1 : t.length }.last) columns['tag_list'] = tag_lists.map { |tl| tl.join(' ').length }.max end columns['tag_list'] = [ flex_width / 3, tag_lists.map { |tl| tl.join(' ').length }.max, ].max columns['desc'] = flex_width - columns['tag_list'] format = %w{full_name desc author tag_list}.map do |k| "%-#{ [ columns[k], min_widths[k] ].max }s" end.join(padding) + "\n" highlight = proc do |s| s = s.gsub(term, colorize(:green, term)) s = s.gsub(term.gsub('/', '-'), colorize(:green, term.gsub('/', '-'))) if term =~ /\// s end format % [ headers['full_name'], headers['desc'], headers['author'], headers['tag_list'] ] + - results.map do |match| + results[:answers].map do |match| name, desc, author, keywords = %w{full_name desc author tag_list}.map { |k| match[k] } desc = desc[0...(columns['desc'] - 3)] + '...' if desc.length > columns['desc'] highlight[format % [ name.sub('/', '-'), desc, "@#{author}", [keywords].flatten.join(' ') ]] end.join end end end diff --git a/lib/puppet/forge.rb b/lib/puppet/forge.rb index eff05eda5..59abb94c2 100644 --- a/lib/puppet/forge.rb +++ b/lib/puppet/forge.rb @@ -1,113 +1,114 @@ require 'net/http' require 'open-uri' require 'pathname' require 'uri' require 'puppet/forge/cache' require 'puppet/forge/repository' +require 'puppet/forge/errors' class Puppet::Forge # +consumer_name+ is a name to be used for identifying the consumer of the # forge and +consumer_semver+ is a SemVer object to identify the version of # the consumer def initialize(consumer_name, consumer_semver) @consumer_name = consumer_name @consumer_semver = consumer_semver end # Return a list of module metadata hashes that match the search query. # This return value is used by the module_tool face install search, # and displayed to on the console. # # Example return value: # # [ # { # "author" => "puppetlabs", # "name" => "bacula", # "tag_list" => ["backup", "bacula"], # "releases" => [{"version"=>"0.0.1"}, {"version"=>"0.0.2"}], # "full_name" => "puppetlabs/bacula", # "version" => "0.0.2", # "project_url" => "http://github.com/puppetlabs/puppetlabs-bacula", # "desc" => "bacula" # } # ] # def search(term) - server = Puppet.settings[:module_repository].sub(/^(?!https?:\/\/)/, 'http://') + server = Puppet.settings[:module_repository] Puppet.notice "Searching #{server} ..." response = repository.make_http_request("/modules.json?q=#{URI.escape(term)}") case response.code when "200" matches = PSON.parse(response.body) else raise RuntimeError, "Could not execute search (HTTP #{response.code})" end matches end def remote_dependency_info(author, mod_name, version) version_string = version ? "&version=#{version}" : '' response = repository.make_http_request("/api/v1/releases.json?module=#{author}/#{mod_name}#{version_string}") json = PSON.parse(response.body) rescue {} case response.code when "200" return json else error = json['error'] || '' if error =~ /^Module #{author}\/#{mod_name} has no release/ return [] else raise RuntimeError, "Could not find release information for this module (#{author}/#{mod_name}) (HTTP #{response.code})" end end end def get_release_packages_from_repository(install_list) install_list.map do |release| modname, version, file = release cache_path = nil if file begin cache_path = repository.retrieve(file) rescue OpenURI::HTTPError => e raise RuntimeError, "Could not download module: #{e.message}" end else raise RuntimeError, "Malformed response from module repository." end cache_path end end # Locate a module release package on the local filesystem and move it # into the `Puppet.settings[:module_working_dir]`. Do not unpack it, just # return the location of the package on disk. def get_release_package_from_filesystem(filename) if File.exist?(File.expand_path(filename)) repository = Repository.new('file:///') uri = URI.parse("file://#{URI.escape(File.expand_path(filename))}") cache_path = repository.retrieve(uri) else raise ArgumentError, "File does not exists: #{filename}" end cache_path end def retrieve(release) repository.retrieve(release) end def uri repository.uri end def repository version = "#{@consumer_name}/#{[@consumer_semver.major, @consumer_semver.minor, @consumer_semver.tiny].join('.')}#{@consumer_semver.special}" @repository ||= Puppet::Forge::Repository.new(Puppet[:module_repository], version) end private :repository end diff --git a/lib/puppet/forge/errors.rb b/lib/puppet/forge/errors.rb new file mode 100644 index 000000000..50575d2ae --- /dev/null +++ b/lib/puppet/forge/errors.rb @@ -0,0 +1,56 @@ +# Puppet::Forge specific exceptions +module Puppet::Forge::Errors + + # This exception is the parent for all Forge API errors + class ForgeError < StandardError + # This is normally set by the child class, but if it is not this will + # fall back to displaying the message as a multiline. + def multiline + self.message + end + end + + # This exception is raised when there is an SSL verification error when + # communicating with the forge. + # + # @option options [String] :uri The URI that failed + class SSLVerifyError < ForgeError + def initialize(options) + @uri = options[:uri] + + super "Unable to verify the SSL certificate at #{@uri}" + end + + # A multiline version of the error message + def multiline + message = <<-EOS.chomp +Unable to verify the SSL certificate at #{@uri} + This could be because the certificate is invalid or that the CA bundle + installed with your version of OpenSSL is not available, not valid or + not up to date. + EOS + end + end + + # This exception is raised when there is a communication error when connecting + # to the forge + # + # @option options [String] :uri The URI that failed + class CommunicationError < ForgeError + def initialize(options) + @uri = options[:uri] + + super "Unable to connect to the server at #{@uri}" + end + + # A multiline version of the error message + def multiline + message = <<-EOS.chomp +Could not connect to #{@uri} + There was a network communications problem + Check your network connection and try again + EOS + end + end + +end diff --git a/lib/puppet/forge/repository.rb b/lib/puppet/forge/repository.rb index 8ddf44b6d..89c362da0 100644 --- a/lib/puppet/forge/repository.rb +++ b/lib/puppet/forge/repository.rb @@ -1,116 +1,130 @@ -require 'net/http' +require 'net/https' require 'digest/sha1' require 'uri' +require 'puppet/forge/errors' class Puppet::Forge # = Repository # # This class is a file for accessing remote repositories with modules. class Repository + include Puppet::Forge::Errors + attr_reader :uri, :cache # Instantiate a new repository instance rooted at the +url+. # The agent will report +consumer_version+ in the User-Agent to # the repository. def initialize(url, consumer_version) - @uri = url.is_a?(::URI) ? url : ::URI.parse(url.sub(/^(?!https?:\/\/)/, 'http://')) + @uri = url.is_a?(::URI) ? url : ::URI.parse(url) @cache = Cache.new(self) @consumer_version = consumer_version end # Read HTTP proxy configurationm from Puppet's config file, or the # http_proxy environment variable. def http_proxy_env proxy_env = ENV["http_proxy"] || ENV["HTTP_PROXY"] || nil begin return URI.parse(proxy_env) if proxy_env rescue URI::InvalidURIError return nil end return nil end def http_proxy_host env = http_proxy_env if env and env.host then return env.host end if Puppet.settings[:http_proxy_host] == 'none' return nil end return Puppet.settings[:http_proxy_host] end def http_proxy_port env = http_proxy_env if env and env.port then return env.port end return Puppet.settings[:http_proxy_port] end # Return a Net::HTTPResponse read for this +request_path+. def make_http_request(request_path) request = Net::HTTP::Get.new(request_path, { "User-Agent" => user_agent }) if ! @uri.user.nil? && ! @uri.password.nil? request.basic_auth(@uri.user, @uri.password) end return read_response(request) end # Return a Net::HTTPResponse read from this HTTPRequest +request+. def read_response(request) begin - Net::HTTP::Proxy( - http_proxy_host, - http_proxy_port - ).start(@uri.host, @uri.port) do |http| + proxy_class = Net::HTTP::Proxy(http_proxy_host, http_proxy_port) + proxy = proxy_class.new(@uri.host, @uri.port) + + if @uri.scheme == 'https' + cert_store = OpenSSL::X509::Store.new + cert_store.set_default_paths + + proxy.use_ssl = true + proxy.verify_mode = OpenSSL::SSL::VERIFY_PEER + proxy.cert_store = cert_store + end + + proxy.start do |http| http.request(request) end rescue Errno::ECONNREFUSED, SocketError - msg = "Error: Could not connect to #{@uri}\n" - msg << " There was a network communications problem\n" - msg << " Check your network connection and try again\n" - Puppet.err msg - exit(1) + raise CommunicationError.new(:uri => @uri.to_s) + rescue OpenSSL::SSL::SSLError => e + if e.message =~ /certificate verify failed/ + raise SSLVerifyError.new(:uri => @uri.to_s) + else + raise e + end end end # Return the local file name containing the data downloaded from the # repository at +release+ (e.g. "myuser-mymodule"). def retrieve(release) return cache.retrieve(@uri + release) end # Return the URI string for this repository. def to_s return @uri.to_s end # Return the cache key for this repository, this a hashed string based on # the URI. def cache_key return @cache_key ||= [ @uri.to_s.gsub(/[^[:alnum:]]+/, '_').sub(/_$/, ''), Digest::SHA1.hexdigest(@uri.to_s) ].join('-') end def user_agent "#{@consumer_version} Puppet/#{Puppet.version} (#{Facter.value(:operatingsystem)} #{Facter.value(:operatingsystemrelease)}) #{ruby_version}" end private :user_agent def ruby_version # the patchlevel is not available in ruby 1.8.5 patch = defined?(RUBY_PATCHLEVEL) ? "-p#{RUBY_PATCHLEVEL}" : "" "Ruby/#{RUBY_VERSION}#{patch} (#{RUBY_RELEASE_DATE}; #{RUBY_PLATFORM})" end private :ruby_version end end diff --git a/lib/puppet/module_tool/applications/installer.rb b/lib/puppet/module_tool/applications/installer.rb index d0d7dfd05..0e2c60c22 100644 --- a/lib/puppet/module_tool/applications/installer.rb +++ b/lib/puppet/module_tool/applications/installer.rb @@ -1,182 +1,183 @@ require 'open-uri' require 'pathname' require 'fileutils' require 'tmpdir' require 'semver' require 'puppet/forge' require 'puppet/module_tool' require 'puppet/module_tool/shared_behaviors' require 'puppet/module_tool/install_directory' module Puppet::ModuleTool module Applications class Installer < Application include Puppet::ModuleTool::Errors + include Puppet::Forge::Errors def initialize(name, forge, install_dir, options = {}) super(options) @action = :install @environment = Puppet::Node::Environment.new(Puppet.settings[:environment]) @force = options[:force] @ignore_dependencies = options[:force] || options[:ignore_dependencies] @name = name @forge = forge @install_dir = install_dir end def run begin if is_module_package?(@name) @source = :filesystem @filename = File.expand_path(@name) raise MissingPackageError, :requested_package => @filename unless File.exist?(@filename) parsed = parse_filename(@filename) @module_name = parsed[:module_name] @version = parsed[:version] else @source = :repository @module_name = @name.gsub('/', '-') @version = options[:version] end results = { :module_name => @module_name, :module_version => @version, :install_dir => options[:target_dir], } @install_dir.prepare(@module_name, @version || 'latest') cached_paths = get_release_packages unless @graph.empty? Puppet.notice 'Installing -- do not interrupt ...' cached_paths.each do |hash| hash.each do |dir, path| Unpacker.new(path, @options.merge(:target_dir => dir)).run end end end - rescue ModuleToolError => err + rescue ModuleToolError, ForgeError => err results[:error] = { :oneline => err.message, :multiline => err.multiline, } else results[:result] = :success results[:installed_modules] = @graph ensure results[:result] ||= :failure end results end private include Puppet::ModuleTool::Shared # Return a Pathname object representing the path to the module # release package in the `Puppet.settings[:module_working_dir]`. def get_release_packages get_local_constraints if !@force && @installed.include?(@module_name) raise AlreadyInstalledError, :module_name => @module_name, :installed_version => @installed[@module_name].first.version, :requested_version => @version || (@conditions[@module_name].empty? ? :latest : :best), :local_changes => @installed[@module_name].first.local_changes end if @ignore_dependencies && @source == :filesystem @urls = {} @remote = { "#{@module_name}@#{@version}" => { } } @versions = { @module_name => [ { :vstring => @version, :semver => SemVer.new(@version) } ] } else get_remote_constraints(@forge) end @graph = resolve_constraints({ @module_name => @version }) @graph.first[:tarball] = @filename if @source == :filesystem resolve_install_conflicts(@graph) unless @force # This clean call means we never "cache" the module we're installing, but this # is desired since module authors can easily rerelease modules different content but the same # version number, meaning someone with the old content cached will be very confused as to why # they can't get new content. # Long term we should just get rid of this caching behavior and cleanup downloaded modules after they install # but for now this is a quick fix to disable caching Puppet::Forge::Cache.clean download_tarballs(@graph, @graph.last[:path], @forge) end # # Resolve installation conflicts by checking if the requested module # or one of it's dependencies conflicts with an installed module. # # Conflicts occur under the following conditions: # # When installing 'puppetlabs-foo' and an existing directory in the # target install path contains a 'foo' directory and we cannot determine # the "full name" of the installed module. # # When installing 'puppetlabs-foo' and 'pete-foo' is already installed. # This is considered a conflict because 'puppetlabs-foo' and 'pete-foo' # install into the same directory 'foo'. # def resolve_install_conflicts(graph, is_dependency = false) graph.each do |release| @environment.modules_by_path[options[:target_dir]].each do |mod| if mod.has_metadata? metadata = { :name => mod.forge_name.gsub('/', '-'), :version => mod.version } next if release[:module] == metadata[:name] else metadata = nil end if release[:module] =~ /-#{mod.name}$/ dependency_info = { :name => release[:module], :version => release[:version][:vstring] } dependency = is_dependency ? dependency_info : nil latest_version = @versions["#{@module_name}"].sort_by { |h| h[:semver] }.last[:vstring] raise InstallConflictError, :requested_module => @module_name, :requested_version => @version || "latest: v#{latest_version}", :dependency => dependency, :directory => mod.path, :metadata => metadata end resolve_install_conflicts(release[:dependencies], true) end end end # # Check if a file is a vaild module package. # --- # FIXME: Checking for a valid module package should be more robust and # use the acutal metadata contained in the package. 03132012 - Hightower # +++ # def is_module_package?(name) filename = File.expand_path(name) filename =~ /.tar.gz$/ end end end end diff --git a/lib/puppet/module_tool/applications/searcher.rb b/lib/puppet/module_tool/applications/searcher.rb index cc994bafd..b80875f4d 100644 --- a/lib/puppet/module_tool/applications/searcher.rb +++ b/lib/puppet/module_tool/applications/searcher.rb @@ -1,16 +1,28 @@ module Puppet::ModuleTool module Applications class Searcher < Application + include Puppet::Forge::Errors def initialize(term, forge, options = {}) @term = term @forge = forge super(options) end def run - @forge.search(@term) + results = {} + begin + results[:answers] = @forge.search(@term) + results[:result] = :success + rescue ForgeError => e + results[:result] = :failure + results[:error] = { + :oneline => e.message, + :multiline => e.multiline, + } + end + results end end end end diff --git a/spec/unit/face/module/search_spec.rb b/spec/unit/face/module/search_spec.rb index 699dc117f..6f4a6b8cb 100644 --- a/spec/unit/face/module/search_spec.rb +++ b/spec/unit/face/module/search_spec.rb @@ -1,169 +1,201 @@ require 'spec_helper' require 'puppet/face' require 'puppet/application/module' require 'puppet/module_tool' describe "puppet module search" do subject { Puppet::Face[:module, :current] } let(:options) do {} end describe Puppet::Application::Module do subject do app = Puppet::Application::Module.new app.stubs(:action).returns(Puppet::Face.find_action(:module, :search)) app end before { subject.render_as = :console } before { Puppet::Util::Terminal.stubs(:width).returns(100) } it 'should output nothing when receiving an empty dataset' do - subject.render([], ['apache', {}]).should == "No results found for 'apache'." + subject.render({:answers => [], :result => :sucess}, ['apache', {}]).should == "No results found for 'apache'." + end + + it 'should return error and exit when error returned' do + results = { + :result => :failure, + :error => { + :oneline => 'Something failed', + :multiline => 'Something failed', + } + } + expect { subject.render(results, ['apache', {}]) }.to raise_error 'Something failed' end it 'should output a header when receiving a non-empty dataset' do - results = [ - {'full_name' => '', 'author' => '', 'desc' => '', 'tag_list' => [] }, - ] + results = { + :result => :success, + :answers => [ + {'full_name' => '', 'author' => '', 'desc' => '', 'tag_list' => [] }, + ], + } subject.render(results, ['apache', {}]).should =~ /NAME/ subject.render(results, ['apache', {}]).should =~ /DESCRIPTION/ subject.render(results, ['apache', {}]).should =~ /AUTHOR/ subject.render(results, ['apache', {}]).should =~ /KEYWORDS/ end it 'should output the relevant fields when receiving a non-empty dataset' do - results = [ - {'full_name' => 'Name', 'author' => 'Author', 'desc' => 'Summary', 'tag_list' => ['tag1', 'tag2'] }, - ] + results = { + :result => :success, + :answers => [ + {'full_name' => 'Name', 'author' => 'Author', 'desc' => 'Summary', 'tag_list' => ['tag1', 'tag2'] }, + ] + } subject.render(results, ['apache', {}]).should =~ /Name/ subject.render(results, ['apache', {}]).should =~ /Author/ subject.render(results, ['apache', {}]).should =~ /Summary/ subject.render(results, ['apache', {}]).should =~ /tag1/ subject.render(results, ['apache', {}]).should =~ /tag2/ end it 'should elide really long descriptions' do - results = [ - { - 'full_name' => 'Name', - 'author' => 'Author', - 'desc' => 'This description is really too long to fit in a single data table, guys -- we should probably set about truncating it', - 'tag_list' => ['tag1', 'tag2'], - }, - ] + results = { + :result => :success, + :answers => [ + { + 'full_name' => 'Name', + 'author' => 'Author', + 'desc' => 'This description is really too long to fit in a single data table, guys -- we should probably set about truncating it', + 'tag_list' => ['tag1', 'tag2'], + }, + ] + } subject.render(results, ['apache', {}]).should =~ /\.{3} @Author/ end it 'should never truncate the module name' do - results = [ - { - 'full_name' => 'This-module-has-a-really-really-long-name', - 'author' => 'Author', - 'desc' => 'Description', - 'tag_list' => ['tag1', 'tag2'], - }, - ] + results = { + :result => :success, + :answers => [ + { + 'full_name' => 'This-module-has-a-really-really-long-name', + 'author' => 'Author', + 'desc' => 'Description', + 'tag_list' => ['tag1', 'tag2'], + }, + ] + } subject.render(results, ['apache', {}]).should =~ /This-module-has-a-really-really-long-name/ end it 'should never truncate the author name' do - results = [ - { - 'full_name' => 'Name', - 'author' => 'This-author-has-a-really-really-long-name', - 'desc' => 'Description', - 'tag_list' => ['tag1', 'tag2'], - }, - ] + results = { + :result => :success, + :answers => [ + { + 'full_name' => 'Name', + 'author' => 'This-author-has-a-really-really-long-name', + 'desc' => 'Description', + 'tag_list' => ['tag1', 'tag2'], + }, + ] + } subject.render(results, ['apache', {}]).should =~ /@This-author-has-a-really-really-long-name/ end it 'should never remove tags that match the search term' do - results = [ - { - 'full_name' => 'Name', - 'author' => 'Author', - 'desc' => 'Description', - 'tag_list' => ['Supercalifragilisticexpialidocious'] + (1..100).map { |i| "tag#{i}" }, - }, - ] + results = { + :results => :success, + :answers => [ + { + 'full_name' => 'Name', + 'author' => 'Author', + 'desc' => 'Description', + 'tag_list' => ['Supercalifragilisticexpialidocious'] + (1..100).map { |i| "tag#{i}" }, + }, + ] + } subject.render(results, ['Supercalifragilisticexpialidocious', {}]).should =~ /Supercalifragilisticexpialidocious/ subject.render(results, ['Supercalifragilisticexpialidocious', {}]).should_not =~ /tag/ end { 100 => "NAME DESCRIPTION AUTHOR KEYWORDS#{' '*15}\n"\ "Name This description is really too long to fit ... @JohnnyApples tag1 tag2 taggitty3#{' '*4}\n", 70 => "NAME DESCRIPTION AUTHOR KEYWORDS#{' '*5}\n"\ "Name This description is rea... @JohnnyApples tag1 tag2#{' '*4}\n", 80 => "NAME DESCRIPTION AUTHOR KEYWORDS#{' '*8}\n"\ "Name This description is really too... @JohnnyApples tag1 tag2#{' '*7}\n", 200 => "NAME DESCRIPTION AUTHOR KEYWORDS#{' '*48}\n"\ "Name This description is really too long to fit in a single data table, guys -- we should probably set about trunca... @JohnnyApples tag1 tag2 taggitty3#{' '*37}\n" }.each do |width, expectation| it "should resize the table to fit the screen, when #{width} columns" do - results = [ - { - 'full_name' => 'Name', - 'author' => 'JohnnyApples', - 'desc' => 'This description is really too long to fit in a single data table, guys -- we should probably set about truncating it', - 'tag_list' => ['tag1', 'tag2', 'taggitty3'], - }, - ] + results = { + :result => :success, + :answers => [ + { + 'full_name' => 'Name', + 'author' => 'JohnnyApples', + 'desc' => 'This description is really too long to fit in a single data table, guys -- we should probably set about truncating it', + 'tag_list' => ['tag1', 'tag2', 'taggitty3'], + }, + ] + } Puppet::Util::Terminal.expects(:width).returns(width) result = subject.render(results, ['apache', {}]) result.lines.sort_by(&:length).last.chomp.length.should <= width result.should == expectation end end end describe "option validation" do context "without any options" do it "should require a search term" do pattern = /wrong number of arguments/ expect { subject.search }.to raise_error ArgumentError, pattern end end it "should accept the --module-repository option" do forge = mock("Puppet::Forge") searcher = mock("Searcher") options[:module_repository] = "http://forge.example.com" Puppet::Forge.expects(:new).with("PMT", subject.version).returns(forge) Puppet::ModuleTool::Applications::Searcher.expects(:new).with("puppetlabs-apache", forge, has_entries(options)).returns(searcher) searcher.expects(:run) subject.search("puppetlabs-apache", options) end end describe "inline documentation" do subject { Puppet::Face[:module, :current].get_action :search } its(:summary) { should =~ /search.*module/im } its(:description) { should =~ /search.*module/im } its(:returns) { should =~ /array/i } its(:examples) { should_not be_empty } %w{ license copyright summary description returns examples }.each do |doc| context "of the" do its(doc.to_sym) { should_not =~ /(FIXME|REVISIT|TODO)/ } end end end end diff --git a/spec/unit/forge/repository_spec.rb b/spec/unit/forge/repository_spec.rb index 064a24fd3..ace56f484 100644 --- a/spec/unit/forge/repository_spec.rb +++ b/spec/unit/forge/repository_spec.rb @@ -1,88 +1,131 @@ require 'spec_helper' require 'net/http' require 'puppet/forge/repository' require 'puppet/forge/cache' +require 'puppet/forge/errors' describe Puppet::Forge::Repository do let(:consumer_version) { "Test/1.0" } let(:repository) { Puppet::Forge::Repository.new('http://fake.com', consumer_version) } + let(:ssl_repository) { Puppet::Forge::Repository.new('https://fake.com', consumer_version) } it "retrieve accesses the cache" do uri = URI.parse('http://some.url.com') repository.cache.expects(:retrieve).with(uri) repository.retrieve(uri) end describe 'http_proxy support' do after :each do ENV["http_proxy"] = nil end it "supports environment variable for port and host" do ENV["http_proxy"] = "http://test.com:8011" repository.http_proxy_host.should == "test.com" repository.http_proxy_port.should == 8011 end it "supports puppet configuration for port and host" do ENV["http_proxy"] = nil proxy_settings_of('test.com', 7456) repository.http_proxy_port.should == 7456 repository.http_proxy_host.should == "test.com" end it "uses environment variable before puppet settings" do ENV["http_proxy"] = "http://test1.com:8011" proxy_settings_of('test2.com', 7456) repository.http_proxy_host.should == "test1.com" repository.http_proxy_port.should == 8011 end end describe "making a request" do before :each do proxy_settings_of("proxy", 1234) end it "returns the result object from the request" do - result = "the http response" + result = "the http response" performs_an_http_request result do |http| http.expects(:request).with(responds_with(:path, "the_path")) end repository.make_http_request("the_path").should == result end + it 'returns the result object from a request with ssl' do + result = "the http response" + performs_an_https_request result do |http| + http.expects(:request).with(responds_with(:path, "the_path")) + end + + ssl_repository.make_http_request("the_path").should == result + end + + it 'return a valid exception when there is an SSL verification problem' do + performs_an_https_request "the http response" do |http| + http.expects(:request).with(responds_with(:path, "the_path")).raises OpenSSL::SSL::SSLError.new("certificate verify failed") + end + + expect { ssl_repository.make_http_request("the_path") }.to raise_error Puppet::Forge::Errors::SSLVerifyError, 'Unable to verify the SSL certificate at https://fake.com' + end + + it 'return a valid exception when there is a communication problem' do + performs_an_http_request "the http response" do |http| + http.expects(:request).with(responds_with(:path, "the_path")).raises SocketError + end + + expect { repository.make_http_request("the_path") }.to raise_error Puppet::Forge::Errors::CommunicationError, 'Unable to connect to the server at http://fake.com' + end + it "sets the user agent for the request" do performs_an_http_request do |http| http.expects(:request).with() do |request| puppet_version = /Puppet\/\d+\..*/ os_info = /\(.*\)/ ruby_version = /Ruby\/\d+\.\d+\.\d+(-p\d+)? \(\d{4}-\d{2}-\d{2}; .*\)/ request["User-Agent"] =~ /^#{consumer_version} #{puppet_version} #{os_info} #{ruby_version}/ end end repository.make_http_request("the_path") end def performs_an_http_request(result = nil, &block) http = mock("http client") yield http + proxy_class = mock("http proxy class") + proxy = mock("http proxy") + proxy_class.expects(:new).with("fake.com", 80).returns(proxy) + proxy.expects(:start).yields(http).returns(result) + Net::HTTP.expects(:Proxy).with("proxy", 1234).returns(proxy_class) + end + + def performs_an_https_request(result = nil, &block) + http = mock("http client") + yield http + + proxy_class = mock("http proxy class") proxy = mock("http proxy") - proxy.expects(:start).with("fake.com", 80).yields(http).returns(result) - Net::HTTP.expects(:Proxy).with("proxy", 1234).returns(proxy) + proxy_class.expects(:new).with("fake.com", 443).returns(proxy) + proxy.expects(:start).yields(http).returns(result) + proxy.expects(:use_ssl=).with(true) + proxy.expects(:cert_store=) + proxy.expects(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER) + Net::HTTP.expects(:Proxy).with("proxy", 1234).returns(proxy_class) end end def proxy_settings_of(host, port) Puppet.settings.stubs(:[]).with(:http_proxy_host).returns(host) Puppet.settings.stubs(:[]).with(:http_proxy_port).returns(port) end end diff --git a/spec/unit/module_tool/applications/searcher_spec.rb b/spec/unit/module_tool/applications/searcher_spec.rb new file mode 100644 index 000000000..fcfe3e6af --- /dev/null +++ b/spec/unit/module_tool/applications/searcher_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' +require 'puppet/module_tool/applications' +require 'puppet_spec/modules' + +describe Puppet::ModuleTool::Applications::Searcher, :fails_on_windows => true do + include PuppetSpec::Files + + describe "when searching" do + let(:forge) { mock 'forge' } + + it "should return results from a forge query when successful" do + results = 'mock results' + forge.expects(:search).with('search_term').returns(results) + + searcher = Puppet::ModuleTool::Applications::Searcher.new('search_term', forge) + search_result = searcher.run + search_result.should == { + :result => :success, + :answers => results, + } + end + + it "should return an error when the forge query throws an exception" do + forge.expects(:search).with('search_term').raises Puppet::Forge::Errors::ForgeError.new("something went wrong") + + searcher = Puppet::ModuleTool::Applications::Searcher.new('search_term', forge) + search_result = searcher.run + search_result.should == { + :result => :failure, + :error => { + :oneline => 'something went wrong', + :multiline => 'something went wrong', + }, + } + end + end +end