From e8b4f6ca357d929db700ac589ccfc4e0d5de4b66 Mon Sep 17 00:00:00 2001 From: Pawel Fiuto Date: Mon, 30 Dec 2019 16:35:57 +0000 Subject: [PATCH 1/3] Reorder switches in dbpath_fix find command --- manifests/server/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/server/config.pp b/manifests/server/config.pp index 486af7557..4f72ce9f5 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -136,7 +136,7 @@ exec { 'fix dbpath permissions': command => "chown -R ${user}:${group} ${dbpath}", path => ['/usr/bin', '/bin'], - onlyif => "find ${dbpath} -not -user ${user} -o -not -group ${group} -print -quit | grep -q '.*'", + onlyif => "find ${dbpath} -print -not -user ${user} -o -not -group ${group} -quit | grep -q '.*'", subscribe => File[$dbpath], } } From 2ce85b826c229ffc9270a2e8b037a5147bd8740c Mon Sep 17 00:00:00 2001 From: Pawel Fiuto Date: Mon, 30 Dec 2019 16:58:43 +0000 Subject: [PATCH 2/3] Fix test --- spec/classes/server_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index ffeab1355..88e6fb1d3 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -280,7 +280,7 @@ is_expected.to contain_exec('fix dbpath permissions'). with_command('chown -R foo:bar /var/lib/mongodb'). with_path(['/usr/bin', '/bin']). - with_onlyif("find /var/lib/mongodb -not -user foo -o -not -group bar -print -quit | grep -q '.*'"). + with_onlyif("find /var/lib/mongodb -print -not -user foo -o -not -group bar -quit | grep -q '.*'"). that_subscribes_to('File[/var/lib/mongodb]') end end From c3e0c90ccff120b0a135821b3910339a9256e6f0 Mon Sep 17 00:00:00 2001 From: Pawel Fiuto Date: Wed, 18 Mar 2020 12:07:41 +0000 Subject: [PATCH 3/3] Correct find command again This was still wrong as it would always return results regardless if ownership on files. The correct solution is to drop `-print` altogether. --- manifests/server/config.pp | 2 +- spec/classes/server_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/server/config.pp b/manifests/server/config.pp index 4f72ce9f5..d13a1edbe 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -136,7 +136,7 @@ exec { 'fix dbpath permissions': command => "chown -R ${user}:${group} ${dbpath}", path => ['/usr/bin', '/bin'], - onlyif => "find ${dbpath} -print -not -user ${user} -o -not -group ${group} -quit | grep -q '.*'", + onlyif => "find ${dbpath} -not -user ${user} -o -not -group ${group} -quit | grep -q '.*'", subscribe => File[$dbpath], } } diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 88e6fb1d3..c9ccf5a43 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -280,7 +280,7 @@ is_expected.to contain_exec('fix dbpath permissions'). with_command('chown -R foo:bar /var/lib/mongodb'). with_path(['/usr/bin', '/bin']). - with_onlyif("find /var/lib/mongodb -print -not -user foo -o -not -group bar -quit | grep -q '.*'"). + with_onlyif("find /var/lib/mongodb -not -user foo -o -not -group bar -quit | grep -q '.*'"). that_subscribes_to('File[/var/lib/mongodb]') end end