Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
riton committed Jan 8, 2015
2 parents b47fbdc + aea45d4 commit 72fd957
Show file tree
Hide file tree
Showing 19 changed files with 126 additions and 307 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
YYYY-MM-DD Release 0.1.0
- something you did
- something else you did
#### 2015-01-08 - Remi Ferrand <[email protected]> - 1.0.0

* Initial release
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ccin2p3
remi.ferrand
48 changes: 26 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,60 @@
3. [Setup - The basics of getting started with etc_services](#setup)
* [What etc_services affects](#what-etc_services-affects)
* [Setup requirements](#setup-requirements)
* [Beginning with etc_services](#beginning-with-etc_services)
4. [Usage - Configuration options and additional functionality](#usage)
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
5. [Limitations - OS compatibility, etc.](#limitations)
6. [Development - Guide for contributing to the module](#development)

## Overview

A one-maybe-two sentence summary of what the module does/what problem it solves. This is your 30 second elevator pitch for your module. Consider including OS/Puppet version it works with.
Manage a single `/etc/services` entry.

## Module Description

If applicable, this section should have a brief description of the technology the module integrates with and what that integration enables. This section should answer the questions: "What does this module *do*?" and "Why would I use it?"

If your module has a range of functionality (installation, configuration, management, etc.) this is the time to mention it.
Manage a single `/etc/services` entry.

## Setup

### What etc_services affects

* A list of files, packages, services, or operations that the module will alter, impact, or execute on the system it's installed on.
* This is a great place to stick any warnings.
* Can be in list or paragraph form.
* `/etc/services`

### Setup Requirements

### Setup Requirements **OPTIONAL**
* [puppetlabs-stdlib](https://github.com/puppetlabs/puppetlabs-stdlib.git)

If your module requires anything extra before setting up (pluginsync enabled, etc.), mention it here.
## Usage

### Beginning with etc_services
### Classes and Defined Types

The very basic steps needed for a user to get the module up and running.
#### Defined Type: `etc_services`

If your most recent release breaks compatibility or requires particular steps for upgrading, you may wish to include an additional section here: Upgrading (For an example, see http://forge.puppetlabs.com/puppetlabs/firewall).
Manage `/etc/services` entries.

## Usage
Separator `/` is used between _service_name_ and _protocol_ and is *mandatory*.

Put the classes, types, and resources for customizing, configuring, and doing the fancy stuff with your module here.
Example:

```puppet
::etc_services { 'kerberos/udp':
port => '88',
aliases => [ 'kerberos5', 'krb5', 'kerberos-sec' ],
comment => 'Kerberos v5'
}
```

## Reference

Here, list the classes, types, providers, facts, etc contained in your module. This section should include all of the under-the-hood workings of your module so people know what the module is touching on their system but don't need to mess with things. (We are working on automating this section!)
### Defined Types

* [etc_services](#defined-type-etc_services-type-etc_services): Manage `/etc/services` entry.

## Limitations

This is where you list OS compatibility, version compatibility, etc.
This module could be used on any operating systems that has support for augeas and uses `/etc/services` file.

## Development

Since your module is awesome, other users will want to play with it. Let them know what the ground rules for contributing are.

## Release Notes/Contributors/Etc **Optional**

If you aren't using changelog, put your release notes here (though you should consider using changelog). You may also add any additional sections you feel are necessary or important to include here. Please use the `## ` header.
If you want to contribute or adjust some of the settings / behavior, either:
* create a new _Pull Request_.
12 changes: 0 additions & 12 deletions manifests/config.pp

This file was deleted.

77 changes: 63 additions & 14 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,27 +1,76 @@
#
# Copyright (c) IN2P3 Computing Centre, IN2P3, CNRS
#
# Contributor(s) : ccin2p3
# Contributor(s) : Remi Ferrand <remi.ferrand_at_cc(dot)in2p3(dot)fr>
#

# == Class: etc_services
# == Define: etc_services
#
# Full description of class etc_services here.
# Manage a /etc/services entry uniquely identified by its name and protocol.
#
# === Parameters
#
# [*sample_parameter*]
# Explanation of what this parameter affects and what it defaults to.
# [*port*]
# /etc/services entry port. Required.
# [*comment]
# /etc/services entry comment. Defaults to ''.
# [*aliases*]
# /etc/services entry aliases specified as an array. Defaults to [].
# [*ensure*]
# Should /etc/services entry be present or absent. Defaults to present.
#
class etc_services (
$package_name = $etc_services::params::package_name,
$service_name = $etc_services::params::service_name,
) inherits etc_services::params {
define etc_services (
$port,
$comment = '',
$aliases = [],
$ensure = 'present'
)
{
validate_re($name, '^\w+/(tcp|udp)$')
validate_re($ensure, '^(absent|present)$')
validate_re($port, '^\d+$')
validate_array($aliases)
validate_string($comment)

# validate parameters here
$primary_keys = split($name, '/')
$service_name = $primary_keys[0]
$protocol = $primary_keys[1]

class { 'etc_services::install': } ->
class { 'etc_services::config': } ~>
class { 'etc_services::service': } ->
Class['etc_services']
if ($ensure == 'present') {
$augeas_alias_operations = prefix($aliases, 'set $node/alias[last()+1] ')

$augeas_pre_alias_operations = [
"defnode node service-name[.='${service_name}'][protocol = '${protocol}'] ${service_name}",
"set \$node/port ${port}",
"set \$node/protocol ${protocol}",
'remove $node/alias',
'remove $node/#comment'
]

if empty($comment) {
$augeas_post_alias_operations = []
} else {
$augeas_post_alias_operations = [
"set \$node/#comment '${comment}'"
]
}

$augeas_operations = flatten([
$augeas_pre_alias_operations,
$augeas_alias_operations,
$augeas_post_alias_operations
])
}
else {
$augeas_operations = [
"remove service-name[.='${service_name}'][protocol = '${protocol}'] ${service_name}"
]
}

augeas { "${service_name}_${protocol}":
context => '/files/etc/services',
changes => $augeas_operations
}
}

# vim: tabstop=2 shiftwidth=2 softtabstop=2
14 changes: 0 additions & 14 deletions manifests/install.pp

This file was deleted.

26 changes: 0 additions & 26 deletions manifests/params.pp

This file was deleted.

14 changes: 0 additions & 14 deletions manifests/profile/base.pp

This file was deleted.

14 changes: 0 additions & 14 deletions manifests/profile/example.pp

This file was deleted.

26 changes: 0 additions & 26 deletions manifests/resource/example.pp

This file was deleted.

20 changes: 0 additions & 20 deletions manifests/resource/example/config.pp

This file was deleted.

17 changes: 0 additions & 17 deletions manifests/resource/example/install.pp

This file was deleted.

34 changes: 0 additions & 34 deletions manifests/resource/example/params.pp

This file was deleted.

20 changes: 0 additions & 20 deletions manifests/resource/example/service.pp

This file was deleted.

Loading

0 comments on commit 72fd957

Please sign in to comment.