Skip to content

Commit 7ecd3c9

Browse files
committedJul 25, 2018
initial commit
0 parents  commit 7ecd3c9

15 files changed

+314
-0
lines changed
 

‎.gitignore

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### JetBrains template
3+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
4+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5+
6+
# User-specific stuff:
7+
.idea/workspace.xml
8+
.idea/tasks.xml
9+
.idea/dictionaries
10+
.idea/vcs.xml
11+
.idea/jsLibraryMappings.xml
12+
13+
# Sensitive or high-churn files:
14+
.idea/dataSources.ids
15+
.idea/dataSources.xml
16+
.idea/dataSources.local.xml
17+
.idea/sqlDataSources.xml
18+
.idea/dynamic.xml
19+
.idea/uiDesigner.xml
20+
21+
# Gradle:
22+
.idea/gradle.xml
23+
.idea/libraries
24+
25+
# Mongo Explorer plugin:
26+
.idea/mongoSettings.xml
27+
28+
## File-based project format:
29+
*.iws
30+
31+
## Plugin-specific files:
32+
33+
# IntelliJ
34+
/out/
35+
36+
# mpeltonen/sbt-idea plugin
37+
.idea_modules/
38+
39+
# JIRA plugin
40+
atlassian-ide-plugin.xml
41+
42+
# Crashlytics plugin (for Android Studio and IntelliJ)
43+
com_crashlytics_export_strings.xml
44+
crashlytics.properties
45+
crashlytics-build.properties
46+
fabric.properties
47+
### OSX template
48+
.DS_Store
49+
.AppleDouble
50+
.LSOverride
51+
52+
# Icon must end with two \r
53+
Icon
54+
55+
# Thumbnails
56+
._*
57+
58+
# Files that might appear in the root of a volume
59+
.DocumentRevisions-V100
60+
.fseventsd
61+
.Spotlight-V100
62+
.TemporaryItems
63+
.Trashes
64+
.VolumeIcon.icns
65+
66+
# Directories potentially created on remote AFP share
67+
.AppleDB
68+
.AppleDesktop
69+
Network Trash Folder
70+
Temporary Items
71+
.apdisk
72+

‎.gitlab-ci.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
stages:
2+
- Puppet 5
3+
- push2github
4+
5+
xenial:puppet5:
6+
image: scalecommerce/xenial:1.8
7+
stage: Puppet 5
8+
script:
9+
- ./test/install.sh
10+
- puppet apply -v ./test/site.pp
11+
- inspec exec ./test/inspec/sc_postgresql.rb
12+
13+
push2github:
14+
stage: push2github
15+
script:
16+
- git push --mirror https://$GITHUB_TOKEN@github.com/ScaleCommerce/puppet-sc_postgresql.git

‎Gemfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source 'https://rubygems.org'
2+
3+
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 5.0']
4+
gem 'puppet', puppetversion
5+
gem 'puppetlabs_spec_helper', '>= 0.1.0'
6+
gem 'puppet-lint', '>= 0.3.2'
7+
gem 'facter', '>= 1.7.0'

‎README.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[![build status](https://gitlab.scale.sc/sc-puppet/puppet-sc_postgresql/badges/master/build.svg)](https://gitlab.scale.sc/sc-puppet/puppet-sc_postgresql/commits/master)
2+
3+
# sc_postgresql
4+
5+
#### Table of Contents
6+
7+
1. [Overview](#overview)
8+
2. [Module Description - What the module does and why it is useful](#module-description)
9+
3. [Setup - The basics of getting started with sc_apache](#setup)
10+
* [What sc_apache affects](#what-sc_postgresql-affects)
11+
* [Beginning with sc_apache](#beginning-with-sc_postgresql)
12+
4. [Usage - Configuration options and additional functionality](#usage)
13+
14+
## Overview
15+
16+
ScaleCommerce Wrapper Module for puppetlabs-postgresql. Manages Supervisord, Databases, Users, Roles.
17+
18+
## Module Description
19+
20+
This module uses hiera to configure Postgresql ressources.
21+
22+
## Setup
23+
24+
### What sc_postgresql affects
25+
26+
* postgresql
27+
* supervisord
28+
29+
### Beginning with sc_postgresql
30+
31+
You will need a working hiera-Setup (https://docs.puppetlabs.com/hiera/3.1/complete_example.html).
32+
33+
Check out our solultion for Puppet-Hiera-Roles (https://github.com/ScaleCommerce/puppet-hiera-roles).
34+
35+
## Usage: Databases
36+
37+
Put this into your node.yaml or role.yaml. See [Documentation of puppetlabs-postgresql](https://github.com/puppetlabs/puppetlabs-postgresql) for details on postgresql yaml syntax.
38+
```
39+
---
40+
classes:
41+
- sc_postgresql
42+
```

‎Rakefile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require 'rubygems'
2+
require 'puppetlabs_spec_helper/rake_tasks'
3+
require 'puppet-lint/tasks/puppet-lint'
4+
PuppetLint.configuration.send('disable_80chars')
5+
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
6+
7+
desc "Validate manifests, templates, and ruby files"
8+
task :validate do
9+
Dir['manifests/**/*.pp'].each do |manifest|
10+
sh "puppet parser validate --noop #{manifest}"
11+
end
12+
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
13+
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
14+
end
15+
Dir['templates/**/*.erb'].each do |template|
16+
sh "erb -P -x -T '-' #{template} | ruby -c"
17+
end
18+
end

‎hiera.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
version: 5
3+
defaults:
4+
datadir: "%{settings::confdir}/hieradata"
5+
data_hash: yaml_data
6+
7+
hierarchy:
8+
- name: overrride
9+
path: override.yaml
10+
- name: common
11+
path: common.yaml
12+
- name: module
13+
path: module.yaml

‎hieradata/common.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
classes:
3+
- supervisord

‎hieradata/module.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
classes:
3+
- sc_postgresql
4+
5+
postgresql::server::postgres_password: very_secret!!
6+
postgresql::server::listen_addresses: "*"
7+
postgresql::server::ip_mask_allow_all_users: "%{ipaddress}"
8+
postgresql::server::service:service_provider: supervisor
9+
10+
sc_postgresql::databases:
11+
my_db:
12+
user: my_user
13+
owner: my_owner
14+
password: also_very_secret!!

‎hieradata/override.yaml

Whitespace-only changes.

‎inspec/sc_postgresql.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# postgresql running in supervisor?
2+
describe command('supervisorctl status postgresql') do
3+
its('stdout') { should match 'RUNNING'}
4+
end

‎install.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
export PATH=/opt/puppetlabs/bin:$PATH
3+
sed -i -e "s/nodaemon=true/nodaemon=false/" /etc/supervisord.conf
4+
/usr/local/bin/supervisord -c /etc/supervisord.conf
5+
echo "Running in $(pwd)"
6+
echo "Puppet Version: $(puppet -V)"
7+
locale
8+
9+
# configure puppet
10+
ln -sf $(pwd)/test/hiera.yaml $(puppet config print confdir |cut -d: -f1)/
11+
ln -sf $(pwd)/test/hieradata $(puppet config print confdir |cut -d: -f1)/hieradata
12+
puppet config set certname puppet-test.scalecommerce
13+
14+
# install puppet modules
15+
puppet module install puppetlabs-postgresql
16+
puppet module install yo61-logrotate
17+
git clone https://github.com/ScaleCommerce/puppet-supervisor_provider.git $(puppet config print modulepath |cut -d: -f1)/supervisor_provider
18+
https://github.com/ScaleCommerce/puppet-sc_bashprofile.git $(puppet config print modulepath |cut -d: -f1)/sc_bashprofile
19+
ln -sf $(pwd) $(puppet config print modulepath |cut -d: -f1)/sc_postgresql
20+
21+
wget -q https://packages.chef.io/files/stable/inspec/2.2.41/ubuntu/16.04/inspec_2.2.41-1_amd64.deb
22+
dpkg -i inspec_*

‎manifests/init.pp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# == Class: sc_postgresql
2+
#
3+
# ScaleCommerce Wrapper Module for puppetlabs-postgresql.
4+
# Manages Supervisord.
5+
#
6+
# === Variables
7+
#
8+
# [*use_supervisor*]
9+
# can be true or false, default is true.
10+
# determines if start script should be used with supervisor
11+
#
12+
# === Authors
13+
#
14+
# Thomas Lohner <tl@scale.sc>
15+
#
16+
# === Copyright
17+
#
18+
# Copyright 2018 ScaleCommerce GmbH.
19+
#
20+
21+
class sc_postgresql (
22+
$use_supervisor = true,
23+
) {
24+
25+
if $use_supervisor {
26+
class {'::sc_postgresql::supervisor':}
27+
}
28+
29+
include postgresql::server
30+
31+
ensure_resources('postgresql::server::db', hiera_hash('sc_postgresql::databases', {}), hiera_hash('sc_postgresql::databases_defaults', {}))
32+
33+
# postgresql::server::role
34+
35+
# postgresql::server::database_grant
36+
37+
38+
# postgresql::server::table_grant
39+
40+
41+
}

‎manifests/supervisor.pp

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class sc_nginx::supervisor(
2+
){
3+
4+
include supervisord
5+
include postgresql::server
6+
include postgresql::repo
7+
8+
file { ['/etc/init/postgresql.conf', '/etc/init.d/postgresql']:
9+
ensure => absent,
10+
require => Package['postgresql-server'],
11+
}
12+
13+
supervisord::program { 'postgresql':
14+
command => "/usr/lib/postgresql/$postgresql::repo::version/bin/postgres -D /var/lib/postgresql/$postgresql::repo::version/main -c config_file=/etc/postgresql/$postgresql::repo::version/main/postgresql.conf",
15+
autostart => true,
16+
autorestart => true,
17+
require => Package['postgresql-server'],
18+
before => Service['postgresqld'],
19+
}
20+
21+
# override default service provider
22+
Service <| title == "postgresqld"|> {
23+
provider => supervisor,
24+
}
25+
}

‎metadata.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "scalecommerce-sc_postgresql",
3+
"version": "0.1",
4+
"author": "Thomas Lohner, ScaleCommerce GmbH",
5+
"summary": "ScaleCommerce Wrapper Module for puppetlabs-postgresql. Manages Databases, Users, Roles.",
6+
"license": "Apache 2.0",
7+
"source": "https://github.com/ScaleCommerce/puppet-sc_postgresql.git",
8+
"project_page": "https://github.com/ScaleCommerce/puppet-sc_postgresql",
9+
"issues_url": "https://github.com/ScaleCommerce/puppet-sc_postgresql/issues",
10+
"dependencies": [
11+
{ "name":"puppetlabs-stdlib","version_requirement":">= 1.0.0" },
12+
{ "name":"puppetlabs-postgresql" }
13+
]
14+
}

‎site.pp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
hiera_include('classes')
2+
3+
# resource wrapper
4+
$files=hiera_hash('files', {})
5+
create_resources(file, $files)
6+
7+
$crons=hiera_hash('crons', {})
8+
create_resources(cron, $crons)
9+
10+
$execs=hiera_hash('execs', {})
11+
create_resources(exec, $execs)
12+
13+
$hosts=hiera_hash('hosts', {})
14+
create_resources(host, $hosts)
15+
16+
$mounts=hiera_hash('mounts', {})
17+
create_resources(mount, $mounts)
18+
19+
$packages=hiera_hash('packages', {})
20+
create_resources(package, $packages)
21+
22+
$services=hiera_hash('services', {})
23+
create_resources(service, $services)

0 commit comments

Comments
 (0)
Please sign in to comment.