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

Add Windows support #79

Merged
merged 2 commits into from Oct 29, 2013
Merged

Add Windows support #79

merged 2 commits into from Oct 29, 2013

Conversation

luisfdez
Copy link

Hi.
I've created a patch to add support for windows hosts, aimed to close #49. The basics of the patch are:

  • It adds a ruby version of the bash script.
  • Creates a new params.pp to store platform specific variables.
    (file mode, owners, paths, names,...)
  • Refactor to point variable references to params.pp.
  • Refactor setup.pp to generalize variables according to $::kernel fact.
  • Generalizes command execution according to variables in params.pp setup.pp.

I'd like your input/test in this modifications.

The ruby script is a first version trying to match 1-1 the bash structure. Anyway, it needs to be polished and improved as not all the ordering options available in .sh are implemented.


# find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir
open('fragments.concat', 'a') do |f|
Dir.entries("fragments").sort.each{ |entry|
Copy link
Author

Choose a reason for hiding this comment

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

This is the default sort, the script should be improved to change the criteria according to SETTINGS[:sortarg].

@apenney
Copy link

apenney commented Oct 23, 2013

Can I get you to rebase this against master? We've merged in a bunch of syntax/formatting changes and I think this'll significantly shrink the size of this PR. :)

$mode = '0644',
$owner = $concat::params::id,
$group = $concat::params::root_group,
$mode = $concat::params::fragment_mode,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the concat define is the entry point for this module, concat::setup or concat::params won't be loaded unless it's been manually included into the manifest. I'm not a big fan of that and got a PR merged to remove the requirement to do that (#77). This is a limitation of defined types since they don't support inheritance.

@luisfdez
Copy link
Author

Thanks @jhoblitt & @apenney. I've just rebased the code and made it simpler, I'm waiting to see what Travis says.

@@ -44,9 +56,11 @@
mode => '0750',
}

## Old versions of this module used a different path.
Copy link

Choose a reason for hiding this comment

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

If you don't mind lets just remove this entire section, I don't think we care about people with 2-3 year old versions of this module anymore. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

How about I submit a separate PR for this since dropping it isn't related to windows support?

Copy link
Author

Choose a reason for hiding this comment

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

Ok @jhoblitt . I'll wait for your PR to rebase it. Ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

@luisfdez Sure. I just opened that PR as #86 .

Copy link

Choose a reason for hiding this comment

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

Merged #86!

@apenney
Copy link

apenney commented Oct 24, 2013

Other than the failures with travis, which I'm sure you'll resolve, I'm definitely happy with the direction this is going. Long term I think we'll move to a type/provider for concat and do away with the script altogether, but this is awesome for our windows users!

# can we write to -o?
if File.file?(SETTINGS[:outfile])
if !File.writable?(SETTINGS[:outfile])
raise "Cannot write to %s" % [SETTINGS[:outfile]]

Choose a reason for hiding this comment

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

Interpolation is preferred over format string, eg "Cannot write to #{SETTINGS[:outfile]}"

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. I'm not a ruby expert, so these kind of things are really welcome. I'll update it for the next rebase.

@luisfdez
Copy link
Author

Code rebased, next round will be to improve ruby script according to @adrienthebo recommendations.

@apenney
Copy link

apenney commented Oct 24, 2013

Thanks for being so fast with these changes! Looking good, once I see the code changes I'll make sure travis is happy then get this merged.

@@ -191,7 +193,7 @@
exec { "concat_${name}":
alias => "concat_${fragdir}",
command => 'true',
Copy link
Contributor

Choose a reason for hiding this comment

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

I've only presently have a winxp test VM up and it's cmd.exe shell does not seem to have true. Have you tested file removal on windows?

Copy link
Author

Choose a reason for hiding this comment

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

Ummm good catch. Have to take a look to this scenario... the idea is just to return true?

Copy link

Choose a reason for hiding this comment

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

Just to return any "noop" in this case really, doesn't have to be true, could be something else for windows. Really we need to work out how to refactor so there's not a massive if/else with fake resources, but we can do that as a followup to this work.

- It adds a ruby version of the bash script.
- Refactor setup.pp to include new variables.
- Generalizes command execution according to variables in setup.pp.
@luisfdez
Copy link
Author

New version rebased:

  • Changed absent exec to use command&path depending on the $::kernel fact. Move conditions to setup.pp?
  • Update Ruby script according to @adrienthebo comments. Could you take another look to it?

OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options]"
opts.separator ""
opts.separator "Specific options:"
Copy link
Contributor

Choose a reason for hiding this comment

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

#separator is being called twice.

@jhoblitt
Copy link
Contributor

@luisfdez Thank you for all your effort on this PR! It's looking really good now, we're down to just very minor nit-picks now.

@luisfdez
Copy link
Author

@jhoblitt you're welcome 👍 , it's worth to have your module available for windows machines.

I've just added a commit to remove the duplicated call.

@jhoblitt
Copy link
Contributor

The rspec-system tests passed with the centos-64-x64 box.

@luisfdez Thank you again for this PR! Would you be willing to follow up with another PR to add spec coverage for $::kernel == windows?

jhoblitt pushed a commit that referenced this pull request Oct 29, 2013
@jhoblitt jhoblitt merged commit 4de578d into puppetlabs:master Oct 29, 2013
@luisfdez luisfdez deleted the feature/windows-support branch October 29, 2013 14:16
@luisfdez
Copy link
Author

@jhoblitt & others, thanks for your time! It's great to have this patch merged.

Regarding the spec coverage, it's a good idea. Could you give some guidelines about how to structure the code mixing platforms?

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

Successfully merging this pull request may close these issues.

None yet

6 participants