Skip to content

Commit

Permalink
Allow to use OpenBSD specific service_flags and package_flavors.
Browse files Browse the repository at this point in the history
Give example for passenger in README.md and add OpenBSD to the
supported OSs in metadata.json.
  • Loading branch information
buzzdeee committed Jan 23, 2015
1 parent fa34755 commit 2960c10
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ nginx::nginx_mailhosts:
## Nginx with precompiled Passenger
Currently this works only for Debian family.
Currently this works only for Debian family and OpenBSD.
On Debian it might look like:
```puppet
class { 'nginx':
package_source => 'passenger',
Expand All @@ -141,6 +142,20 @@ class { 'nginx':
}
```

Here the example for OpenBSD:

```puppet
class { 'nginx':
package_flavor => 'passenger',
service_flags => '-u'
http_cfg_append => {
passenger_root => '/usr/local/lib/ruby/gems/2.1/gems/passenger-4.0.44',
passenger_ruby => '/usr/local/bin/ruby21',
passenger_max_pool_size => '15',
}
}
```

Package source `passenger` will add [Phusion Passenger repository](https://oss-binaries.phusionpassenger.com/apt/passenger) to APT sources.
For each virtual host you should specify which ruby should be used.

Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@
$package_ensure = present,
$package_name = $::nginx::params::package_name,
$package_source = 'nginx',
$package_flavor = undef,
$manage_repo = $::nginx::params::manage_repo,
### END Package Configuration ###

### START Service Configuation ###
$configtest_enable = false,
$service_ensure = running,
$service_flags = undef,
$service_restart = '/etc/init.d/nginx configtest && /etc/init.d/nginx restart',
$service_name = undef,
### END Service Configuration ###
Expand Down Expand Up @@ -210,6 +212,7 @@
package_name => $package_name,
package_source => $package_source,
package_ensure => $package_ensure,
package_flavor => $package_flavor,
notify => Class['::nginx::service'],
manage_repo => $manage_repo,
}
Expand Down Expand Up @@ -291,6 +294,7 @@
service_ensure => $service_ensure,
service_restart => $service_restart,
service_name => $service_name,
service_flags => $service_flags,
}

create_resources('::nginx::resource::upstream', $nginx_upstreams)
Expand Down
7 changes: 7 additions & 0 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
$package_name = $::nginx::params::package_name,
$package_source = 'nginx',
$package_ensure = 'present',
$package_flavor = undef,
$manage_repo = $::nginx::params::manage_repo,
) inherits ::nginx::params {

Expand Down Expand Up @@ -57,6 +58,12 @@
source => $package_source,
}
}
'OpenBSD': {
package { $package_name:
ensure => $package_ensure,
flavor => $package_flavor,
}
}
default: {
package { 'nginx':
ensure => $package_ensure,
Expand Down
2 changes: 2 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
$service_restart = $::nginx::service_restart,
$service_ensure = $::nginx::service_ensure,
$service_name = 'nginx',
$service_flags = undef,
) {

$service_enable = $service_ensure ? {
Expand All @@ -38,6 +39,7 @@
ensure => $service_ensure_real,
name => $service_name,
enable => $service_enable,
flags => $service_flags,
hasstatus => true,
hasrestart => true,
}
Expand Down
3 changes: 3 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"6.0"
]
},
{
"operatingsystem": "OpenBSD"
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease":[
Expand Down

9 comments on commit 2960c10

@Zophar78
Copy link
Contributor

Choose a reason for hiding this comment

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

This breaks on redhat system because the flaggable feature is not supported for service. How do you plan to manage that?

@buzzdeee
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIRC, flaggable feature is only supported on OpenBSD, however, I've tested it with Puppet 3.7.3 at least on a SLES 11, SP3 machine:

srv82:/tmp # puppet apply -e "service { 'xend': ensure => running, flags => undef, }"
Notice: Compiled catalog for srv82.srv.intern in environment production in 0.14 seconds
Notice: Finished catalog run in 0.30 seconds
srv82:/tmp # puppet apply -e "service { 'xend': ensure => running, flags => 'some flag', }"
Notice: Compiled catalog for srv82.srv.intern in environment production in 0.15 seconds
Notice: Finished catalog run in 0.28 seconds

So, it just ignores the parameter that it doesn't know of.

I wonder what happens for you on RedHat then?

@Zophar78
Copy link
Contributor

Choose a reason for hiding this comment

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

Here's what happen with puppet 3.4.3:

[vagrant@nginx-vagrant ~]$ puppet --version
3.4.3 (Puppet Enterprise 3.2.0)
[vagrant@nginx-vagrant ~]$ puppet apply -e "service { 'xend': ensure => running, flags => undef, }"
Error: Invalid parameter flags at line 1 on node nginx-vagrant

I got Invalid parameter each time i try to call the flags parameter on service.

@buzzdeee
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are obviously running an old version of Puppet (Enterprise), afaik, PE 3.7.0 just got releasesd, maybe just upgrade ;)

OK, might not be an option for you, and I don't know if PE supports that at all ;)

@jfryman, what "oldest" puppet version do you intend to support?

In the worst case, I could just add something similar as:

if ::osfamily == 'OpenBSD' ... with flags parameter, else without flags parameter.

I'm curious, does the flavor parameter for the package work for you? I.e.

puppet apply -e "package {'nginx': flavor => undef,}"

So, I'm wondering if I would need to do similar things here for the package too.

Sebastian

@buzzdeee
Copy link
Contributor Author

Choose a reason for hiding this comment

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

doh, I've just seen, in the package.pp, its already evaluating ::osfamily, so I could just do the same for the service.
But anyways, I'm still interested if the
puppet apply -e "package {'nginx': flavor => undef,}"
works for you, or ends up with same error.

@Zophar78
Copy link
Contributor

Choose a reason for hiding this comment

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

This one works:
[vagrant@nginx-vagrant ~]$ sudo puppet apply -e "package {'nginx': flavor => undef,}"
Notice: Compiled catalog for vagrant.test.com in environment production in 0.88 seconds

It's an "old" (less than one year) version but this one is used in an enterprise environnement (where upgrading puppet infra may took some time indeed). Would really appreciate a test on ::osfamily on that one :)

Also crash on CentOS 6.5:
[vagrant@centos65-64 ~]$ puppet apply -e "service { 'nginx': ensure => running, flags => undef, }"
Error: Invalid parameter flags at line 1 on node centos65-64.example42.com
Error: Invalid parameter flags at line 1 on node centos65-64.example42.com
[vagrant@centos65-64 ~]$ puppet --version
3.4.2

@Zophar78
Copy link
Contributor

Choose a reason for hiding this comment

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

I did the PR if you don't mind:
#569

@buzzdeee
Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for taking care, I wouldn't have got around to it before the evening.
Just added a little comment.

cheers

@Zophar78
Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops my bad... fixed.

Please sign in to comment.