Skip to content

Commit aa6c532

Browse files
authored
Merge pull request #484 from cultuurnet/feature/ssh_key_tags
Allow multiple tags on SSH pubkeys
2 parents 112d053 + 410bcac commit aa6c532

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

manifests/ssh.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
purge => true
5454
}
5555

56-
any2array($ssh_authorized_keys_tags).each |$tag| {
56+
[$ssh_authorized_keys_tags].flatten.each |$tag| {
5757
Ssh_authorized_key <| tag == $tag |>
5858
}
5959

manifests/ssh_authorized_keys.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
user => 'ubuntu',
1616
type => $key_attributes['type'],
1717
key => $key_attributes['key'],
18-
tag => $attributes['tag']
18+
tag => $attributes['tags']
1919
}
2020
}
2121
}

spec/classes/ssh_authorized_keys_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
it { is_expected.to have_ssh_authorized_key_resource_count(0) }
1717
end
1818

19-
context "with keys => { foo => { tag => publiq, keys => { type => ssh-rsa, key => abcd1234 } }, bar => { tag => publiq, keys => [{ type => ssh-rsa, key => efgh5678 }, { type => ssh-ed25519, key => ijkl9012 }] }, baz => { tag => acme, keys => {type => ssh-rsa, key => efgh5678} } }" do
19+
context "with keys => { foo => { tags => [publiq, example], keys => { type => ssh-rsa, key => abcd1234 } }, bar => { tags => publiq, keys => [{ type => ssh-rsa, key => efgh5678 }, { type => ssh-ed25519, key => ijkl9012 }] }, baz => { tags => acme, keys => {type => ssh-rsa, key => efgh5678} } }" do
2020
let(:params) {
2121
{
2222
'keys' => {
23-
'foo' => { 'tag' => 'publiq', 'keys' => { 'type' => 'ssh-rsa', 'key' => 'abcd1234' } },
24-
'bar' => { 'tag' => 'publiq', 'keys' => [{ 'type' => 'ssh-rsa', 'key' => 'efgh5678' }, { 'type' => 'ssh-ed25519', 'key' => 'ijkl9012' }] },
25-
'baz' => { 'tag' => 'acme', 'keys' => { 'type' => 'ssh-rsa', 'key' => 'efgh5678' } }
23+
'foo' => { 'tags' => ['publiq', 'example'], 'keys' => { 'type' => 'ssh-rsa', 'key' => 'abcd1234' } },
24+
'bar' => { 'tags' => 'publiq', 'keys' => [{ 'type' => 'ssh-rsa', 'key' => 'efgh5678' }, { 'type' => 'ssh-ed25519', 'key' => 'ijkl9012' }] },
25+
'baz' => { 'tags' => 'acme', 'keys' => { 'type' => 'ssh-rsa', 'key' => 'efgh5678' } }
2626
}
2727
}
2828
}
@@ -31,7 +31,7 @@
3131
'user' => 'ubuntu',
3232
'type' => 'ssh-rsa',
3333
'key' => 'abcd1234',
34-
'tag' => 'publiq'
34+
'tag' => ['publiq', 'example']
3535
) }
3636

3737
it { is_expected.to contain_ssh_authorized_key('bar 1').with(

spec/support/hiera/data/common.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,24 @@ profiles::certificates::certificates:
6565

6666
profiles::ssh_authorized_keys::keys:
6767
'publiq first key':
68-
tag: 'publiq'
68+
tags: 'publiq'
6969
keys:
7070
type: 'ssh-rsa'
7171
key: 'abcd'
7272
'publiq second key':
73-
tag: 'publiq'
73+
tags:
74+
- 'publiq'
75+
- 'example'
7476
keys:
7577
type: 'ssh-ed25519'
7678
key: 'defg'
7779
'foobar first key':
78-
tag: 'foobar'
80+
tags: 'foobar'
7981
keys:
8082
type: 'ssh-rsa'
8183
key: '0123'
8284
'acme first key':
83-
tag: 'acme'
85+
tags: 'acme'
8486
keys:
8587
type: 'ssh-rsa'
8688
key: '4567'

0 commit comments

Comments
 (0)