Faidon Liambotis has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/356109 )
Change subject: labstore: avoid the hardcoding of eth0/eth1 ...................................................................... labstore: avoid the hardcoding of eth0/eth1 Instead of hardcoding eth0 and eth1 in a bunch of places, use $monitor_iface (for eth0) and $data_iface (eth1) as parameters to role::labs::nfs::secondary and pass them to included classes as needed. We could use $facts['interface_primary'] for $monitor_iface (instead of eth0), but since we have to hardcode the value for $data_iface, that would be of limited value. Change-Id: I761da8f8d2e07e596c2d81a69d48543dc88ece2a --- M modules/labstore/files/monitor/check_drbd_cluster_ip M modules/labstore/manifests/monitoring/secondary.pp M modules/role/manifests/labs/nfs/secondary.pp M modules/role/templates/labs/nfs/nfs-manage.sh.erb 4 files changed, 29 insertions(+), 21 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/09/356109/1 diff --git a/modules/labstore/files/monitor/check_drbd_cluster_ip b/modules/labstore/files/monitor/check_drbd_cluster_ip index 47b4f5f..6ed247c 100644 --- a/modules/labstore/files/monitor/check_drbd_cluster_ip +++ b/modules/labstore/files/monitor/check_drbd_cluster_ip @@ -4,7 +4,7 @@ import sys -def check_cluster_ip(node, role, ip): +def check_cluster_ip(node, role, interface, ip): """ If role is primary, check that cluster ip is assigned to the eth0 interface, else make sure it is not. @@ -13,9 +13,8 @@ :param ip: string :returns: boolean """ - # Check if the ip string is present in the list of ipv4 IPs assigned to the - # eth0 interface - ip_assigned = ip in str(subprocess.check_output(['/bin/ip', '-4', 'a', 'list', 'eth0'])) + # Check if the ip is present in the list of IPv4 IPs assigned to interface + ip_assigned = ip in str(subprocess.check_output(['/bin/ip', '-4', 'a', 'list', interface])) if (role == 'primary' and ip_assigned) or \ (role == 'secondary' and not ip_assigned): print('Cluster IP assignment OK') @@ -32,10 +31,11 @@ to DRBD primary') parser.add_argument('node', help='Hostname of node being checked') parser.add_argument('role', help='Expected drbd role, primary|secondary') + parser.add_argument('interface', help='Interface with an IP assigned') parser.add_argument('ip', help='Cluster IP assigned to primary node') args = parser.parse_args() - if not check_cluster_ip(args.node, args.role, args.ip): + if not check_cluster_ip(args.node, args.role, args.interface, args.ip): sys.exit(1) diff --git a/modules/labstore/manifests/monitoring/secondary.pp b/modules/labstore/manifests/monitoring/secondary.pp index c58c0b5..035f350 100644 --- a/modules/labstore/manifests/monitoring/secondary.pp +++ b/modules/labstore/manifests/monitoring/secondary.pp @@ -7,7 +7,7 @@ # - check that cluster ip is assigned to DRBD primary # - NFS is being served over cluster IP -class labstore::monitoring::secondary($drbd_role, $cluster_ip, $resource = 'all') { +class labstore::monitoring::secondary($drbd_role, $cluster_iface, $cluster_ip, $resource = 'all') { sudo::user { 'nagios_check_drbd': user => 'nagios', @@ -54,7 +54,7 @@ nrpe::monitor_service { 'check_drbd_cluster_ip': description => 'DRBD Cluster IP assignment', - nrpe_command => "/usr/bin/sudo /usr/local/sbin/check_drbd_cluster_ip ${::hostname} ${drbd_role} ${cluster_ip}", + nrpe_command => "/usr/bin/sudo /usr/local/sbin/check_drbd_cluster_ip ${::hostname} ${drbd_role} ${cluster_iface} ${cluster_ip}", require => File['/usr/local/sbin/check_drbd_cluster_ip'], } diff --git a/modules/role/manifests/labs/nfs/secondary.pp b/modules/role/manifests/labs/nfs/secondary.pp index 2c102f9..90bc994 100644 --- a/modules/role/manifests/labs/nfs/secondary.pp +++ b/modules/role/manifests/labs/nfs/secondary.pp @@ -1,4 +1,7 @@ -class role::labs::nfs::secondary($monitor = 'eth0') { +class role::labs::nfs::secondary( + $monitor_iface = 'eth0', + $data_iface = 'eth1', +) { system::role { 'role::labs::nfs::secondary': description => 'NFS secondary share cluster', @@ -10,10 +13,12 @@ include role::labs::db::maintain_dbusers # Enable RPS to balance IRQs over CPUs - interface::rps { $monitor: } + interface::rps { 'monitor': + interface => $monitor_iface, + } - interface::manual{ 'eth1': - interface => 'eth1', + interface::manual{ 'data': + interface => $data_iface, } if $::hostname == 'labstore1005' { @@ -21,10 +26,10 @@ $drbd_role = 'primary' interface::ip { 'drbd-replication': - interface => 'eth1', + interface => $data_iface, address => '192.168.0.2', prefixlen => '30', - require => Interface::Manual['eth1'], + require => Interface::Manual[$data_iface], } } @@ -33,10 +38,10 @@ $drbd_role = 'secondary' interface::ip { 'drbd-replication': - interface => 'eth1', + interface => $data_iface, address => '192.168.0.1', prefixlen => '30', - require => Interface::Manual['eth1'], + require => Interface::Manual[$data_iface], } } @@ -98,12 +103,15 @@ } include labstore::monitoring::exports - include labstore::monitoring::interfaces include labstore::monitoring::ldap include labstore::monitoring::nfsd + class { 'labstore::monitoring::interfaces': + monitor_iface => $monitor_iface, + } class { 'labstore::monitoring::secondary': - drbd_role => $drbd_role, - cluster_ip => $cluster_ip, + drbd_role => $drbd_role, + cluster_iface => $monitor_iface, + cluster_ip => $cluster_ip, } if($drbd_role == 'primary') { diff --git a/modules/role/templates/labs/nfs/nfs-manage.sh.erb b/modules/role/templates/labs/nfs/nfs-manage.sh.erb index 01fdd7b..abfa5c4 100644 --- a/modules/role/templates/labs/nfs/nfs-manage.sh.erb +++ b/modules/role/templates/labs/nfs/nfs-manage.sh.erb @@ -27,10 +27,10 @@ fi /sbin/drbdadm primary all - /bin/ip address add <%= @cluster_ip %>/24 dev eth0 + /bin/ip address add <%= @cluster_ip %>/24 dev <%= @monitor_iface %> /usr/sbin/arping -c 3 -S <%= @cluster_ip %> \ - -i eth0 <%= @subnet_gateway_ip %> &> /dev/null + -i <%= @monitor_iface %> <%= @subnet_gateway_ip %> &> /dev/null <% @drbd_resource_config.each do |resource, config| %> mount -o noatime <%= config['device'] %> <%= config['mount_path'] -%> @@ -54,7 +54,7 @@ <% end %> /sbin/drbdadm secondary all - /bin/ip a del <%= @cluster_ip %>/24 dev eth0 + /bin/ip a del <%= @cluster_ip %>/24 dev <%= @monitor_iface %> /usr/sbin/drbd-overview ;; status) -- To view, visit https://gerrit.wikimedia.org/r/356109 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I761da8f8d2e07e596c2d81a69d48543dc88ece2a Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Faidon Liambotis <fai...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits