Dzahn has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/260694

Change subject: mha: move roles to module/role/
......................................................................

mha: move roles to module/role/

Change-Id: Ia125c22c3d8ed9c2069d3c0920bff4e028b71f3a
---
A modules/role/manifests/mha/manager.pp
R modules/role/manifests/mha/mha.pp
A modules/role/manifests/mha/node.pp
3 files changed, 114 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/94/260694/1

diff --git a/modules/role/manifests/mha/manager.pp 
b/modules/role/manifests/mha/manager.pp
new file mode 100644
index 0000000..2d2cc09
--- /dev/null
+++ b/modules/role/manifests/mha/manager.pp
@@ -0,0 +1,88 @@
+class mha::manager inherits role::coredb::config {
+    include mha::node
+    include passwords::misc::scripts
+
+    $mysql_root_pass = $passwords::misc::scripts::mysql_root_pass
+    $mysql_repl_pass = $passwords::misc::scripts::mysql_repl_pass
+
+    package { 'mha4mysql-manager':
+        ensure => latest,
+    }
+
+    file { '/etc/mha':
+        ensure => directory,
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0550',
+    }
+
+    file { '/etc/mha/primary_site':
+        content => "${::mw_primary}\n",
+    }
+
+    file { '/usr/local/bin/master_ip_online_change':
+        source => 'puppet:///files/mha/master_ip_online_change',
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0555',
+    }
+
+    file { '/usr/local/bin/mha_site_switch':
+        source => 'puppet:///files/mha/mha_site_switch',
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0544',
+    }
+
+    $shardlist = inline_template('<%= topology.keys.join(',') %>')
+    $shards    = split($shardlist, ',')
+
+    define mha_shard_config(
+        $shard  = {},
+        $site   = '',
+        $altsite= '',
+) {
+        file { "/etc/mha/${name}.cnf":
+            owner   => 'root',
+            group   => 'root',
+            mode    => '0400',
+            content => template('mha/local.erb'),
+            require => File['/etc/mha'],
+        }
+    }
+
+    define mha_dc_switch( $shard={} ) {
+        file { "/etc/mha/${name}-dc.cnf":
+            owner   => 'root',
+            group   => 'root',
+            mode    => '0400',
+            content => template('mha/siteswitch.erb'),
+            require => File['/etc/mha'],
+        }
+    }
+
+    define mha_coredb_config( $topology={} ) {
+        $shard = $topology[$name]
+        if $shard['primary_site'] and $shard['primary_site'] != 'both' {
+            # eqiad
+            mha_shard_config { "${name}-eqiad":
+                shard   => $shard,
+                site    => 'eqiad',
+                altsite => 'codfw',
+            }
+            # codfw
+            mha_shard_config { "${name}-codfw":
+                shard   => $shard,
+                site    => 'codfw',
+                altsite => 'eqiad',
+            }
+            # dc switch
+            mha_dc_switch { $name:
+                shard => $shard,
+            }
+
+        }
+    }
+
+    mha_coredb_config { $shards: topology => $topology }
+}
diff --git a/manifests/role/mha.pp b/modules/role/manifests/mha/mha.pp
similarity index 100%
rename from manifests/role/mha.pp
rename to modules/role/manifests/mha/mha.pp
diff --git a/modules/role/manifests/mha/node.pp 
b/modules/role/manifests/mha/node.pp
new file mode 100644
index 0000000..0565779
--- /dev/null
+++ b/modules/role/manifests/mha/node.pp
@@ -0,0 +1,26 @@
+class mha::node {
+    package { 'mha4mysql-node':
+        ensure => latest,
+    }
+
+    file { [ '/home/mysql', '/home/mysql/.ssh' ]:
+        ensure  => directory,
+        owner   => 'mysql',
+        group   => 'mysql',
+        mode    => '0700',
+        require => User['mysql'],
+    }
+
+    file { '/home/mysql/.ssh/mysql.key':
+        owner  => 'mysql',
+        group  => 'mysql',
+        mode   => '0400',
+        content => secret('ssh/mysql/mysql.key'),
+    }
+
+    ssh::userkey { 'mysql':
+        ensure  => present,
+        content => 'ssh-rsa 
AAAAB3NzaC1yc2EAAAADAQABAAABAQDryVraiGfd0eQzV0QB/xXvgiPvpp8qt/BEqT9xWpohPNC1MevM+SMGmpimCLyvv35JDmz1DiJwJf72GKakDqWdbp/pBHitr0VV3eANpLyYiDTWir75SEF9F/WxkRTbEe/tErJc0tsksVGIm+36r3eHrrz68AkJJZVhcQMMXPx6Ye1NIy5qJ/i7cSSAxkanHlXiX+lnGMIxYUKuiVVl7kxrGDAvaLeszZKdYn8WkMH32MuL/M66ff9vBY7pGGM8MubjGMxL878hpimhTrLcmay7l4nuAMW6UUnkqufx6ArT80RWDWz5woFvyheBdVDnQZI06cJzj3WG6rWt8eG/A1SL
 mha@production',
+    }
+}
+

-- 
To view, visit https://gerrit.wikimedia.org/r/260694
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia125c22c3d8ed9c2069d3c0920bff4e028b71f3a
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Dzahn <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to