From: Stephen Gran Date: Wed, 11 Sep 2013 07:35:18 +0000 (+0100) Subject: refactor X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=62823a752e52be5f80185c80e2e0298cb6f75398;p=mirror%2Fdsa-puppet.git refactor Signed-off-by: Stephen Gran --- diff --git a/modules/roles/manifests/pubsub.pp b/modules/roles/manifests/pubsub.pp index 9cc7bb7d9..2f02be0d3 100644 --- a/modules/roles/manifests/pubsub.pp +++ b/modules/roles/manifests/pubsub.pp @@ -1,11 +1,8 @@ class roles::pubsub { include roles::pubsub::params + include roles::pubsub::entities $cluster_cookie = $roles::pubsub::params::cluster_cookie - $admin_password = $roles::pubsub::params::admin_password - $ftp_password = $roles::pubsub::params::ftp_password - $buildd_password = $roles::pubsub::params::buildd_password - $wbadm_password = $roles::pubsub::params::wbadm_password $cc_master = rainier $cc_secondary = rapoport @@ -37,151 +34,6 @@ class roles::pubsub { source => 'puppet:///modules/roles/pubsub/rabbitmq-mgmt.config' } - rabbitmq_user { 'admin': - admin => true, - password => $admin_password, - provider => 'rabbitmqctl', - } - - rabbitmq_user { 'ftpteam': - admin => true, - password => $ftp_password, - provider => 'rabbitmqctl', - } - - rabbitmq_user { 'buildd': - admin => true, - password => $buildd_password, - provider => 'rabbitmqctl', - } - - rabbitmq_user { 'wbadm': - admin => true, - password => $wbadm_password, - provider => 'rabbitmqctl', - } - - rabbitmq_vhost { 'packages': - ensure => present, - provider => 'rabbitmqctl', - } - - rabbitmq_vhost { 'buildd': - ensure => present, - provider => 'rabbitmqctl', - } - - rabbitmq_user_permissions { 'admin@buildd': - configure_permission => '.*', - read_permission => '.*', - write_permission => '.*', - provider => 'rabbitmqctl', - require => [ - Rabbitmq_user['admin'], - Rabbitmq_vhost['buildd'] - ] - } - rabbitmq_user_permissions { 'admin@packages': - configure_permission => '.*', - read_permission => '.*', - write_permission => '.*', - provider => 'rabbitmqctl', - require => [ - Rabbitmq_user['admin'], - Rabbitmq_vhost['packages'] - ] - } - - rabbitmq_user_permissions { 'admin@/': - configure_permission => '.*', - read_permission => '.*', - write_permission => '.*', - provider => 'rabbitmqctl', - require => Rabbitmq_user['admin'] - } - - rabbitmq_user_permissions { 'ftpteam@packages': - configure_permission => '.*', - read_permission => '.*', - write_permission => '.*', - provider => 'rabbitmqctl', - require => [ - Rabbitmq_user['ftpteam'], - Rabbitmq_vhost['packages'] - ] - } - - rabbitmq_user_permissions { 'wbadm@packages': - read_permission => 'unchecked', - write_permission => 'wbadm', - provider => 'rabbitmqctl', - require => [ - Rabbitmq_user['wbadm'], - Rabbitmq_vhost['packages'] - ] - } - - rabbitmq_user_permissions { 'buildd@buildd': - configure_permission => '.*', - read_permission => '.*', - write_permission => '.*', - provider => 'rabbitmqctl', - require => [ - Rabbitmq_user['buildd'], - Rabbitmq_vhost['buildd'] - ] - } - - rabbitmq_user_permissions { 'wbadm@buildd': - configure_permission => '.*', - read_permission => '.*', - write_permission => '.*', - provider => 'rabbitmqctl', - require => [ - Rabbitmq_user['wbadm'], - Rabbitmq_vhost['buildd'] - ] - } - - rabbitmq_policy { 'mirror-buildd': - vhost => 'buildd', - match => '.*', - policy => '{"ha-mode":"all"}', - require => Rabbitmq_vhost['buildd'] - } - - rabbitmq_policy { 'mirror-packages': - vhost => 'packages', - match => '.*', - policy => '{"ha-mode":"all"}', - require => Rabbitmq_vhost['packages'] - } - - rabbitmq_plugin { 'rabbitmq_management': - ensure => present, - provider => 'rabbitmqplugins', - require => Package['rabbitmq-server'], - notify => Service['rabbitmq-server'] - } - rabbitmq_plugin { 'rabbitmq_management_agent': - ensure => present, - provider => 'rabbitmqplugins', - require => Package['rabbitmq-server'], - notify => Service['rabbitmq-server'] - } - rabbitmq_plugin { 'rabbitmq_tracing': - ensure => present, - provider => 'rabbitmqplugins', - require => Package['rabbitmq-server'], - notify => Service['rabbitmq-server'] - } - rabbitmq_plugin { 'rabbitmq_management_visualiser': - ensure => present, - provider => 'rabbitmqplugins', - require => Package['rabbitmq-server'], - notify => Service['rabbitmq-server'] - } - @ferm::rule { 'rabbitmq': description => 'rabbitmq connections', rule => '&SERVICE_RANGE(tcp, 5671, $HOST_DEBIAN_V4)' diff --git a/modules/roles/manifests/pubsub/entities.pp b/modules/roles/manifests/pubsub/entities.pp new file mode 100644 index 000000000..d06832fa3 --- /dev/null +++ b/modules/roles/manifests/pubsub/entities.pp @@ -0,0 +1,154 @@ +class roles::pubsub::entities { + include roles::pubsub::params + + $admin_password = $roles::pubsub::params::admin_password + $ftp_password = $roles::pubsub::params::ftp_password + $buildd_password = $roles::pubsub::params::buildd_password + $wbadm_password = $roles::pubsub::params::wbadm_password + + rabbitmq_user { 'admin': + admin => true, + password => $admin_password, + provider => 'rabbitmqctl', + } + + rabbitmq_user { 'ftpteam': + admin => true, + password => $ftp_password, + provider => 'rabbitmqctl', + } + + rabbitmq_user { 'buildd': + admin => true, + password => $buildd_password, + provider => 'rabbitmqctl', + } + + rabbitmq_user { 'wbadm': + admin => true, + password => $wbadm_password, + provider => 'rabbitmqctl', + } + + rabbitmq_vhost { 'packages': + ensure => present, + provider => 'rabbitmqctl', + } + + rabbitmq_vhost { 'buildd': + ensure => present, + provider => 'rabbitmqctl', + } + + rabbitmq_user_permissions { 'admin@/': + configure_permission => '.*', + read_permission => '.*', + write_permission => '.*', + provider => 'rabbitmqctl', + require => Rabbitmq_user['admin'] + } + + rabbitmq_user_permissions { 'admin@buildd': + configure_permission => '.*', + read_permission => '.*', + write_permission => '.*', + provider => 'rabbitmqctl', + require => [ + Rabbitmq_user['admin'], + Rabbitmq_vhost['buildd'] + ] + } + rabbitmq_user_permissions { 'admin@packages': + configure_permission => '.*', + read_permission => '.*', + write_permission => '.*', + provider => 'rabbitmqctl', + require => [ + Rabbitmq_user['admin'], + Rabbitmq_vhost['packages'] + ] + } + + rabbitmq_user_permissions { 'ftpteam@packages': + configure_permission => '.*', + read_permission => '.*', + write_permission => '.*', + provider => 'rabbitmqctl', + require => [ + Rabbitmq_user['ftpteam'], + Rabbitmq_vhost['packages'] + ] + } + + rabbitmq_user_permissions { 'wbadm@packages': + read_permission => 'unchecked', + write_permission => 'wbadm', + provider => 'rabbitmqctl', + require => [ + Rabbitmq_user['wbadm'], + Rabbitmq_vhost['packages'] + ] + } + + rabbitmq_user_permissions { 'buildd@buildd': + configure_permission => '.*', + read_permission => '.*', + write_permission => '.*', + provider => 'rabbitmqctl', + require => [ + Rabbitmq_user['buildd'], + Rabbitmq_vhost['buildd'] + ] + } + + rabbitmq_user_permissions { 'wbadm@buildd': + configure_permission => '.*', + read_permission => '.*', + write_permission => '.*', + provider => 'rabbitmqctl', + require => [ + Rabbitmq_user['wbadm'], + Rabbitmq_vhost['buildd'] + ] + } + + rabbitmq_policy { 'mirror-buildd': + vhost => 'buildd', + match => '.*', + policy => '{"ha-mode":"all"}', + require => Rabbitmq_vhost['buildd'] + } + + rabbitmq_policy { 'mirror-packages': + vhost => 'packages', + match => '.*', + policy => '{"ha-mode":"all"}', + require => Rabbitmq_vhost['packages'] + } + + rabbitmq_plugin { 'rabbitmq_management': + ensure => present, + provider => 'rabbitmqplugins', + require => Package['rabbitmq-server'], + notify => Service['rabbitmq-server'] + } + rabbitmq_plugin { 'rabbitmq_management_agent': + ensure => present, + provider => 'rabbitmqplugins', + require => Package['rabbitmq-server'], + notify => Service['rabbitmq-server'] + } + rabbitmq_plugin { 'rabbitmq_tracing': + ensure => present, + provider => 'rabbitmqplugins', + require => Package['rabbitmq-server'], + notify => Service['rabbitmq-server'] + } + rabbitmq_plugin { 'rabbitmq_management_visualiser': + ensure => present, + provider => 'rabbitmqplugins', + require => Package['rabbitmq-server'], + notify => Service['rabbitmq-server'] + } + +}