Showing with 2,954 additions and 1,666 deletions.
  1. +3 −0 .gitignore
  2. +20 −0 CHANGELOG.md
  3. +0 −139 CONTRIBUTING.md
  4. +212 −0 DEVELOPERS.md
  5. +181 −96 README.markdown
  6. +28 −0 acceptance/Gemfile
  7. +125 −0 acceptance/README.md
  8. +60 −0 acceptance/Rakefile
  9. +13 −0 acceptance/files/uninstall.ps1
  10. +411 −0 acceptance/helpers.rb
  11. +14 −0 acceptance/options.rb
  12. +80 −0 acceptance/pre_suite/00_master_setup.rb
  13. +42 −0 acceptance/tests/test_upgrade_pc1_to_puppet5.rb
  14. +42 −0 acceptance/tests/test_upgrade_puppet5_to_puppet6.rb
  15. +35 −0 docker/bin/helpers/run-upgrade.sh
  16. +29 −0 docker/bin/upgrade.sh
  17. +25 −0 docker/bin/versions.sh
  18. +107 −0 docker/centos/Dockerfile
  19. +18 −0 docker/centos/Dockerfile.versions
  20. +3 −0 docker/deploy.pp
  21. +111 −0 docker/ubuntu/Dockerfile
  22. +22 −0 docker/ubuntu/Dockerfile.versions
  23. +12 −0 docker/upgrade.pp
  24. +32 −16 templates/install_puppet.ps1.erb → files/install_puppet.ps1
  25. +11 −1 lib/facter/settings.rb
  26. +5 −1 lib/puppet/parser/functions/windows_msi_installargs.rb
  27. +25 −0 lib/puppet/provider/puppet_agent_upgrade_error/puppet_agent_upgrade_error.rb
  28. +25 −0 lib/puppet/type/puppet_agent_upgrade_error.rb
  29. +86 −89 manifests/init.pp
  30. +64 −83 manifests/install.pp
  31. +26 −0 manifests/install/darwin.pp
  32. +53 −0 manifests/install/solaris.pp
  33. +77 −0 manifests/install/windows.pp
  34. +47 −5 manifests/osfamily/aix.pp
  35. +16 −11 manifests/osfamily/darwin.pp
  36. +112 −105 manifests/osfamily/debian.pp
  37. +121 −103 manifests/osfamily/redhat.pp
  38. +33 −23 manifests/osfamily/solaris.pp
  39. +98 −80 manifests/osfamily/suse.pp
  40. +22 −8 manifests/osfamily/windows.pp
  41. +51 −112 manifests/params.pp
  42. +0 −43 manifests/prepare.pp
  43. +0 −55 manifests/prepare/mco_client_config.pp
  44. +0 −57 manifests/prepare/mco_server_config.pp
  45. +26 −57 manifests/prepare/package.pp
  46. +23 −42 manifests/prepare/puppet_config.pp
  47. +0 −45 manifests/prepare/ssl.pp
  48. +0 −21 manifests/prepare/stringify_facts.pp
  49. +10 −4 manifests/service.pp
  50. +0 −90 manifests/windows/install.pp
  51. +4 −21 metadata.json
  52. +27 −8 spec/classes/puppet_agent_osfamily_aix_spec.rb
  53. +22 −24 spec/classes/puppet_agent_osfamily_darwin_spec.rb
  54. +57 −17 spec/classes/puppet_agent_osfamily_debian_spec.rb
  55. +58 −36 spec/classes/puppet_agent_osfamily_redhat_spec.rb
  56. +44 −0 spec/classes/puppet_agent_osfamily_solaris_spec.rb
  57. +19 −36 spec/classes/puppet_agent_osfamily_suse_spec.rb
  58. +0 −1 spec/classes/puppet_agent_osfamily_windows_spec.rb
  59. +0 −6 spec/classes/puppet_agent_params_spec.rb
  60. +0 −139 spec/classes/puppet_agent_prepare_spec.rb
  61. +10 −7 spec/classes/puppet_agent_spec.rb
  62. +43 −65 spec/classes/puppet_agent_windows_install_spec.rb
  63. +1 −1 spec/spec_helper_local.rb
  64. +4 −4 task_spec/spec/acceptance/init_spec.rb
  65. +13 −0 task_spec/spec/acceptance/nodesets/osx1014-64.yml
  66. +21 −1 tasks/install.json
  67. +21 −1 tasks/install_powershell.json
  68. +5 −3 tasks/install_powershell.ps1
  69. +21 −1 tasks/install_shell.json
  70. +26 −7 tasks/install_shell.sh
  71. +1 −1 templates/do_install.sh.erb
  72. +1 −1 templates/osx_install.sh.erb
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.iml
.*.sw[op]
.DS_Store
.beaker/
.bundle/
.idea/
.metadata
Expand All @@ -13,6 +14,8 @@ Gemfile.lock
bin/
coverage/
doc/
hosts.yaml
hosts.yml
junit/
log/
pkg/
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.1.0] - 2019-03-26

### Summary
New parameters for managing package sources to allow for targeting mirrors. SLES and MacOS support for open-source installs. Better service management for windows installations

### Features
- Added SLES support for open-source installations ([MODULES-8598](https://tickets.puppetlabs.com/browse/MODULES-8598))
- Added MacOS support for open-source installations ([MODULES-8599](https://tickets.puppetlabs.com/browse/MODULES-8599))
- Error reporting for windows background upgrades ([MODULES-8554](https://tickets.puppetlabs.com/browse/MODULES-8554))
- New source parameters for managing alternate sources (like mirrors) ([MODULES-6604](https://tickets.puppetlabs.com/browse/MODULES-6604))

### Bug fixes
- Fix inherited permissions exec resource on windows ([MODULES-8406](https://tickets.puppetlabs.com/browse/MODULES-8406))
- Fix service management for puppet > 6 ([MODULES-8319](https://tickets.puppetlabs.com/browse/MODULES-8319))
- No longer passing environment for windows installations ([MODULES-4730](https://tickets.puppetlabs.com/browse/MODULES-4730))
- Fix rpm import of gpg keys for newer SLES ([MODULES-8583](https://tickets.puppetlabs.com/browse/MODULES-8583))
- Wait on any hanging pxp-agent processes in windows installations ([FM-7628](https://tickets.puppetlabs.com/browse/FM-7628))
- Update parameters to use 'server_list' when provided rather than the 'server' setting
- Update windows installations to always run service management outside of the initial puppet run (i.e. restart any services after the upgrade without using puppet)

## [2.0.1] - 2019-01-17

### Summary
Expand Down
139 changes: 0 additions & 139 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,142 +130,3 @@ process as easy as possible.
location of your branch, along with any other commentary you
may wish to make.

# Testing

## Getting Started

Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages,
or Gems, are required to build, develop, and test this software.

Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to
install all dependencies needed for this project in the project root by running

```shell
% bundle install --path .bundle/gems
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.1.0)
Using builder (3.2.2)
-- 8><-- many more --><8 --
Using rspec-system-puppet (2.2.0)
Using serverspec (0.6.3)
Using rspec-system-serverspec (1.0.0)
Using bundler (1.3.5)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
```

NOTE: some systems may require you to run this command with sudo.

If you already have those gems installed, make sure they are up-to-date:

```shell
% bundle update
```

## Running Tests

With all dependencies in place and up-to-date, run the tests:

### Unit Tests

```shell
% bundle exec rake spec
```

This executes all the [rspec tests](http://rspec-puppet.com/) in the directories defined [here](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/699d9fbca1d2489bff1736bb254bb7b7edb32c74/lib/puppetlabs_spec_helper/rake_tasks.rb#L17) and so on.
rspec tests may have the same kind of dependencies as the module they are testing. Although the module defines these dependencies in its [metadata.json](./metadata.json),
rspec tests define them in [.fixtures.yml](./fixtures.yml).

### Acceptance Tests

Some Puppet modules also come with acceptance tests, which use [beaker][]. These tests spin up a virtual machine under
[VirtualBox](https://www.virtualbox.org/), controlled with [Vagrant](http://www.vagrantup.com/), to simulate scripted test
scenarios. In order to run these, you need both Virtualbox and Vagrant installed on your system.

Run the tests by issuing the following command

```shell
% bundle exec rake spec_clean
% bundle exec rspec spec/acceptance
```

This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml),
install Puppet, copy this module, and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb)
and then run all the tests under [spec/acceptance](./spec/acceptance).

## Writing Tests

### Unit Tests

When writing unit tests for Puppet, [rspec-puppet][] is your best friend. It provides tons of helper methods for testing your manifests against a
catalog (e.g. contain_file, contain_package, with_params, etc). It would be ridiculous to try and top rspec-puppet's [documentation][rspec-puppet_docs]
but here's a tiny sample:

Sample manifest:

```puppet
file { "a test file":
ensure => present,
path => "/etc/sample",
}
```

Sample test:

```ruby
it 'does a thing' do
expect(subject).to contain_file("a test file").with({:path => "/etc/sample"})
end
```

### Acceptance Tests

Writing acceptance tests for Puppet involves [beaker][] and its cousin [beaker-rspec][]. A common pattern for acceptance tests is to create a test manifest, apply it
twice to check for idempotency or errors, then run expectations.

```ruby
it 'does an end-to-end thing' do
pp = <<-EOF
file { 'a test file':
ensure => present,
path => "/etc/sample",
content => "test string",
}
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("/etc/sample") do
it { is_expected.to contain "test string" }
end
```
# If you have commit access to the repository
Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge
in your changes. The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that
all changes go through a code review process.**
The record of someone performing the merge is the record that they performed the code review. Again, this should be someone other than the author of the topic branch.
# Get Help
### On the web
* [Puppet help messageboard](http://puppet.com/community/get-help)
* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing)
* [General GitHub documentation](http://help.github.com/)
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
### On chat
* Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli
* IRC (freenode) #puppet-dev, #voxpupuli
[rspec-puppet]: http://rspec-puppet.com/
[rspec-puppet_docs]: http://rspec-puppet.com/documentation/
[beaker]: https://github.com/puppetlabs/beaker
[beaker-rspec]: https://github.com/puppetlabs/beaker-rspec
212 changes: 212 additions & 0 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# Development on puppet-agent module

Welcome to the `puppet-agent` module! This is a document which will help
guide you to getting started on development. The key sections here are:

1. [Iterative code changes](#iterative)
1. [Important files to understand repo](#files)
1. [Other tools for development](#tools)
1. [Testing](#testing)

## Iterative code changes<a name="iterative"/>

### Docker workflow

Iterative development is the practice of reducing the amount of time
between making a code change and seeing the result of that change.
Below are a few methods to do this style of development.

For iterative development using Docker, see:
- docker/bin/upgrade.sh
- docker/bin/versions.sh
*Ubuntu*
- docker/ubuntu/Dockerfile
*CentOS*
- docker/centos/Dockerfile

*Note*: This will not start systemd services due to a limitation in
Docker. It will upgrade packages properly, and should be useful for the
majority of development on the module.

### VMPooler workflow

1. Forward your ssh key to do github operations.
1. Ensure editor supports editing remote files.
1. Checkout a vmpooler machine.
1. Clone the module.
1. Run `puppet apply` to test it as you work.

### Development for Puppet Enterprise exclusive platforms

#### Manual testing workflow
1. Install an "old" PE on a master (typically RHEL).
1. Declare the pe_repo classes for each agent you're testing upgrades for (e.g. like Windows, Fedora, etc.) using the PE Console.
1. Install a "new" PE on the same master.
1. Run puppet agent so that the pe_repo platforms have the new agent package.
1. Copy local puppetlabs-puppet_agent module over to the /etc/puppetlabs/code/environment/production/modules directory.
1. Install any module dependencies on the master via puppet module install (which you can get from the metadata.json file).
1. Grab a VM to use as the agent, either in a local hypervisor or in VCloud.
1. Test an upgrade scenario by installing the "old" agent by curling the old PE's install.bash script onto the agent VM and running puppet agent -t to link up with the master. Make sure to sign the agent’s CSR on the master.
1. Declare the puppet_agent class in the site manifest (site.pp) declaring the master's agent as the puppet agent version for the agent node. Use the version returned by the master’s aio_agent_version fact.
1. On the agent node, run `puppet agent -t`.
1. To check that the upgrade was performed successfully, check the aio_agent_version fact on the agent to see if it matches what's reported on the master.

## Important files to understand repo<a name="files"/>

These are a few key files to look at to understand the basic flow of how the repository works:

- manifests/init.pp -- This is the entrypoint for the module. This file
describes the module's parameters, includes other classes(e.g.
`prepare` and `install`), and adds some exception cases for a variety
of platforms.
- templates/do_install.sh.erb -- This calls the other scripts in the same directory.

## Other tools for development<a name="tools"/>

This ad-hoc job can be used to run CI against a branch
[here](https://jenkins-master-prod-1.delivery.puppetlabs.net/view/puppet-agent/view/puppetlabs-puppet_agent%20module/view/ad-hoc/).

This link/job may be updated with a new workflow in the near future.

## Testing<a name="testing"/>

Prior to committing any changes, ensure the tests pass locally.

### Getting Started

Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages,
or Gems, are required to build, develop, and test this software.

Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to
install all dependencies needed for this project in the project root by running

```shell
% bundle install --path .bundle/gems
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.1.0)
Using builder (3.2.2)
-- 8><-- many more --><8 --
Using rspec-system-puppet (2.2.0)
Using serverspec (0.6.3)
Using rspec-system-serverspec (1.0.0)
Using bundler (1.3.5)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
```

NOTE: some systems may require you to run this command with sudo.

If you already have those gems installed, make sure they are up-to-date:

```shell
% bundle update
```

### Running Tests

With all dependencies in place and up-to-date, run the tests:

#### Unit Tests

```shell
% bundle exec rake spec
```

This executes all the [rspec tests](http://rspec-puppet.com/) in the directories defined [here](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/699d9fbca1d2489bff1736bb254bb7b7edb32c74/lib/puppetlabs_spec_helper/rake_tasks.rb#L17) and so on.
rspec tests may have the same kind of dependencies as the module they are testing. Although the module defines these dependencies in its [metadata.json](./metadata.json),
rspec tests define them in [.fixtures.yml](./fixtures.yml).

#### Acceptance Tests

Some Puppet modules also come with acceptance tests, which use [beaker][]. These tests spin up a virtual machine under
[VirtualBox](https://www.virtualbox.org/), controlled with [Vagrant](http://www.vagrantup.com/), to simulate scripted test
scenarios. In order to run these, you need both Virtualbox and Vagrant installed on your system.

Run the tests by issuing the following command

```shell
% bundle exec rake spec_clean
% bundle exec rspec spec/acceptance
```

This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml),
install Puppet, copy this module, and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb)
and then run all the tests under [spec/acceptance](./spec/acceptance).

### Writing Tests

#### Unit Tests

When writing unit tests for Puppet, [rspec-puppet][] is your best friend. It provides tons of helper methods for testing your manifests against a
catalog (e.g. contain_file, contain_package, with_params, etc). It would be ridiculous to try and top rspec-puppet's [documentation][rspec-puppet_docs]
but here's a tiny sample:

Sample manifest:

```puppet
file { "a test file":
ensure => present,
path => "/etc/sample",
}
```

Sample test:

```ruby
it 'does a thing' do
expect(subject).to contain_file("a test file").with({:path => "/etc/sample"})
end
```

#### Acceptance Tests

Writing acceptance tests for Puppet involves [beaker][] and its cousin [beaker-rspec][]. A common pattern for acceptance tests is to create a test manifest, apply it
twice to check for idempotency or errors, then run expectations.

More information about beaker and beaker-puppet is [here][https://github.com/puppetlabs/puppetlabs-puppet_agent/tree/master/acceptance].

```ruby
it 'does an end-to-end thing' do
pp = <<-EOF
file { 'a test file':
ensure => present,
path => "/etc/sample",
content => "test string",
}
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("/etc/sample") do
it { is_expected.to contain "test string" }
end
```
## If you have commit access to the repository
Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge
in your changes. The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that
all changes go through a code review process.**
The record of someone performing the merge is the record that they performed the code review. Again, this should be someone other than the author of the topic branch.
## Get Help
### On the web
* [Puppet help messageboard](http://puppet.com/community/get-help)
* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing)
* [General GitHub documentation](http://help.github.com/)
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
### On chat
* Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli
[rspec-puppet]: http://rspec-puppet.com/
[rspec-puppet_docs]: http://rspec-puppet.com/documentation/
[beaker]: https://github.com/puppetlabs/beaker
[beaker-rspec]: https://github.com/puppetlabs/beaker-rspec
Loading