Puppet out: Debug: Exec[line_remove](provider=posix): Executing '/usr/bin/perl -w -ni -e 'my $qs = quotemeta('ssh-rsa AAAA/BBBB/knMQ== user@host.f.q.d.n'); print unless /^$qs$/ ' '/root/user/b1.bak'' Debug: Executing: '/usr/bin/perl -w -ni -e 'my $qs = quotemeta('ssh-rsa AAAA/BBBB/knMQ== user@host.f.q.d.n'); print unless /^$qs$/ ' '/root/user/b1.bak'' Notice: /Stage[main]/Main/Line[ssh_key]/Exec[line_remove]/returns: Unquoted string "ssh" may clash with future reserved word at -e line 1. Notice: /Stage[main]/Main/Line[ssh_key]/Exec[line_remove]/returns: syntax error at -e line 1, at EOF Notice: /Stage[main]/Main/Line[ssh_key]/Exec[line_remove]/returns: Execution of -e aborted due to compilation errors. ## Same errors as direct at the cmd line # /usr/bin/perl -w -ni -e 'my $qs = quotemeta('ssh-rsa AAAA/BBBB/knMQ== user@host.f.q.d.n'); print unless /^$qs$/ ' '/root/user/b1.bak' Unquoted string "ssh" may clash with future reserved word at -e line 1. syntax error at -e line 1, at EOF Execution of -e aborted due to compilation errors. # Try swap outer quotes '-> " # /usr/bin/perl -w -ni -e "my $qs = quotemeta('ssh-rsa AAAA/BBBB/knMQ== user@host.f.q.d.n'); print unless /^$qs$/ " '/root/user/b1.bak' syntax error at -e line 1, near "my =" Execution of -e aborted due to compilation errors. # Try "" around quotemeta string # /usr/bin/perl -w -ni -e 'my $qs = quotemeta("ssh-rsa AAAA/BBBB/knMQ== user@host.f.q.d.n"); print unless /^$qs$/ ' '/root/user/b1.bak' Possible unintended interpolation of @host in string at -e line 1. Name "main::host" used only once: possible typo at -e line 1. #### # Direct cli # perl -w -ni -e 'my $str = sprintf( qq(%s), q(ssh-rsa AAAA/BBBB/knMQ== user@host.f.q.d.n) ); print $_ unless $_ =~ /$str/ ' /root/user/b1.bak # From within puppet command => "/usr/bin/perl -w -ni -e 'my \$str = sprintf( qq(%s), q($line) ); print \$_ unless \$_ =~ /\$str/ ' '${file}'", #### # cat b1.bak ssh-rsa CCCC/DDDD/knMQ== user@host2.f.q.d.n ssh-rsa AAAA/BBBB/kPW+Yi9yZ7Kh0mL/knMQ== user@host.f.q.d.n # perl -w -n -e 'my $str = sprintf( qq(%s), q(ssh-rsa AAAA/BBBB/kPW+Yi9yZ7Kh0mL/knMQ== user@host.f.q.d.n) ); print $_ unless $_ =~ /$str/ ' /root/user/b1.bak ssh-rsa CCCC/DDDD/knMQ== user@host2.f.q.d.n ssh-rsa AAAA/BBBB/kPW+Yi9yZ7Kh0mL/knMQ== user@host.f.q.d.n