Showing with 106 additions and 2 deletions.
  1. +1 −1 Modulefile
  2. +31 −1 README.md
  3. +61 −0 manifests/dotfile.pp
  4. +5 −0 manifests/virtualenv.pp
  5. +8 −0 templates/inifile.erb
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'stankevich-python'
version '1.8.2'
version '1.8.3'
source 'git://github.com/stankevich/puppet-python.git'
author 'stankevich'
license 'Apache License, Version 2.0'
Expand Down
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Currently, the changes you need to make are as follows:
```shell
git submodule add https://github.com/stankevich/puppet-python.git /path/to/python
```
**OR**
OR

``` shell
puppet module install stankevich-python
Expand Down Expand Up @@ -196,6 +196,36 @@ Manages Gunicorn virtual hosts.
}
```

### python::dotfile

Manages arbitrary python dotiles with a simple config hash.

**ensure** - present/absent. Default: present

**filename** - Default: $title

**mode** - Default: 0644

**owner** - Default: root

**group** - Default: root

**config** Config hash. This will be expanded to an ini-file. Default: {}

```puppet
python::dotfile { '/var/lib/jenkins/.pip/pip.conf':
ensure => present,
owner => 'jenkins',
group => 'jenkins',
config => {
'global' => {
'index-url => 'https://mypypi.acme.com/simple/'
'extra-index-url => https://pypi.risedev.at/simple/
}
}
}
```

## Authors

[Sergey Stankevich](https://github.com/stankevich)
Expand Down
61 changes: 61 additions & 0 deletions manifests/dotfile.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# == Define: python::dotfile
#
# Manages any python dotfiles with a simple config hash.
#
# === Parameters
#
# [*ensure*]
# present|absent. Default: present
#
# [*filename*]
# Filename. Default: $title
#
# [*mode*]
# File mode. Default: 0644
#
# [*owner*]
# [*group*]
# Owner/group. Default: `root`/`root`
#
# [*config*]
# Config hash. This will be expanded to an ini-file. Default: {}
#
# === Examples
#
# python::dotfile { '/var/lib/jenkins/.pip/pip.conf':
# ensure => present,
# owner => 'jenkins',
# group => 'jenkins',
# config => {
# 'global' => {
# 'index-url => 'https://mypypi.acme.com/simple/'
# 'extra-index-url => https://pypi.risedev.at/simple/
# }
# }
# }
#
#
define python::dotfile (
$ensure = 'present',
$filename = $title,
$owner = 'root',
$group = 'root',
$mode = '0644',
$config = {},
) {
$parent_dir = dirname($filename)

exec { "create ${title}'s parent dir":
command => "install -o ${owner} -g ${group} -d ${parent_dir}",
path => [ '/usr/bin', '/bin', '/usr/local/bin', ],
creates => $parent_dir,
}

file { $filename:
ensure => $ensure,
owner => $owner,
group => $group,
content => template("${module_name}/inifile.erb"),
require => Exec["create ${title}'s parent dir"],
}
}
5 changes: 5 additions & 0 deletions manifests/virtualenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
# [*group*]
# The group relating to the virtualenv being manipulated. Default: root
#
# [*mode*]
# Optionally specify directory mode. Default: 750
#
# [*proxy*]
# Proxy server to use for outbound connections. Default: none
#
Expand Down Expand Up @@ -77,6 +80,7 @@
$index = false,
$owner = 'root',
$group = 'root',
$mode = '750',
$proxy = false,
$environment = [],
$path = [ '/bin', '/usr/bin', '/usr/sbin' ],
Expand Down Expand Up @@ -144,6 +148,7 @@
ensure => directory,
owner => $owner,
group => $group,
mode => $mode
}


Expand Down
8 changes: 8 additions & 0 deletions templates/inifile.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# this file is managed by puppet
<%- @config.sort.map do |section,conf| -%>
[<%= section -%>]
<%- conf.sort.map do |key,value| -%>
<%= key %> = <%= value %>
<%- end -%>
<%- end -%>