Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 4b1cd9a

Browse files
authored
Merge pull request #769 from simonswine/automated-cherry-pick-of-#766-#767-#768-release-0.6
Automated cherry pick of #766 #767 #768
2 parents b5d544f + ee90ec3 commit 4b1cd9a

11 files changed

Lines changed: 32 additions & 7 deletions

File tree

puppet/hieradata/common.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ consul::backup_bucket_prefix: "%{::consul_backup_bucket_prefix}"
3535
consul::private_ip: "%{::vault_private_ip}"
3636
consul::cloud_provider: aws
3737
consul::backup_schedule: "%{::consul_backup_schedule}"
38+
consul::datacenter: "%{::vault_region}"
3839

3940
vault_server::region: "%{::vault_region}"
4041
vault_server::environment: "%{::vault_environment}"

puppet/modules/aws_ebs/manifests/mount.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
String $dest_path,
1818
String $device,
1919
Boolean $is_not_attached,
20-
Enum['xfs'] $filesystem = 'xfs',
20+
Enum['xfs', 'ext4'] $filesystem = 'xfs',
2121
){
2222
require ::aws_ebs
2323

puppet/modules/aws_ebs/spec/defines/mount_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
it 'should contain mount service' do
4545
should contain_service(mount_service_name).that_requires("Service[#{format_service_name}]")
46-
should contain_file("/etc/systemd/system/#{mount_service_name}").with_content(%r{Type=xfs})
46+
should contain_file("/etc/systemd/system/#{mount_service_name}").with_content(%r{Type=auto})
4747
should contain_file("/etc/systemd/system/#{mount_service_name}").with_content(%r{Where=/mnt/folder/test1})
4848
should contain_file("/etc/systemd/system/#{mount_service_name}").with_content(%r{What=/dev/xvdy})
4949
end

puppet/modules/aws_ebs/templates/ensure-volume-formatted.service.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ After=<%= @attach_service_name %>
88
[Service]
99
Type=oneshot
1010
RemainAfterExit=yes
11-
ExecStart=<%= scope['aws_ebs::format_bin_path'] %> <%= @device %>
11+
ExecStart=<%= scope['aws_ebs::format_bin_path'] %> <%= @device %> <%= @filesystem %>
1212

1313
[Install]
1414
WantedBy=multiuser.target

puppet/modules/aws_ebs/templates/ensure_volume_formatted.sh.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
PATH=/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin
44
DEVICE=$1
5+
FILESYSTEM=$2
56

6-
blkid "${DEVICE}" || (wipefs -fa "${DEVICE}" && mkfs.xfs "${DEVICE}")
7+
blkid "${DEVICE}" || (wipefs -fa "${DEVICE}" && mkfs.${FILESYSTEM} "${DEVICE}")

puppet/modules/aws_ebs/templates/volume.mount.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ After=<%= @format_service_name %>
66
[Mount]
77
What=<%= @device %>
88
Where=<%= @dest_path %>
9-
Type=<%= @filesystem %>
9+
Type=auto
1010

1111
[Install]
1212
WantedBy=multiuser.target
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
set -e
4+
set -x
5+
6+
CONSUL_DATACENTER=$(strings -n1 $1/data/raft/raft.db | grep Datacenter -A1 | head -n2 | tail -n 1)
7+
8+
if [ -z "${CONSUL_DATACENTER}" ]; then
9+
echo "{}"
10+
else
11+
echo "{\"datacenter\":\"${CONSUL_DATACENTER}\",\"acl_datacenter\":\"${CONSUL_DATACENTER}\"}"
12+
fi

puppet/modules/consul/manifests/install.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@
129129
target => "${consul::_backinator_dest_dir}/consul-backinator",
130130
}
131131

132+
file { "${consul::_dest_dir}/consul-detect-existing-datacenter.sh":
133+
ensure => file,
134+
content => file('consul/consul-detect-existing-datacenter.sh'),
135+
mode => '0755'
136+
}
137+
132138
file { "${consul::_dest_dir}/consul-backup.sh":
133139
ensure => file,
134140
content => file('consul/consul-backup.sh'),

puppet/modules/consul/manifests/service.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
$bin_path = $consul::bin_path
2828
$config_path = $consul::config_path
29+
$config_datacenter_override_path = "${consul::config_dir}/consul-datacenter.json"
30+
$consul_detect_existing_datacenter_path = "${consul::_dest_dir}/consul-detect-existing-datacenter.sh"
2931

3032
$consul_encrypt = $consul::_consul_encrypt
3133
$consul_master_token = $consul::_consul_master_token

puppet/modules/consul/templates/consul.service.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ ExecStartPre=/bin/chown -c root:<%= @group %> <%= @data_dir %>
2626
ExecStartPre=/bin/chmod 0750 <%= @data_dir%>
2727
ExecStartPre=/bin/chown -cR <%= @user %>:<%= @group %> <%= @data_dir %>/data
2828
ExecStartPre=/bin/chmod 0750 <%= @data_dir %>/data
29+
# detect an already existing datacenter setting
30+
ExecStartPre=/bin/sh -c ". <%= @consul_detect_existing_datacenter_path %> <%= @data_dir %> > <%= @config_datacenter_override_path %>"
2931
ExecStart=<%= @bin_path %> \
3032
agent \
3133
-config-file=<%= @config_path %> \
34+
-config-file=<%= @config_datacenter_override_path %> \
3235
-data-dir=<%= @data_dir %>/data
3336
Restart=on-failure
3437
RestartSec=10

0 commit comments

Comments
 (0)