-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(SIMP-2961) Add automatic cluster creation for consul.
- Add a bootstrap manifest to mark a consul server for bootstrapping, and generates the certificate, keys, and tokens necessary for libkv - Add hiera data-in-modules for the consul configuration data. - Fix debugging output for libkv::put - Add 'consul-create-acl' command that can use a master token to generate a new acl from a hard coded template, for use by libkv
- Loading branch information
1 parent
d68ea45
commit 159757c
Showing
6 changed files
with
261 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters