Only grep for last 8 characters as this is what apt-key list returns#373
Closed
szponek wants to merge 1 commit intoDataDog:masterfrom
Closed
Only grep for last 8 characters as this is what apt-key list returns#373szponek wants to merge 1 commit intoDataDog:masterfrom
szponek wants to merge 1 commit intoDataDog:masterfrom
Conversation
Member
|
@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. |
truthbk
suggested changes
Dec 5, 2017
| 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", |
Member
There was a problem hiding this comment.
I believe this should be:
unless => "/usr/bin/apt-key list | grep #{name[-8,8]} | grep expires",
Author
There was a problem hiding this comment.
@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
Member
There was a problem hiding this comment.
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.
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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