Skip to content

Commit 277e8e5

Browse files
authored
feat(super agent): migrate newrelic-infra configs (#1064)
1 parent 1b6dd23 commit 277e8e5

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

recipes/newrelic/infrastructure/super-agent/debian.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ install:
7575
- task: add_nr_source
7676
- task: update_apt_nr_source
7777
- task: install_super_agent
78+
- task: migrate_newrelic_infra_config
7879
- task: update_otel_license_key
7980
- task: config_supervisors
8081
- task: config_opamp
@@ -85,7 +86,6 @@ install:
8586
- task: assert_super_agent_started
8687
- task: post_install
8788

88-
8989
write_recipe_metadata:
9090
cmds:
9191
- |
@@ -172,16 +172,32 @@ install:
172172
- |
173173
if [ "{{.NR_CLI_INFRA_AGENT}}" != "false" ] ; then
174174
if [ -f /etc/newrelic-infra.yml ]; then
175+
printf "\nAn existing newrelic-infra configuration file was detected. Updating where needed."
176+
175177
sed -i "/^staging/d" /etc/newrelic-infra.yml
176178
sed -i "/^enable_process_metrics/d" /etc/newrelic-infra.yml
177179
sed -i "/^status_server_enabled/d" /etc/newrelic-infra.yml
178180
sed -i "/^status_server_port/d" /etc/newrelic-infra.yml
179181
sed -i "/^license_key/d" /etc/newrelic-infra.yml
180182
sed -i '/^custom_attributes:/,/^\S/{ /^\S/!d }' /etc/newrelic-infra.yml
181-
sed -i '/^custom_attributes:/d' /etc/newrelic-infra.yml
183+
sed -i '/^custom_attributes:/d' /etc/newrelic-infra.yml
182184
sed -i "/^is_secure_forward_only/d" /etc/newrelic-infra.yml
185+
186+
if [ "{{.NR_SA_MIGRATE_INFRA_CONFIG}}" == "true" ] || [ "{{.NEW_RELIC_ASSUME_YES}}" == "true" ] ; then
187+
touch /etc/newrelic-infra-do-migrate
188+
else
189+
printf "\nWould you like to migrate this newrelic-infra config to use it with the newrelic super agent? (y/N): "
190+
read -r MIGRATE_NEWRELIC_INFRA_CONFIG
191+
MIGRATE_NEWRELIC_INFRA_CONFIG=${MIGRATE_NEWRELIC_INFRA_CONFIG:-N}
192+
193+
if [ "$MIGRATE_NEWRELIC_INFRA_CONFIG" == "y" ] ; then
194+
touch /etc/newrelic-infra-do-migrate
195+
fi
196+
fi
183197
else
184198
touch /etc/newrelic-infra.yml
199+
# If we are creating a new file, perform the migration as well
200+
touch /etc/newrelic-infra-do-migrate
185201
fi
186202
fi
187203
- |
@@ -311,6 +327,15 @@ install:
311327
fi
312328
silent: true
313329

330+
# If configured to do so, migrate the newrelic-infra configuration for usage with the super agent
331+
migrate_newrelic_infra_config:
332+
cmds:
333+
- |
334+
if [ -f /etc/newrelic-infra-do-migrate ]; then
335+
rm /etc/newrelic-infra-do-migrate
336+
newrelic-config-migrate
337+
fi
338+
314339
# Add NR Ingest Key as ENV Var for the Super Agent Systemd service (used by Infra Agent and Otel)
315340
update_otel_license_key:
316341
cmds:

recipes/newrelic/infrastructure/super-agent/rhel.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ install:
9494
- task: setup_infra_license
9595
- task: setup_infra_proxy
9696
- task: install_super_agent
97+
- task: migrate_newrelic_infra_config
9798
- task: update_otel_license_key
9899
- task: config_supervisors
99100
- task: config_opamp
@@ -181,6 +182,8 @@ install:
181182
- |
182183
if [ "{{.NR_CLI_INFRA_AGENT}}" != "false" ] ; then
183184
if [ -f /etc/newrelic-infra.yml ]; then
185+
printf "\nAn existing newrelic-infra configuration file was detected. Updating where needed."
186+
184187
sed -i "/^staging/d" /etc/newrelic-infra.yml
185188
sed -i "/^enable_process_metrics/d" /etc/newrelic-infra.yml
186189
sed -i "/^status_server_enabled/d" /etc/newrelic-infra.yml
@@ -189,8 +192,22 @@ install:
189192
sed -i '/^custom_attributes:/,/^\S/{ /^\S/!d }' /etc/newrelic-infra.yml
190193
sed -i '/^custom_attributes:/d' /etc/newrelic-infra.yml
191194
sed -i "/^is_secure_forward_only/d" /etc/newrelic-infra.yml
195+
196+
if [ "{{.NR_SA_MIGRATE_INFRA_CONFIG}}" == "true" ] || [ "{{.NEW_RELIC_ASSUME_YES}}" == "true" ] ; then
197+
touch /etc/newrelic-infra-do-migrate
198+
else
199+
printf "\nWould you like to migrate this newrelic-infra config to use it with the newrelic super agent? (y/N): "
200+
read -r MIGRATE_NEWRELIC_INFRA_CONFIG
201+
MIGRATE_NEWRELIC_INFRA_CONFIG=${MIGRATE_NEWRELIC_INFRA_CONFIG:-N}
202+
203+
if [ "$MIGRATE_NEWRELIC_INFRA_CONFIG" == "y" ] ; then
204+
touch /etc/newrelic-infra-do-migrate
205+
fi
206+
fi
192207
else
193208
touch /etc/newrelic-infra.yml
209+
# If we are creating a new file, perform the migration as well
210+
touch /etc/newrelic-infra-do-migrate
194211
fi
195212
fi
196213
- |
@@ -249,6 +266,15 @@ install:
249266
rpm -E %{rhel}
250267
silent: true
251268

269+
# If configured to do so, migrate the newrelic-infra configuration for usage with the super agent
270+
migrate_newrelic_infra_config:
271+
cmds:
272+
- |
273+
if [ -f /etc/newrelic-infra-do-migrate ]; then
274+
rm /etc/newrelic-infra-do-migrate
275+
newrelic-config-migrate
276+
fi
277+
252278
update_otel_license_key:
253279
cmds:
254280
- |

recipes/newrelic/infrastructure/super-agent/suse.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ install:
6565
- task: setup_infra_license
6666
- task: setup_infra_proxy
6767
- task: install_super_agent
68+
- task: migrate_newrelic_infra_config
6869
- task: update_otel_license_key
6970
- task: config_supervisors
7071
- task: config_opamp
@@ -144,6 +145,8 @@ install:
144145
- |
145146
if [ "{{.NR_CLI_INFRA_AGENT}}" != "false" ] ; then
146147
if [ -f /etc/newrelic-infra.yml ]; then
148+
printf "\nAn existing newrelic-infra configuration file was detected. Updating where needed."
149+
147150
sed -i "/^staging/d" /etc/newrelic-infra.yml
148151
sed -i "/^enable_process_metrics/d" /etc/newrelic-infra.yml
149152
sed -i "/^status_server_enabled/d" /etc/newrelic-infra.yml
@@ -152,8 +155,22 @@ install:
152155
sed -i '/^custom_attributes:/,/^\S/{ /^\S/!d }' /etc/newrelic-infra.yml
153156
sed -i '/^custom_attributes:/d' /etc/newrelic-infra.yml
154157
sed -i "/^is_secure_forward_only/d" /etc/newrelic-infra.yml
158+
159+
if [ "{{.NR_SA_MIGRATE_INFRA_CONFIG}}" == "true" ] || [ "{{.NEW_RELIC_ASSUME_YES}}" == "true" ] ; then
160+
touch /etc/newrelic-infra-do-migrate
161+
else
162+
printf "\nWould you like to migrate this newrelic-infra config to use it with the newrelic super agent? (y/N): "
163+
read -r MIGRATE_NEWRELIC_INFRA_CONFIG
164+
MIGRATE_NEWRELIC_INFRA_CONFIG=${MIGRATE_NEWRELIC_INFRA_CONFIG:-N}
165+
166+
if [ "$MIGRATE_NEWRELIC_INFRA_CONFIG" == "y" ] ; then
167+
touch /etc/newrelic-infra-do-migrate
168+
fi
169+
fi
155170
else
156171
touch /etc/newrelic-infra.yml
172+
# If we are creating a new file, perform the migration as well
173+
touch /etc/newrelic-infra-do-migrate
157174
fi
158175
fi
159176
- |
@@ -203,6 +220,15 @@ install:
203220
sh: awk -F= '/VERSION_ID/ {print $2}' /etc/os-release
204221
silent: true
205222

223+
# If configured to do so, migrate the newrelic-infra configuration for usage with the super agent
224+
migrate_newrelic_infra_config:
225+
cmds:
226+
- |
227+
if [ -f /etc/newrelic-infra-do-migrate ]; then
228+
rm /etc/newrelic-infra-do-migrate
229+
newrelic-config-migrate
230+
fi
231+
206232
update_otel_license_key:
207233
cmds:
208234
- |

0 commit comments

Comments
 (0)