From d0c267ca90d0df3af7d913764648cd3dba659dd7 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Fri, 2 Oct 2020 14:31:16 -0400 Subject: [PATCH] Fix sed command to not delete lines after match --- salt/playbook/files/automation_user_create.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/playbook/files/automation_user_create.sh b/salt/playbook/files/automation_user_create.sh index 632a73c41..03736e521 100644 --- a/salt/playbook/files/automation_user_create.sh +++ b/salt/playbook/files/automation_user_create.sh @@ -37,7 +37,7 @@ while [[ $try_count -le 6 ]]; do # Search for the needed keys in the global pillar file, if missing then add them if (grep -Pzq 'playbook:\n api_key:.*' $local_salt_dir/pillar/global.sls); then - sed -iz "s/playbook:\n api_key:.*/playbook:\n api_key: ${automation_api_key}/" $local_salt_dir/pillar/global.sls + sed -e '1h;2,$H;$!d;g' -e "s/playbook:\n api_key:.*/playbook:\n api_key: ${automation_api_key}/m" -i $local_salt_dir/pillar/global.sls else { echo "playbook:"