-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only grep for last 8 characters as this is what apt-key list returns #373
Conversation
@szponek thanks for this - I'll try to fix the tests for older puppets DSL, got to check how we can grab the substring there. This is ready to go as soon as we get that sorted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@szponek almost ready - as you can see from the tests, this breaks for older puppets, I believe using a hash '#' instead of a '$' should fix the substring.
@@ -15,6 +15,6 @@ | |||
define datadog_agent::ubuntu::install_key() { | |||
exec { "key ${name}": | |||
command => "/usr/bin/apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys ${name}", | |||
unless => "/usr/bin/apt-key list | grep ${name} | grep expires", | |||
unless => "/usr/bin/apt-key list | grep ${name[-8,8]} | grep expires", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be:
unless => "/usr/bin/apt-key list | grep #{name[-8,8]} | grep expires",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@truthbk are you sure #{var} is a valid way for variable interpolation? It doesn't work on puppet 5.3.2 for me:
[szponek@szponek tmp]$ cat test1.pp
$test='12345678'
notify { "Test: #{test[-3,3]}": }
[szponek@szponek tmp]$ puppet apply test1.pp
Notice: Compiled catalog for szponek.example.net in environment production in 0.01 seconds
Notice: Test: #{test[-3,3]}
Notice: /Stage[main]/Main/Notify[Test: #{test[-3,3]}]/message: defined 'message' as 'Test: #{test[-3,3]}'
Notice: Applied catalog in 0.02 seconds
'$' works as expected so maybe [8-,8] construct is just not supported on puppet < 4.x
[szponek@szponek tmp]$ cat test1.pp
$test='12345678'
notify { "Test: ${test[-3,3]}": }
[szponek@szponek tmp]$ puppet apply test2.pp
Notice: Compiled catalog for szponek.example.net in environment production in 0.02 seconds
Notice: Test: 678
Notice: /Stage[main]/Main/Notify[Test: 678]/message: defined 'message' as 'Test: 678'
Notice: Applied catalog in 0.02 seconds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right. Too much chef for me lately. I'll see what I can come up with that works across all versions... I think I can maybe use regsubst
for this.
This fixes #367 by grepping only the last 8 characters of the key ID, which is what apt-key list returns on Debian and Ubuntu