(FACT-2832) Use full path for augparse command #2135
(FACT-2832) Use full path for augparse command #2135mihaibuzgau merged 1 commit intopuppetlabs:mainfrom
Conversation
| command = if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/ | ||
| 'augparse' | ||
| else | ||
| '/opt/puppetlabs/puppet/bin/augparse' |
There was a problem hiding this comment.
Do we want to have this fact only in a puppet-agent context? What if i want to use the augeas fact with standalone facter and i install augeas to have augparse command?
For example installing augeas-tools and cfacter 3.11.0 on ubuntu-20.04 i can have the augeas fact.
There was a problem hiding this comment.
I changed the behaviour as follows:
1st: check if the path from puppet-agent's augparse exists and is readable; If not
2st: call 'augparse' without path and hope it is in path; If this command returns empty string
3rd: try requiring augeas gem and calling Augeas cli method to determine it's version.
So if augeas is present on the system, facter will determine it's version, even if it isn't in path or if it was installed manually and not shipped in puppet-agent context.
|
CLA signed by all contributors. |
| subject(:augeas) { Facter::Resolvers::Augeas } | ||
|
|
||
| let(:log_spy) { instance_spy(Facter::Log) } | ||
| let(:executable?) { false } |
There was a problem hiding this comment.
usually variables do not have ? in name, that is a convention only for boolean methods
Description of the problem: On unix like systems and linux operating systems, the call:
::Augeas.openis very time consuming. Alsoaugparsecommand is not found because the puppet directories are not in path.Description of the fix: On unix like and linux systems, call augparse with the full path and avoid calling the method
::Augeas.open.Note: Augeas is shipped in puppet-agent packages except Windows ones (that's is why this change is not affecting Windows behaviour)