Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
heliocentric committed Jul 10, 2017
2 parents 5482a8a + 69ddddd commit 77e9ee8
Show file tree
Hide file tree
Showing 46 changed files with 1,109 additions and 409 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
# S6.0.0 4.7 2.1.9
---
language: ruby
sudo: false
sudo: true
cache: bundler
services:
- docker
- vagrant
before_script:
- ./prep_ci.sh
- bundle
bundler_args: --without development system_tests
before_install: rm Gemfile.lock || true
script:
- bundle exec rake test
- docker run -e LOCAL_USER_ID=1000 -it --rm -v $(pwd):/data:Z simpproject/centos:6-ruby21 bundle exec rake spec
notifications:
email: false
rvm:
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
* Sat Jul 10 2017 Dylan Cochran <[email protected]> - 0.3.0
- (SIMP-2961) Add automatic cluster creation for consul.
- (SIMP-3130) metadata needs to default to 'String'.
- (SIMP-3129) atomic_create needs to create metadata
- (SIMP-3127) libkv can't list / since metadata update
- (SIMP-3122) Move the libkv wrapper outside the loader
- (SIMP-3125) Move key regex match into libkv wrapper
- (SIMP-3110) Use <key>.meta to convert a value to the correct type
- (SIMP-3060) Fix travisci tests
- (SIMP-3109) Create a <key>.meta key to store type

* Sat Apr 29 2017 Dylan Cochran <[email protected]> - 0.2.0
- (SIMP-2978) Fix readme generation
- (SIMP-3019) Add ssl/tls support to consul backend
Expand Down
38 changes: 38 additions & 0 deletions bootstrap/consul.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
file { "/etc/simp":
ensure => directory,
}
file { "/etc/simp/bootstrap/":
ensure => directory,
}
file { "/etc/simp/bootstrap/consul":
ensure => directory,
}
exec { "/usr/bin/uuidgen >/etc/simp/bootstrap/consul/master_token":
creates => '/etc/simp/bootstrap/consul/master_token',
require => File["/etc/simp/bootstrap/consul"],
} ->
exec { "/opt/puppetlabs/bin/puppet cert generate server.dc1.consul":
creates => '/etc/puppetlabs/puppet/ssl/private_keys/server.dc1.consul.pem',
} ->
file { "/etc/simp/bootstrap/consul/server.dc1.consul.private.pem":
source => '/etc/puppetlabs/puppet/ssl/private_keys/server.dc1.consul.pem',
} ->
file { "/etc/simp/bootstrap/consul/server.dc1.consul.cert.pem":
source => '/etc/puppetlabs/puppet/ssl/certs/server.dc1.consul.pem',
} ->
file { "/etc/simp/bootstrap/consul/ca.pem":
source => '/etc/puppetlabs/puppet/ssl/ca/ca_crt.pem',
} ->
class { "libkv::consul":
dont_copy_files => true,
bootstrap => true,
server => true,
} ->
exec { "/usr/local/bin/consul keygen >/etc/simp/bootstrap/consul/key":
path => $::path,
creates => '/etc/simp/bootstrap/consul/key',
} ->
file { "/opt/puppetlabs/facter/facts.d/consul_bootstrap.sh":
mode => "a+x",
content => "#!/bin/sh\necho 'consul_bootstrap=true'",
}
16 changes: 16 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
lookup_options:
libkv::consul::config_hash:
merge: hash
libkv::consul::config_hash:
acl_datacenter: "dc1"
acl_default_policy: "deny"
addresses:
http: '127.0.0.1'
https: '0.0.0.0'
ports:
https: 8501
http: 8500
data_dir: '/opt/consul'
node_name: "%{::hostname}"
client_addr: '0.0.0.0'
ui_dir: /opt/consul/ui
26 changes: 26 additions & 0 deletions files/consul/consul-create-acl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
TOKEN=$(cat $1)
OUTPUTFILE=$2
# Give consul some time to attempt a join, then realize it's bootstrapping
# a new cluster
sleep 10
if [ "${TYPE}" = "" ] ; then
TYPE="libkv"
fi
case "${TYPE}" in
libkv)
POLICY='{
"Name": "libkv-acl",
"Type": "client",
"Rules": "{\"key\":{\"puppet/\":{\"policy\":\"write\"}},\"operator\":\"read\"}"
}'
;;
agent)
POLICY='{
"Name": "agent-acl",
"Taype": "client",
"Rules": "{\"key\":{\"\":{\"policy\":\"write\"}, \"puppet/\":{\"policy\":\"deny\"}},\"operator\":\"read\"}"
}'
;;
esac
curl --request PUT --data "${POLICY}" -q http://localhost:8500/v1/acl/create?token="${TOKEN}" | cut -d '"' -f 4 >"${OUTPUTFILE}"
10 changes: 10 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
version: 4
datadir: data
hierarchy:
- name: "OSFamily + Release"
backend: "yaml"
path: "os/%{facts.osfamily}-%{facts.operatingsystemmajrelease}"
- name: "Common"
backend: "yaml"
path: "common"
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/atomic_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,6 @@ def atomic_create(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = {}
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.atomic_create(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/atomic_delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,6 @@ def atomic_delete(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = {}
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.atomic_delete(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/atomic_get.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ def atomic_get(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = {}
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.atomic_get(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/atomic_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ def atomic_list(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = {}
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.atomic_list(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/atomic_put.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,6 @@ def atomic_put(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = {}
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.atomic_put(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ def delete(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = false
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.delete(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/deletetree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ def deletetree(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = false
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.deletetree(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/empty_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ def empty_value(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = nil
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.empty_value(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/exists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ def exists(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = nil
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.exists(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/get.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ def get(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = nil
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.get(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ def info(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = {}
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.info(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ def list(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = {}
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.list(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/newlock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ def newlock(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval =
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.newlock(url, auth, params);
Expand Down
12 changes: 0 additions & 12 deletions lib/puppet/functions/libkv/pop_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ def pop_error(params)
auth = call_function('lookup', 'libkv::auth', { 'default_value' => nil })
end
params["auth"] = auth
if params.key?('key')
regex = /^\/[a-zA-Z0-9._\-\/]*$/
error_msg = "the specified key, '#{params['key']}' does not match regex '#{regex}'"
unless (regex =~ params['key'])
if (params["softfail"] == true)
retval = ""
return retval
else
raise "the specified key, '#{params['key']}' does not match regex '#{regex}'"
end
end
end
if (params["softfail"] == true)
begin
retval = libkv.pop_error(url, auth, params);
Expand Down
Loading

0 comments on commit 77e9ee8

Please sign in to comment.