diff --git a/x-pack/plugins/fleet/server/services/epm/agent/agent.test.ts b/x-pack/plugins/fleet/server/services/epm/agent/agent.test.ts index e57b19c847806..a3e5749384c0b 100644 --- a/x-pack/plugins/fleet/server/services/epm/agent/agent.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/agent/agent.test.ts @@ -327,6 +327,25 @@ input: logs }); }); + it('should support $$$$ yaml values at root level', () => { + const streamTemplate = ` +input: logs +{{custom}} + `; + const vars = { + custom: { + type: 'yaml', + value: 'test: $$$$', + }, + }; + + const output = compileTemplate(vars, streamTemplate); + expect(output).toEqual({ + input: 'logs', + test: '$$$$', + }); + }); + it('should suport !!str for string values', () => { const stringTemplate = ` my-package: diff --git a/x-pack/plugins/fleet/server/services/epm/agent/agent.ts b/x-pack/plugins/fleet/server/services/epm/agent/agent.ts index 9a26394cd1cb1..f1187e3629c0b 100644 --- a/x-pack/plugins/fleet/server/services/epm/agent/agent.ts +++ b/x-pack/plugins/fleet/server/services/epm/agent/agent.ts @@ -164,8 +164,7 @@ function replaceRootLevelYamlVariables(yamlVariables: { [k: string]: any }, yaml let patchedTemplate = yamlTemplate; Object.entries(yamlVariables).forEach(([key, val]) => { - patchedTemplate = patchedTemplate.replace( - new RegExp(`^"${key}"`, 'gm'), + patchedTemplate = patchedTemplate.replace(new RegExp(`^"${key}"`, 'gm'), () => val ? safeDump(val) : '' ); });