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

Adding Windows support #17

Closed
wants to merge 11 commits into from

Conversation

op-ct
Copy link
Contributor

@op-ct op-ct commented Jan 16, 2016

This patch adds:

  • New Windows facts:
    • Windows Server 2008 R2 and Windows Server 2012 R2 entries to the Vagrantfile
    • Windows Server 2008 R2 and Windows Server 2012 R2 facts for Facter 1.6–3.3
  • New Scripts:
    • facts/get_facts.ps1 to gather Windows facts
    • facts/clean_facts.rb, that cleans up facts/ files (e.g., YAML-only output from early Windows Facter versions) before they are entered into the database.
    • A new Rake task (rake table) to generate a markdown matrix of OS versions x Facter versions currently supported by facterdb (to help maintain the README.md).
  • A new spec test to validate Windows facts
  • An updated README.md

Note:

@mcanevet
Copy link
Member

@op-ct thanks a lot.
Wouldn't it be possible to convert UTF-16LE Unicode to UTF-8 or something similar so that we would have to do it at runtime?

@op-ct
Copy link
Contributor Author

op-ct commented Jan 20, 2016

@mcanevet I'd rather have FacterDB be capable of handling UTF-16LE json files on its own. It will allow folks to drop in facter -j dumps from their own Windows systems (especially if they didn't use the Vagrantfile scripts to collect them).

@mcanevet
Copy link
Member

@op-ct well the problem is that I can't even see the .facts content as github detects it as Binary file

@mmoll
Copy link
Contributor

mmoll commented Mar 2, 2016

what's the status here? I'd love to have this in so we can revert our workarounds in the theforeman-puppet tests for Windows. GH at least is viewing the file correctly with the "View" button in the diff.

@mcanevet
Copy link
Member

mcanevet commented Mar 2, 2016

@mmoll @op-ct I'd really prefer converting the UTF-16LTE to UTF-8 during facts collect.

@mmoll
Copy link
Contributor

mmoll commented Mar 25, 2016

@op-ct in #22 some Windows versions got added, could you rebase and update your additionial WIndows facts to UTF-8? The CentOS updates could go into a seperate PR...

@wottah
Copy link

wottah commented Jun 9, 2016

Are these issues getting resolved any time soon? Would greatly appreciate this fix.

On Windows hosts, `facter -j` writes `.facts` files using Little-endian
UTF-16 Unicode, prefixed with a JSON-unfriendly BOM.  This commit
updates the `database` method to correctly interpret these files.

Includes spec test.
This should be run after collecting Windows facts

Requires `vagrant plugin install vagrant-host-shell`
Some things were out of order, but now they are fixed.
@op-ct op-ct force-pushed the windows_support+centos_updates branch from c83a26d to 2baf27c Compare August 9, 2016 06:18
host.vm.provision "shell", path: "get_facts.sh"
host.vm.provision "shell", inline: "/sbin/shutdown -h now"
end
config.vm.define "centos-7-x86_64" do |host|
Copy link
Member

Choose a reason for hiding this comment

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

Why did you change alignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's some left-over silliness from separating the CentOS 7 fixes from the Windows; will be fixed in a bit.

@mcanevet
Copy link
Member

mcanevet commented Aug 9, 2016

@op-ct I still think the facts should be stored in plain text (UTF-8 or something)

@op-ct
Copy link
Contributor Author

op-ct commented Aug 9, 2016

@mcanevet They should be stored in plain text after this (sanitized by clean_facts.rb).

@mcanevet
Copy link
Member

mcanevet commented Aug 9, 2016

@op-ct facts/3.1/windows-2008 R2-x86_64.facts is still in binary format

@@ -2,11 +2,30 @@
require 'jgrep'

module FacterDB
# Convenience method to handle odd files
Copy link
Member

Choose a reason for hiding this comment

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

Is it still needed now that the facts are sanitized?

@op-ct op-ct changed the title Adding Windows support (+centos updates) Adding Windows support Aug 9, 2016
@op-ct op-ct force-pushed the windows_support+centos_updates branch from bc2a4af to 294c490 Compare August 9, 2016 08:03

def self.database
@database ||= "[#{Dir.glob("#{File.expand_path(File.join(File.dirname(__FILE__), '../facts'))}/*/*.facts").map { |f| File.read(f) }.join(',')}]\n"
fs = File.expand_path('../facts/*/*.facts',File.dirname(__FILE__))
Copy link
Member

Choose a reason for hiding this comment

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

I don't get this change in the library...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does a few things, but the intent was to be more semantic and less error-prone when a file contains bad data (or a different encoding).

A convenient side effect is that self.buld_database() makes a nice place to insert code for inspecting incoming data. I've already done this to identify broken data files during development. In the future, we might consider using it to identify facter data that doesn't conform to FacterDB conventions (e.g., an fqdn of foo.example.com)

The Windows `fqdn` and `domain` facts now default to the facterdb
convention of `foo.example.com`.
Before this patch, it wasn't clear which versions of each OS had data
for any given version of facter.

This patch addresses that problem by adding a **Facter version and
Operating System coverage** table to the `README.md`.  The markdown for
the table can be maintained using the new rake task, `rake table`.
@DavidS
Copy link
Contributor

DavidS commented Jul 31, 2017

Many windows versions were backfilled in #46

@op-ct can you rebase and extract only the required code and docs changes you feel still applicable?

@glennsarti
Copy link
Contributor

@op-ct I extracted your README change and put it into #76 . Also enhanced the Windows detection support.

@rodjek
Copy link
Member

rodjek commented Jul 15, 2019

Closing this out as there hasn't been any response and I believe that all the windows related improvements have been added in other PRs since this was opened.

@rodjek rodjek closed this Jul 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants