Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rip back out puppet-module-data #501

Merged
merged 25 commits into from
Nov 22, 2014
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
859f4cb
remove puppet-module-data dependency
Oct 27, 2014
0354722
seperate module/user parameters in config
Oct 27, 2014
6cf49ea
sort parameters
Nov 2, 2014
72a2461
sync up data organization
Nov 2, 2014
050dad3
Merge branch 'master' of https://github.com/jfryman/puppet-nginx into…
Nov 8, 2014
a070813
extracted all variables back to params.pp pattern
Nov 8, 2014
68a5094
cleanup puppet-module-data cruft
Nov 8, 2014
ef5f04d
rename parameter logdir -> log_dir
Nov 8, 2014
487c8ca
Changing deprecation notice
Nov 8, 2014
9e13a15
remove all old docs on puppet-module-data
Nov 8, 2014
ce363ec
add updated documentation
Nov 8, 2014
95f3cf1
config.pp: add missing comma
3flex Nov 10, 2014
2bea3e7
spec_helper: remove module-data-backend dependency
3flex Nov 10, 2014
f3f2c60
Delete hiera.yaml
3flex Nov 10, 2014
d57c787
allow user to declare nginx::config per docs
Nov 17, 2014
486dcd7
Merge branch 'rip-out-module-data' of https://github.com/jfryman/pupp…
Nov 17, 2014
c8e2b0e
fix up mismatched params
Nov 17, 2014
9310f7e
adjust default worker count
Nov 17, 2014
92f74a6
fixtures.yml: remove module_data fixture
3flex Nov 17, 2014
1f79a5d
change logdir to log_dir when calling config from init
3flex Nov 17, 2014
785a5c9
inherit params
Nov 17, 2014
45728b8
Merge branch 'rip-out-module-data' of https://github.com/jfryman/pupp…
Nov 17, 2014
cb5cb83
make sure to call the right variable for log_dir
Nov 17, 2014
12ece07
Merge branch 'master' of https://github.com/jfryman/puppet-nginx into…
Nov 19, 2014
0d939d3
fixing up specs/config parameters
jfryman Nov 22, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 0 additions & 88 deletions data/common.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions data/hiera.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/operatingsystem/SmartOS.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/osfamily/Archlinux.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions data/osfamily/Debian.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions data/osfamily/FreeBSD.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions data/osfamily/Solaris.yaml

This file was deleted.

82 changes: 27 additions & 55 deletions docs/hiera.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,51 @@
# Usage of Hiera

This module takes advantage of the `puppet-module-data` pattern as introduced
by R.I. Pinnear to allow for a significant amount of flexibility with base
configuration of the module. This is to reduce the amount of clutter starting
to gather in `params.pp`, and provide a foundation for future enhancements.
Passing through parameters from the main Class[nginx] and then having them chain down to Class[nginx::config] creates a ton of unnecessary spaghetti code that makes the module more complex to understand and difficult to extend.

## Installation
Going forward, it is recommended to declare your changes in Hiera based on the system(s) role and location in your environment. In Puppet < 3.x, this is accomplished with Hiera bindings.

In order to leverage `puppet-module-data`, you must add an additional
configuration item to your `hiera.yaml` file to load the new backend. Simply
add the following code block.
## Example Conversion

```
:backends:
...
- module_data
```
Say for a moment that you have this code block:

### Vagrant
```ruby
class { 'nginx':
gzip => false,
}
```

In order to use this module with Vagrant, you will need to also configure
Vagrant to load up Hiera. This can be done with the following directives
in your Vagrantfile.
Moving this to hiera is simple. First, identify the appropriate hiera level to apply this attribute. (A node or role level is recommended). Then, add the following codeblock...

```
config.vm.provision "puppet" do |puppet|
...
puppet.hiera_config_path = "hiera.yaml"
puppet.options = "--pluginsync"
end
```yaml
---
nginx::config::gzip: false
```

For a full example, please take a look at https://gist.github.com/jfryman/e9f08affec54307e5198
to get additional information to bootstrap this module.
Magically, it's all done! Work through these until the deprecation notices go away.

## Upgrading
## I (cannot/do not want to) use Hiera

If you happen to be here because of some silly deprecation notice, it is
probably because a manifest is declaring attributes for the Nginx Class.
Upgrading should be easy!
Maybe for some reason, Hiera isn't being used in your organization. Or, you like to keep a certain amount of composibilty in you modules. Or, hidden option #3! Regardless, the recommended path is to instantiate your own copy of Class[nginx::config] and move on with life. Let's do another example.

* Step 1: Make sure you have Hiera configured. https://docs.puppetlabs.com/hiera/1/puppet.html#puppet-3-and-newer
* Step 2: Move any declared parameters to hiera.
* Step 3: Profit!
Assume the same code block as before:

For example:

```
```ruby
class { 'nginx':
logdir => '/data/nginx/logs',
gzip => false,
}
```

should become in your hiera configs:
Should become...

```ruby
include nginx
class { 'nginx::config':
gzip => false,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nginx::config is already declared in nginx class so this would result in a duplicate declaration error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some logic in another branch that covered this that I didn't 🍒-pick and put here. I've grabbed that.

d57c787

```
nginx::config::logdir: /data/nginx/logs
```

Please note: This module takes advantage of Puppet 3 data module bindings.
Be aware of any gotchas that accompany this. Take a look at https://docs.puppetlabs.com/hiera/1/puppet.html#limitations

## I cannot/do not use Hiera! NOW WHAT!
# Why again are you doing this?

Do not fret! This is a big change to the core module, and it may be difficult
to make the conversion right away. First off, we intend to make it blatantly
clear when the module will tear out the parameters in Class[nginx] as
detailed in the deprecation notice. (The current target is v1.0)
Well, the fact of the matter, the old Package/Config/Service pattern has served us well, but times are a-changin. Many users are starting to manage their packages and service seperately outside of the traditional pattern (Docker, anyone?). This means that in order to stay true to the goals of Configuration Management, it is becoming necessary to make less assumptions about how an organizations graph is composed, and allow the end-user additional flexibility. This is requring a re-think about hov to best consume this module.

In the event that you are unable to leverage Hiera for your attribute configuration, you can use the Spaceship Operator to set the parameters for the nginx::config class. For example:

```ruby
Class<| title == 'nginx::class' |> {
proxy_cache_levels => '2',
}
```
The recommended path is to use Hiera, but this pattern should give you an intermediate step during the upgrade process.

139 changes: 75 additions & 64 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,69 +14,81 @@
#
# This class file is not called directly
class nginx::config(
$client_body_buffer_size = undef,
$client_body_temp_path = undef,
$client_max_body_size = undef,
$confd_purge = undef,
$conf_dir = undef,
$conf_template = undef,
$daemon_user = undef,
$events_use = undef,
$fastcgi_cache_inactive = undef,
$fastcgi_cache_key = undef,
$fastcgi_cache_keys_zone = undef,
$fastcgi_cache_levels = undef,
$fastcgi_cache_max_size = undef,
$fastcgi_cache_path = undef,
$fastcgi_cache_use_stale = undef,
$gzip = undef,
$http_access_log = undef,
$http_cfg_append = undef,
$http_tcp_nodelay = undef,
$http_tcp_nopush = undef,
$keepalive_timeout = undef,
$logdir = undef,
$mail = undef,
$multi_accept = undef,
$names_hash_bucket_size = undef,
$names_hash_max_size = undef,
$nginx_error_log = undef,
$pid = undef,
$proxy_buffers = undef,
$proxy_buffer_size = undef,
$proxy_cache_inactive = undef,
$proxy_cache_keys_zone = undef,
$proxy_cache_levels = undef,
$proxy_cache_max_size = undef,
$proxy_cache_path = undef,
$proxy_conf_template = undef,
$proxy_connect_timeout = undef,
$proxy_headers_hash_bucket_size = undef,
$proxy_http_version = undef,
$proxy_read_timeout = undef,
$proxy_redirect = undef,
$proxy_send_timeout = undef,
$proxy_set_header = undef,
$proxy_temp_path = undef,
$root_group = undef,
$run_dir = undef,
$sendfile = undef,
$server_tokens = undef,
$spdy = undef,
$super_user = undef,
$temp_dir = undef,
$types_hash_bucket_size = undef,
$types_hash_max_size = undef,
$vhost_purge = undef,
$worker_connections = undef,
$worker_processes = undef,
$worker_rlimit_nofile = undef,
$global_owner = undef,
$global_group = undef,
$global_mode = undef,
$sites_available_owner = undef,
$sites_available_group = undef,
$sites_available_mode = undef,
### START Module/App Configuration ###
$client_body_temp_path = $nginx::params::client_body_temp_path,
$confd_purge = false,
$conf_dir = $nginx::params::conf_dir,
$daemon_user = $nginx::params::daemon_user,
$global_owner = $nginx::params::global_owner,
$global_group = $nginx::params::global_group,
$global_mode = $nginx::params::global_mode,
$log_dir = $nginx::params::log_dir,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameter in this class should be logdir to match the old name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did consider this... this is the only variable that didn't seem to match the existing style in the rest of code. I'll put another deprecation warning to make it less painful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HA! It actually looks like you did that already. 🙇

$http_access_log = $nginx::params::http_access_log,
$nginx_error_log = $nginx::params::nginx_error_log,
$pid = $nginx::params::pid,
$proxy_temp_path = $nginx::params::proxy_temp_path,
$root_group = $nginx::params::root_group,
$run_dir = $nginx::params::run_dir,
$sites_available_owner = $nginx::params::sites_available_owner,
$sites_available_group = $nginx::params::sites_available_group,
$sites_available_mode = $nginx::params::sites_available_mode,
$super_user = $nginx::params::super_user,
$temp_dir = $nginx::params::temp_dir,
$vhost_purge = false,

# Primary Templates
$conf_template = 'nginx/conf.d/nginx.conf.erb',
$proxy_conf_template = 'nginx/conf.d/proxy.conf.erb',
### END Module/App Configuration ###

### START Nginx Configuration ###
$client_body_buffer_size = '128k',
$client_max_body_size = '10m',
$events_use = false,
$fastcgi_cache_inactive = '20m',
$fastcgi_cache_key = false,
$fastcgi_cache_keys_zone = 'd3:100m',
$fastcgi_cache_levels = 1,
$fastcgi_cache_max_size = '500m',
$fastcgi_cache_path = false,
$fastcgi_cache_use_stale = false,
$gzip = 'on',
$http_cfg_append = false,
$http_tcp_nodelay = 'on',
$http_tcp_nopush = 'off',
$keepalive_timeout = 65,
$mail = false,
$multi_accept = 'off',
$names_hash_bucket_size = 64,
$names_hash_max_size = 512,
$proxy_buffers = '32 4k',
$proxy_buffer_size = '8k',
$proxy_cache_inactive = '20m',
$proxy_cache_keys_zone = 'd2:100m',
$proxy_cache_levels = 1,
$proxy_cache_max_size = '500m',
$proxy_cache_path = false,
$proxy_connect_timeout = 90,
$proxy_headers_hash_bucket_size = 64,
$proxy_http_version = '1.0',
$proxy_read_timeout = 90,
$proxy_redirect = 'off',
$proxy_send_timeout = 90,
$proxy_set_header = [
'Host $host',
'X-Real-IP $remote_addr',
'X-Forwarded-For $proxy_add_x_forwarded_for',
],
$sendfile = 'on',
$server_tokens = 'on',
$spdy = 'off',
$ssl_stapling = 'off',
$types_hash_bucket_size = 512,
$types_hash_max_size = 1024,
$worker_connections = 1024,
$worker_processes = 0,
$worker_rlimit_nofile = 1024,
### END Nginx Configuration ###
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to inherit nginx::params here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good 👀


### Validations ###
Expand Down Expand Up @@ -140,7 +152,6 @@
validate_string($http_access_log)
validate_string($proxy_headers_hash_bucket_size)
validate_bool($super_user)

### END VALIDATIONS ###


Expand Down
Loading