-
-
Notifications
You must be signed in to change notification settings - Fork 879
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
Changes from 14 commits
859f4cb
0354722
6cf49ea
72a2461
050dad3
a070813
68a5094
ef5f04d
487c8ca
9e13a15
ce363ec
95f3cf1
2bea3e7
f3f2c60
d57c787
486dcd7
c8e2b0e
9310f7e
92f74a6
1f79a5d
785a5c9
45728b8
cb5cb83
12ece07
0d939d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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, | ||
} | ||
``` | ||
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. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parameter in this class should be There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ### | ||
) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to inherit nginx::params here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, good 👀 |
||
|
||
### Validations ### | ||
|
@@ -140,7 +152,6 @@ | |
validate_string($http_access_log) | ||
validate_string($proxy_headers_hash_bucket_size) | ||
validate_bool($super_user) | ||
|
||
### END VALIDATIONS ### | ||
|
||
|
||
|
There was a problem hiding this comment.
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 innginx
class so this would result in a duplicate declaration error.There was a problem hiding this comment.
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