Skip to content

Commit 3687a1d

Browse files
authored
refactor: align jammy agent settings to cp+assets approach (#646)
Replace heredoc-based apply.sh scripts with static assets/agent.json files (the same approach already used on ubuntu-noble). This makes the two branches structurally identical so future jammy=>noble merge forwards cannot silently resolve apply.sh conflicts in favour of the wrong version. - Delete prelude_agent.bash (PartitionerType: parted is now inlined as a static field in each assets/agent.json, as the function has unconditionally returned that string since 59a9c29 in 2019) - Replace all 8 bosh_*_agent_settings/apply.sh heredocs with a single cp $assets_dir/agent.json line - Add assets/agent.json for every stage carrying the full config (including UseMonitIptablesFirewall added in 8104abd)
1 parent 1783a82 commit 3687a1d

17 files changed

Lines changed: 227 additions & 246 deletions

File tree

stemcell_builder/lib/prelude_agent.bash

Lines changed: 0 additions & 4 deletions
This file was deleted.

stemcell_builder/stages/bosh_alicloud_agent_settings/apply.sh

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,6 @@
22

33
base_dir=$(readlink -nf $(dirname $0)/../..)
44
source $base_dir/lib/prelude_apply.bash
5-
source $base_dir/lib/prelude_agent.bash
65

7-
cat > $chroot/var/vcap/bosh/agent.json <<JSON
8-
{
9-
"Platform": {
10-
"Linux": {
11-
$(get_partitioner_type_mapping)
12-
"CreatePartitionIfNoEphemeralDisk": true,
13-
"DevicePathResolutionType": "virtio",
14-
"UseMonitIptablesFirewall": true
15-
}
16-
},
17-
"Infrastructure": {
18-
"Settings": {
19-
"Sources": [
20-
{
21-
"Type": "HTTP",
22-
"URI": "http://100.100.100.200",
23-
"UserDataPath": "/latest/user-data",
24-
"InstanceIDPath": "/latest/meta-data/instance-id",
25-
"SSHKeysPath": "/latest/meta-data/public-keys/0/openssh-key"
26-
}
27-
],
28-
"UseServerName": false,
29-
"UseRegistry": true
30-
}
31-
}
32-
}
33-
JSON
6+
# shellcheck disable=SC2154
7+
cp "$assets_dir/agent.json" "$chroot/var/vcap/bosh/agent.json"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"Platform": {
3+
"Linux": {
4+
"PartitionerType": "parted",
5+
"CreatePartitionIfNoEphemeralDisk": true,
6+
"DevicePathResolutionType": "virtio",
7+
"UseMonitIptablesFirewall": true
8+
}
9+
},
10+
"Infrastructure": {
11+
"Settings": {
12+
"Sources": [
13+
{
14+
"Type": "HTTP",
15+
"URI": "http://100.100.100.200",
16+
"UserDataPath": "/latest/user-data",
17+
"InstanceIDPath": "/latest/meta-data/instance-id",
18+
"SSHKeysPath": "/latest/meta-data/public-keys/0/openssh-key"
19+
}
20+
],
21+
"UseServerName": false,
22+
"UseRegistry": true
23+
}
24+
}
25+
}

stemcell_builder/stages/bosh_aws_agent_settings/apply.sh

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,6 @@
22

33
base_dir=$(readlink -nf $(dirname $0)/../..)
44
source $base_dir/lib/prelude_apply.bash
5-
source $base_dir/lib/prelude_agent.bash
65

7-
cat > $chroot/var/vcap/bosh/agent.json <<JSON
8-
{
9-
"Platform": {
10-
"Linux": {
11-
$(get_partitioner_type_mapping)
12-
"DevicePathResolutionType": "virtio",
13-
"CreatePartitionIfNoEphemeralDisk": true,
14-
"UseMonitIptablesFirewall": true,
15-
"InstanceStorageDevicePattern": "/dev/nvme*n1",
16-
"InstanceStorageManagedVolumePattern": "/dev/disk/by-id/nvme-Amazon_Elastic_Block_Store_*"
17-
}
18-
},
19-
"Infrastructure": {
20-
"Settings": {
21-
"Sources": [
22-
{
23-
"Type": "HTTP",
24-
"URI": "http://169.254.169.254",
25-
"UserDataPath": "/latest/user-data",
26-
"InstanceIDPath": "/latest/meta-data/instance-id",
27-
"SSHKeysPath": "/latest/meta-data/public-keys/0/openssh-key",
28-
"TokenPath": "/latest/api/token"
29-
}
30-
],
31-
"UseRegistry": true
32-
}
33-
}
34-
}
35-
JSON
6+
# shellcheck disable=SC2154
7+
cp "$assets_dir/agent.json" "$chroot/var/vcap/bosh/agent.json"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"Platform": {
3+
"Linux": {
4+
"PartitionerType": "parted",
5+
"DevicePathResolutionType": "virtio",
6+
"CreatePartitionIfNoEphemeralDisk": true,
7+
"UseMonitIptablesFirewall": true,
8+
"InstanceStorageDevicePattern": "/dev/nvme*n1",
9+
"InstanceStorageManagedVolumePattern": "/dev/disk/by-id/nvme-Amazon_Elastic_Block_Store_*"
10+
}
11+
},
12+
"Infrastructure": {
13+
"Settings": {
14+
"Sources": [
15+
{
16+
"Type": "HTTP",
17+
"URI": "http://169.254.169.254",
18+
"UserDataPath": "/latest/user-data",
19+
"InstanceIDPath": "/latest/meta-data/instance-id",
20+
"SSHKeysPath": "/latest/meta-data/public-keys/0/openssh-key",
21+
"TokenPath": "/latest/api/token"
22+
}
23+
],
24+
"UseRegistry": true
25+
}
26+
}
27+
}

stemcell_builder/stages/bosh_azure_agent_settings/apply.sh

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,5 @@
33
base_dir=$(readlink -nf $(dirname $0)/../..)
44
source $base_dir/lib/prelude_apply.bash
55

6-
# Set SettingsPath but never use it because file_meta_service is avaliable only when the settings file exists.
7-
cat > $chroot/var/vcap/bosh/agent.json <<JSON
8-
{
9-
"Platform": {
10-
"Linux": {
11-
"CreatePartitionIfNoEphemeralDisk": true,
12-
"DevicePathResolutionType": "scsi",
13-
"PartitionerType": "parted",
14-
"UseMonitIptablesFirewall": true
15-
}
16-
},
17-
"Infrastructure": {
18-
"Settings": {
19-
"Sources": [
20-
{
21-
"Type": "File",
22-
"MetaDataPath": "",
23-
"UserDataPath": "/var/lib/cloud/instance/user-data.txt",
24-
"SettingsPath": "/var/lib/cloud/instance/user-data.txt"
25-
}
26-
],
27-
"UseServerName": true
28-
}
29-
}
30-
}
31-
JSON
6+
# shellcheck disable=SC2154
7+
cp "$assets_dir/agent.json" "$chroot/var/vcap/bosh/agent.json"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"Platform": {
3+
"Linux": {
4+
"CreatePartitionIfNoEphemeralDisk": true,
5+
"DevicePathResolutionType": "scsi",
6+
"PartitionerType": "parted",
7+
"UseMonitIptablesFirewall": true
8+
}
9+
},
10+
"Infrastructure": {
11+
"Settings": {
12+
"Sources": [
13+
{
14+
"Type": "File",
15+
"MetaDataPath": "",
16+
"UserDataPath": "/var/lib/cloud/instance/user-data.txt",
17+
"SettingsPath": "/var/lib/cloud/instance/user-data.txt"
18+
}
19+
],
20+
"UseServerName": true
21+
}
22+
}
23+
}

stemcell_builder/stages/bosh_cloudstack_agent_settings/apply.sh

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,6 @@
22

33
base_dir=$(readlink -nf $(dirname $0)/../..)
44
source $base_dir/lib/prelude_apply.bash
5-
source $base_dir/lib/prelude_agent.bash
65

7-
agent_settings_file=$chroot/var/vcap/bosh/agent.json
8-
9-
cat > $agent_settings_file <<JSON
10-
{
11-
"Platform": {
12-
"Linux": {
13-
$(get_partitioner_type_mapping)
14-
"CreatePartitionIfNoEphemeralDisk": true,
15-
"DevicePathResolutionType": "virtio",
16-
"UseMonitIptablesFirewall": true
17-
}
18-
},
19-
"Infrastructure": {
20-
"Settings": {
21-
"Sources": [
22-
{
23-
"Type": "HTTP",
24-
"URI": "http://169.254.169.254:39724",
25-
"UserDataPath": "/latest/user-data",
26-
"InstanceIDPath": "/latest/meta-data/instance-id",
27-
"SSHKeysPath": "/latest/meta-data/public-keys"
28-
}
29-
],
30-
"UseServerName": true,
31-
"UseRegistry": true
32-
}
33-
}
34-
}
35-
JSON
6+
# shellcheck disable=SC2154
7+
cp "$assets_dir/agent.json" "$chroot/var/vcap/bosh/agent.json"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"Platform": {
3+
"Linux": {
4+
"PartitionerType": "parted",
5+
"CreatePartitionIfNoEphemeralDisk": true,
6+
"DevicePathResolutionType": "virtio",
7+
"UseMonitIptablesFirewall": true
8+
}
9+
},
10+
"Infrastructure": {
11+
"Settings": {
12+
"Sources": [
13+
{
14+
"Type": "HTTP",
15+
"URI": "http://169.254.169.254:39724",
16+
"UserDataPath": "/latest/user-data",
17+
"InstanceIDPath": "/latest/meta-data/instance-id",
18+
"SSHKeysPath": "/latest/meta-data/public-keys"
19+
}
20+
],
21+
"UseServerName": true,
22+
"UseRegistry": true
23+
}
24+
}
25+
}

stemcell_builder/stages/bosh_google_agent_settings/apply.sh

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,6 @@
22

33
base_dir=$(readlink -nf $(dirname $0)/../..)
44
source $base_dir/lib/prelude_apply.bash
5-
source $base_dir/lib/prelude_agent.bash
65

7-
cat > $chroot/var/vcap/bosh/agent.json <<JSON
8-
{
9-
"Platform": {
10-
"Linux": {
11-
"CreatePartitionIfNoEphemeralDisk": true,
12-
$(get_partitioner_type_mapping)
13-
"DevicePathResolutionType": "virtio",
14-
"VirtioDevicePrefix": "google",
15-
"UseMonitIptablesFirewall": true
16-
}
17-
},
18-
"Infrastructure": {
19-
"Settings": {
20-
"Sources": [
21-
{
22-
"Type": "InstanceMetadata",
23-
"URI": "http://169.254.169.254",
24-
"SettingsPath": "/computeMetadata/v1/instance/attributes/bosh_settings",
25-
"Headers": {
26-
"Metadata-Flavor": "Google"
27-
}
28-
}
29-
],
30-
31-
"UseServerName": true,
32-
"UseRegistry": false
33-
}
34-
}
35-
}
36-
JSON
6+
# shellcheck disable=SC2154
7+
cp "$assets_dir/agent.json" "$chroot/var/vcap/bosh/agent.json"

0 commit comments

Comments
 (0)