Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions manifests/resource.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,34 @@
# [ha_primary] If the resource is being applied on the primary host.
# [initial_setup] If this run is associated with the initial setup. Allows a user
# to only perform dangerous setup on the initial run.
# [startup_parameters] Manage startup{} parameters (like wfc-timeout)
define drbd::resource (
$host1 = undef,
$host2 = undef,
$ip1 = undef,
$ip2 = undef,
$res1 = undef,
$res2 = undef,
$cluster = undef,
$secret = false,
$port = '7789',
$device = '/dev/drbd0',
$mountpoint = "/drbd/${name}",
$automount = true,
$owner = 'root',
$group = 'root',
$protocol = 'C',
$verify_alg = 'crc32c',
$rate = false,
$disk_parameters = false,
$net_parameters = false,
$manage = true,
$ha_primary = false,
$initial_setup = false,
$fs_type = 'ext4',
$mkfs_opts = '',
$disk = undef,
$host1 = undef,
$host2 = undef,
$ip1 = undef,
$ip2 = undef,
$res1 = undef,
$res2 = undef,
$cluster = undef,
$secret = false,
$port = '7789',
$device = '/dev/drbd0',
$mountpoint = "/drbd/${name}",
$automount = true,
$owner = 'root',
$group = 'root',
$protocol = 'C',
$verify_alg = 'crc32c',
$rate = false,
$disk_parameters = false,
$net_parameters = false,
$manage = true,
$ha_primary = false,
$initial_setup = false,
$fs_type = 'ext4',
$mkfs_opts = '',
$disk = undef,
$startup_parameters = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be Optional[Hash[String, String]] $startup_parameters = undef instead?

) {
include ::drbd

Expand Down
4 changes: 2 additions & 2 deletions manifests/resource/up.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
exec { "initialize DRBD metadata for ${name}":
command => "yes yes | drbdadm create-md ${name}",
onlyif => "test -e ${disk}",
unless => "drbdadm dump-md ${name} || (drbdadm cstate ${name} | egrep -q '^(Sync|Connected|WFConnection|StandAlone|Verify)')",
unless => "drbdadm dump-md ${name} || (drbdadm cstate ${name} | egrep -q '^(Sync|Connected|Connecting|WFConnection|StandAlone|Verify)')",
before => Service['drbd'],
require => [
Exec['modprobe drbd'],
Expand All @@ -41,7 +41,7 @@
# these things should only be done on the primary during initial setup
if $initial_setup {
exec { "drbd_make_primary_${name}":
command => "drbdadm -- --overwrite-data-of-peer primary ${name}",
command => "drbdadm -- --overwrite-data-of-peer --force primary ${name}",
unless => "drbdadm role ${name} | egrep '^Primary'",
onlyif => "drbdadm dstate ${name} | egrep '^Inconsistent'",
notify => Exec["drbd_format_volume_${name}"],
Expand Down
8 changes: 8 additions & 0 deletions templates/header.res.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ resource <%= @name %> {
<% end -%>
}

startup {
<% if @startup_parameters -%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like `disk_parameters, I think this whole block should be hidden if no parameters are present.

<% @startup_parameters.sort_by {|k, v| k}.each do |k, v| -%>
<%= k %> <%= v %>;
<% end -%>
<% end -%>
}

syncer {
verify-alg <%= @verify_alg %>;
<% if @rate -%>
Expand Down