Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixtures:
forge_modules:
stdlib: "puppetlabs/stdlib"
systemd: "camptocamp/systemd"
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.rb eol=lf
*.erb eol=lf
*.pp eol=lf
*.sh eol=lf
*.epp eol=lf
37 changes: 27 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
.vagrant
*~
.vagrantuser
*.swp
tags
*.orig
*.rej
Gemfile.lock
log
pkg
.git/
.*.sw[op]
.metadata
.yardoc
.yardwarns
*.iml
/.bundle/
/.idea/
/.vagrant/
/coverage/
/bin/
/doc/
/Gemfile.local
/Gemfile.lock
/junit/
/log/
/pkg/
/spec/fixtures/manifests/
/spec/fixtures/modules/
/tmp/
/vendor/
/convert_report.txt
/update_report.txt
.DS_Store
.project
.envrc
/inventory.yaml
52 changes: 38 additions & 14 deletions manifests/process.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
# Group of the config file
#
define lsyncd::process (
$source = undef,
$content = undef,
$owner = 'root',
$group = 'root',
$source = undef,
$content = undef,
$owner = 'root',
$group = 'root',
$systemd_template = 'lsyncd/systemd_unit.epp',
) {

include lsyncd
Expand All @@ -37,23 +38,46 @@
}

$cfgfile = "${lsyncd::confdir}/${name}.lua"
$process = "lsyncd ${cfgfile}"

file { $cfgfile:
ensure => file,
owner => $owner,
group => $group,
mode => '0644',
source => $source,
content => $content,
} ~>

service { "lsyncd-${name}":
ensure => running,
provider => 'debian',
start => "sudo -u ${owner} ${process}",
status => "pgrep -f '^${process}$'",
stop => "pkill --signal KILL -f '^${process}$'",
}

if ($facts['systemd']) {
$process = $facts['os']['family'] ? {
'RedHat' => '/bin/lsyncd',
default => '/usr/local/bin/lsyncd'
}

$template_hash = {
'name' => $name,
'lsyncd_path' => $process,
'user' => $owner,
'lua_file' => $cfgfile,
}
systemd::unit_file { "lsyncd-${name}.service":
content => epp($systemd_template, $template_hash)
}
~>
service { "lsyncd-${name}":
ensure => 'running',
enable => true,
}
} else {
$process = "lsyncd ${cfgfile}"

service { "lsyncd-${name}":
ensure => running,
provider => 'debian',
start => "sudo -u ${owner} ${process}",
status => "pgrep -f '^${process}$'",
stop => "pkill --signal KILL -f '^${process}$'",
require => File[$cfgfile]
}

}
}
29 changes: 25 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,38 @@
"name": "spjmurray-lsyncd",
"version": "1.0.1",
"author": "Simon Murray",
"license": "GPL-3.0",
"summary": "Lsyncd orchestration",
"license": "GPL-3.0",
"source": "https://github.com/spjmurray/puppet-lsyncd",
"project_page": "https://github.com/spjmurray/puppet-lsyncd",
"issues_url": "https://github.com/spjmurray/puppet-lsyncd/issues",
"tags": ["lsyncd"],
"operatingsystem_support": [
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [ "14.04", "14.10", "15.04" ]
"operatingsystemrelease": [
"14.04",
"14.10",
"15.04",
"16.04"
]
}
],
"dependencies": [
{
"name": "camptocamp/systemd",
"version_requirement": ">= 2.2.0 < 3.0.0"
}
],
"dependencies": []
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 4.10.0 < 7.0.0"
}
],
"tags": [
"lsyncd"
],
"pdk-version": "1.10.0",
"template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git#1.10.0",
"template-ref": "1.10.0-0-gbba9ac3"
}
11 changes: 11 additions & 0 deletions spec/classes/lsyncd_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

describe 'lsyncd' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

it { is_expected.to compile }
end
end
end
7 changes: 7 additions & 0 deletions spec/default_facts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Use default_module_facts.yml for module specific facts.
#
# Facts specified here will override the values provided by rspec-puppet-facts.
---
ipaddress: "172.16.254.254"
is_pe: false
macaddress: "AA:AA:AA:AA:AA:AA"
32 changes: 32 additions & 0 deletions spec/defines/process_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'spec_helper'

describe 'lsyncd::process' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:title) { 'test' }
let(:params) { {'content' => 'test'} }
let(:facts) { os_facts }

it { is_expected.to compile }
end
end

systemd = {
:supported_os => [
{
'operatingsystem' => 'Ubuntu',
'operatingsystemrelease' => ['16.04'],
}
],
}
on_supported_os(systemd).each do |os, os_facts|
context "on #{os} (testing systemd)" do
let(:title) { 'test' }
let(:params) { {'content' => 'test'} }
let(:facts) { os_facts.merge({'systemd' => true}) }

it { is_expected.to compile }
it { is_expected.to contain_systemd__unit_file('lsyncd-test.service') }
end
end
end
16 changes: 16 additions & 0 deletions templates/systemd_unit.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%- | String $name,
String $lsyncd_path,
String $user,
String $lua_file
| -%>
[Unit]
Description=Live Syncing (Mirror) Daemon - <%= $name %>
After=network.target

[Service]
Type=simple
User=<%= $user %>
ExecStart=/usr/bin/lsyncd -nodaemon <%= $lua_file %>

[Install]
WantedBy=multi-user.target