From: Stephen Gran Date: Wed, 15 Jan 2014 16:41:12 +0000 (+0000) Subject: make pubsub.conf a concat fragment X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=022adef6d30cad4e24b596ec9d89c189f7426245;p=mirror%2Fdsa-puppet.git make pubsub.conf a concat fragment Signed-off-by: Stephen Gran --- diff --git a/modules/roles/manifests/dbmaster.pp b/modules/roles/manifests/dbmaster.pp index 537588417..5a962096b 100644 --- a/modules/roles/manifests/dbmaster.pp +++ b/modules/roles/manifests/dbmaster.pp @@ -1,5 +1,27 @@ +# = Class: roles::dbmaster +# +# Setup for db.debian.org master host +# +# == Sample Usage: +# +# include roles::dbmaster +# class roles::dbmaster { + + include roles::pubsub::params + + $rabbit_password = $roles::pubsub::params::rabbit_password + ssl::service { 'db.debian.org': notify => Service['apache2'], } + + roles::pubsub::config { 'generate': + key => 'dsa-udgenerate', + exchange => dsa, + topic => 'dsa.ud.replicate', + vhost => dsa, + username => $::fqdn, + password => $rabbit_password + } } diff --git a/modules/roles/manifests/pubsub/client.pp b/modules/roles/manifests/pubsub/client.pp index 41c57b53f..df220ff42 100644 --- a/modules/roles/manifests/pubsub/client.pp +++ b/modules/roles/manifests/pubsub/client.pp @@ -8,15 +8,31 @@ # class roles::pubsub::client { - $rabbit_password = hkdf('/etc/puppet/secret', "mq-client-${::fqdn}") + include roles::pubsub::params - file { '/etc/dsa/pubsub.conf': - content => template('roles/pubsub/pubsub.conf.erb'), - mode => '0440' - } + $rabbit_password = $roles::pubsub::params::rabbit_password package { 'python-dsa-mq': ensure => latest, tag => extra_repo, } + + roles::pubsub::config { 'homedirs': + key => 'dsa-homedirs', + exchange => dsa, + topic => 'dsa.git.homedirs', + vhost => dsa, + username => $::fqdn, + password => $rabbit_password + } + + roles::pubsub::config { 'replicate': + key => 'dsa-udreplicate', + exchange => dsa, + queue => "ud-${::fqdn}", + topic => 'dsa.ud.replicate', + vhost => dsa, + username => $::fqdn, + password => $rabbit_password + } } diff --git a/modules/roles/manifests/pubsub/config.pp b/modules/roles/manifests/pubsub/config.pp new file mode 100644 index 000000000..7c9e38d38 --- /dev/null +++ b/modules/roles/manifests/pubsub/config.pp @@ -0,0 +1,67 @@ +# = Define: roles::pubsub::config +# +# Connection stanzas for pubsub clients +# +# === Parameters +# +# [*key*] +# The lookup key for the ini file, ie: +# [foo] <- this +# a=b +# +# [*topic*] +# The topic to send or receive on +# +# [*username*] +# Authentication username for the connection +# Defaults to $::fqdn +# +# [*password*] +# Authentication password for the connection +# +# [*vhost*] +# RabbitMQ vhost to use for the connection +# Defaults to 'dsa' +# +# [*exchange*] +# RabbitMQ exchange to use for the connection +# Defaults to 'dsa' +# +# [*queue*] +# RabbitMQ queue to use for the connection +# Only necessary on connections where client is receiving messages +# +# [*order*] +# Ordering hint for concat +# Defaults to '00' +# +# == Sample Usage: +# +# roles::pubsub::config { 'testme': +# key => 'test', +# exchange => dsa, +# topic => 'dsa.git.test', +# vhost => dsa, +# username => $::fqdn, +# password => 1234, +# order => 00 +# } +# +define roles::pubsub::config ( + $key, + $topic, + $password, + $vhost=dsa, + $exchange=dsa, + $username=$::fqdn, + $queue=undef, + $order=00 +){ + include roles::pubsub::config::setup + + concat::fragment { "pubsub_conf_${name}": + target => '/etc/dsa/pubsub.conf', + source => 'puppet:///modules/roles/pubsub/pubsub.conf.erb', + order => $order, + } +} diff --git a/modules/roles/manifests/pubsub/config/setup.pp b/modules/roles/manifests/pubsub/config/setup.pp new file mode 100644 index 000000000..06de10694 --- /dev/null +++ b/modules/roles/manifests/pubsub/config/setup.pp @@ -0,0 +1,17 @@ +# = Class: roles::pubsub::config::setup +# +# Sets up concat fragments for pubsub config stanzas +# +# == Sample Usage: +# +# include roles::pubsub::config::setup +# +class roles::pubsub::config::setup { + include concat::setup + + concat { '/etc/dsa/pubsub.conf': + owner => root, + group => root, + mode => '0440', + } +} diff --git a/modules/roles/templates/pubsub/pubsub.conf.erb b/modules/roles/templates/pubsub/pubsub.conf.erb index cf705de03..0e9ff564d 100644 --- a/modules/roles/templates/pubsub/pubsub.conf.erb +++ b/modules/roles/templates/pubsub/pubsub.conf.erb @@ -1,14 +1,10 @@ -[dsa-homedirs] -vhost=dsa -topic=dsa.git.homedirs -exchange=dsa -username=<%= @fqdn %> -password=<%= @rabbit_password %> +[<%= @key -%>] +vhost=<%= @vhost %> +topic=<%= @topic %> +exchange=<%= @exchange % +username=<%= @username %> +password=<%= @password %> +<% if @queue -%> +queue=<%= @queue %> +<% end -%> -[dsa-udreplicate] -vhost=dsa -topic=dsa.ud.replicate -exchange=dsa -username=<%= @fqdn %> -password=<%= @rabbit_password %> -queue=ud-<%= @fqdn %>