Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse XML output of gluster for retrieving facts #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

coder-hugo
Copy link

@coder-hugo coder-hugo commented Apr 24, 2017

This PR provides 2 minor fixes. The first will fix #33 by parsing the xml output of the gluster command. The second one uses ; instead of , as separator for the options in the gluster_volume_#{vol}_options fact as the comma is already used by some gluster options (e.g. auth.ssl-allow) as separator. Having such an option in use every puppet run will fail with the following error:

Evaluation Error: Error while evaluating a Function Call, (<unknown>): could not found expected ':' while scanning a simple key at line 13 column 46 at .../gluster/manifests/volume.pp:272:21

@coder-hugo coder-hugo changed the title Minor fixes [WIP] Minor fixes Apr 24, 2017
@coder-hugo coder-hugo force-pushed the feature/minor-fixes branch from bfbf0f5 to 653f129 Compare April 25, 2017 08:08
@coder-hugo coder-hugo changed the title [WIP] Minor fixes Minor fixes Apr 25, 2017
if volume_options
volume_options.each do |vol, opts|
Facter.add("gluster_volume_#{vol}_options".to_sym) do
setcode do
opts.join(',')
opts.join(';')
Copy link
Member

Choose a reason for hiding this comment

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

Do you think this counts as a breaking change? ie Outside its use in this module, users might be using this fact in their own profiles?? Now that we've dropped puppet 3 support, all users should have a version of facter that supports structured-facts This means the fact could be changed to just return the array - getting rid of the join and corresponding split?

Copy link
Author

Choose a reason for hiding this comment

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

By using ; instead of , as separator for the volume options I tried to fix this error as less invasive as possible. If it's now possible to use sturctured-facts in this module I can adapt the code to do this. In this case I'd split this PR into 2. One that adds the code for using the xml output of gluster for retrieving the facts. And the other one that converts the volume fact from a string to an array. This will make it also easier to give the PRs a better name 😉

Copy link
Member

Choose a reason for hiding this comment

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

+1 for splitting into 2 PRs if possible. That will make it easier to get reviews and merged. And if you're feeling really bored/generous, feel free to completely refactor the hideousness going on in volume.pp in a 3rd :)

@alexjfisher
Copy link
Member

@coder-hugo Thanks for your work.

Could you rename the PR to something that would make sense in the Changelog? (Besides I'm not sure how 'minor' I'd call 548baa7 !)

Looking at the error message...

Evaluation Error: Error while evaluating a Function Call, (): could not found expected ':' while scanning a simple key at line 13 column 46 at .../gluster/manifests/volume.pp:272:21

That's from calling parseyaml on invalid yaml the manifest builds. WTF is going on in that manifest!!?? ;)

eg

# now we make some YAML, and then parse that to get a Puppet hash

# now we make some YAML, and then parse that to get a Puppet hash
          $yaml = join( regsubst( $vol_opts, ': ', ":\n  value: ", 'G'), "\n")
          $hoh = parseyaml($yaml)

seriously? a yaml string is used as some intermediate data format?? surely there's a better more sane way?

@coder-hugo coder-hugo force-pushed the feature/minor-fixes branch from 653f129 to 548baa7 Compare May 4, 2017 07:46
@coder-hugo coder-hugo changed the title Minor fixes Parse XML output of gluster for retrieving facts May 4, 2017
@bastelfreak
Copy link
Member

Hi @coder-hugo, could you please rebase and take a look at the comments from @alexjfisher ?

@tenajsystems
Copy link

@coder-hugo what did you do to work around this issue? I am currently facing the same issue with auth.allow not been able to set multiple ips.

@vox-pupuli-tasks
Copy link

Dear @coder-hugo, thanks for the PR!

This is pccibot, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

@vox-pupuli-tasks
Copy link

Dear @coder-hugo, thanks for the PR!

This is pccibot, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

1 similar comment
@vox-pupuli-tasks
Copy link

Dear @coder-hugo, thanks for the PR!

This is pccibot, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weak regex for volume port Fact
5 participants