Skip to content

Commit 410bcac

Browse files
committed
Allow multiple tags on SSH pubkeys
1 parent bd6f2ce commit 410bcac

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
@@ -62,22 +62,24 @@ profiles::certificates::certificates:
6262

6363
profiles::ssh_authorized_keys::keys:
6464
'publiq first key':
65-
tag: 'publiq'
65+
tags: 'publiq'
6666
keys:
6767
type: 'ssh-rsa'
6868
key: 'abcd'
6969
'publiq second key':
70-
tag: 'publiq'
70+
tags:
71+
- 'publiq'
72+
- 'example'
7173
keys:
7274
type: 'ssh-ed25519'
7375
key: 'defg'
7476
'foobar first key':
75-
tag: 'foobar'
77+
tags: 'foobar'
7678
keys:
7779
type: 'ssh-rsa'
7880
key: '0123'
7981
'acme first key':
80-
tag: 'acme'
82+
tags: 'acme'
8183
keys:
8284
type: 'ssh-rsa'
8385
key: '4567'

0 commit comments

Comments
 (0)