Skip to content

Commit 0ceef7d

Browse files
committed
Use Deferred node_encrypt function on passwords
This is a breaking change for Puppet < 6 as it requires the use of the Deferred type.
1 parent c92dea7 commit 0ceef7d

7 files changed

Lines changed: 43 additions & 16 deletions

File tree

.fixtures.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
---
44
fixtures:
55
repositories:
6-
bash:
7-
repo: "https://github.com/ploperations/ploperations-bash"
8-
ref: "80d2812e41de9f1cd3ffe2b0f6e2bf8852f1741b"
9-
classification:
10-
repo: "https://github.com/ploperations/ploperations-classification"
11-
ref: "a0ee04c65d89ca648113e96d15c5001c70fc718d"
6+
node_encrypt:
7+
repo: 'https://github.com/binford2k/binford2k-node_encrypt.git'
8+
ref: '868021745829a204c5c2028bdec972a2f4dc926a'
129
ssh:
1310
repo: "https://github.com/ploperations/ploperations-ssh"
1411
tag: "0.9.0"
@@ -18,11 +15,12 @@ fixtures:
1815
forge_modules:
1916
# Most of these are dependencies of puppetlabs/ssh.
2017
acl: "puppetlabs/acl"
21-
# bash: "ploperations/bash"
18+
bash: "ploperations/bash"
2219
chocolatey: "puppetlabs/chocolatey"
23-
# classification: "ploperations/classification"
20+
classification: "ploperations/classification"
2421
concat: "puppetlabs/concat"
2522
cygwin: "mdelaney/cygwin"
23+
# node_encrypt: "binford2k/node_encrypt" need 0.4.1 or later
2624
registry: "puppetlabs/registry"
2725
windows_env: "puppet/windows_env"
2826
sshkeys_core: "puppetlabs/sshkeys_core"

.sync.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
---
22
.gitlab-ci.yml:
33
delete: true
4+
.travis.yml:
5+
remove_includes:
6+
-
7+
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
8+
rvm: 2.4.4
49
appveyor.yml:
510
delete: true
611
Gemfile:

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ matrix:
2323
env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop"
2424
-
2525
env: CHECK=parallel_spec
26-
-
27-
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
28-
rvm: 2.4.4
2926
branches:
3027
only:
3128
- master

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ account::user:
125125
Note the accounts must have passwords on Windows. Defining `account::user`
126126
without a password on Windows will cause that user to be removed.
127127

128+
Passwords come into `account::user` with the [Sensitive][] type. From there
129+
`node_encrypt::secret()` takes over. The string is encrypted on the master,
130+
and then decrypted on the agent during catalog application. The `node_encrypt`
131+
module takes advantage of Deferred functions to do the decryption. You can
132+
read more about this at https://forge.puppet.com/binford2k/node_encrypt
128133

129134
### Predefining home directory files
130135

@@ -222,6 +227,7 @@ pdk bundle exec puppet strings generate --format markdown
222227
```
223228

224229
[Hiera eyaml]: https://github.com/voxpupuli/hiera-eyaml
230+
[Sensitive]: https://puppet.com/docs/puppet/latest/lang_data_sensitive.html
225231
[ploperations/ssh]: https://github.com/ploperations/ploperations-ssh
226232
[REFERENCE.md]: https://github.com/ploperations/ploperations-account/blob/master/REFERENCE.md
227233
[virtual]: https://puppet.com/docs/puppet/latest/lang_virtual.html

manifests/user.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
include account
7878

7979
if $password {
80-
$_password = $password
80+
$_password = node_encrypt::secret($password)
8181
} else {
8282
$hiera_accounts = lookup({
8383
name => 'account::user',
@@ -91,7 +91,7 @@
9191
}
9292

9393
$_password = $_password_raw ? {
94-
String => Sensitive($_password_raw),
94+
String => node_encrypt::secret(Sensitive($_password_raw)),
9595
default => $_password_raw,
9696
}
9797
}

metadata.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
"project_page": "https://github.com/ploperations/ploperations-account",
99
"issues_url": "https://github.com/ploperations/ploperations-account/issues",
1010
"dependencies": [
11+
{
12+
"name": "binford2k/node_encrypt",
13+
"version_requirement": ">= 0.4.0 < 2.0.0"
14+
},
1115
{
1216
"name": "ploperations/bash",
1317
"version_requirement": ">= 0.1 < 2.0.0"
@@ -95,7 +99,7 @@
9599
"requirements": [
96100
{
97101
"name": "puppet",
98-
"version_requirement": ">= 4.7.0 < 7.0.0"
102+
"version_requirement": ">= 6.0.0 < 7.0.0"
99103
}
100104
],
101105
"pdk-version": "1.9.0",

spec/defines/user_spec.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,26 @@
1212
})
1313
end
1414

15+
let(:pre_condition) {
16+
pp = <<-END
17+
function node_encrypt::secret ($foo) { $foo }
18+
END
19+
}
20+
1521
context "on #{os}" do
16-
it { is_expected.to compile.with_all_deps }
17-
it { is_expected.to contain_user('jdoe') }
22+
context 'without a password' do
23+
it { is_expected.to compile.with_all_deps }
24+
it { is_expected.to contain_user('jdoe') }
25+
end
26+
27+
context 'with plain text password' do
28+
let(:params) do
29+
{ 'password' => RSpec::Puppet::RawString.new("Sensitive('myPassword')") }
30+
end
31+
32+
it { is_expected.to compile.with_all_deps }
33+
it { is_expected.to contain_user('jdoe') }
34+
end
1835
end
1936
end
2037
end

0 commit comments

Comments
 (0)