Skip to content

(FACT-2832) Use full path for augparse command #2135

Merged
mihaibuzgau merged 1 commit intopuppetlabs:mainfrom
oanatmaria:FACT-2832
Oct 14, 2020
Merged

(FACT-2832) Use full path for augparse command #2135
mihaibuzgau merged 1 commit intopuppetlabs:mainfrom
oanatmaria:FACT-2832

Conversation

@oanatmaria
Copy link
Copy Markdown
Contributor

Description of the problem: On unix like systems and linux operating systems, the call: ::Augeas.open is very time consuming. Also augparse command 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)

@oanatmaria oanatmaria added the bug Something isn't working label Oct 12, 2020
@oanatmaria oanatmaria requested review from a team October 12, 2020 12:59
command = if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
'augparse'
else
'/opt/puppetlabs/puppet/bin/augparse'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

@oanatmaria oanatmaria Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@puppetcla
Copy link
Copy Markdown

CLA signed by all contributors.

subject(:augeas) { Facter::Resolvers::Augeas }

let(:log_spy) { instance_spy(Facter::Log) }
let(:executable?) { false }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually variables do not have ? in name, that is a convention only for boolean methods

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@mihaibuzgau mihaibuzgau merged commit ae9d38e into puppetlabs:main Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants