Puppet Agent on Windows and file paths 32 or 64 Bit

492 views
Skip to first unread message

r0k5t4r

unread,
Nov 21, 2012, 11:08:36 AM11/21/12
to puppet...@googlegroups.com
Hi,

I just started using puppet agent on windows 32Bit and my manfiests are working good so far. Now when using the same manifests on a 64Bit Windows machine I get trouble about the very special Program Files path. :(

Is there a way of using a variable in puppet manifests and the puppet agent automatically uses the correct Program Files (x86) folder on 64Bit machines? I checked the facts on the windows machine but it seems that 64Bit is not correctly reported so using a fact to distinguish is not possible atm.

I'm using puppet 2.7.13


Josh Cooper

unread,
Nov 26, 2012, 12:36:12 PM11/26/12
to puppet...@googlegroups.com
Hi Oliver,

On Wed, Nov 21, 2012 at 8:08 AM, r0k5t4r <oliver_...@gmx.de> wrote:
> I just started using puppet agent on windows 32Bit and my manfiests are
> working good so far. Now when using the same manifests on a 64Bit Windows
> machine I get trouble about the very special Program Files path. :(

Facter 1.6.10 will correctly report 32-bit or 64-bit architecture and
hardwaremodel. See http://projects.puppetlabs.com/issues/10261.
However, there is still a bug where a 32-bit OS running on 64-bit
hardware is reported as 64 instead of 32. See
https://projects.puppetlabs.com/issues/16948. As a result, you may
need to do something like:
https://github.com/puppetlabs/puppetlabs-dism/blob/master/lib/puppet/provider/dism/dism.rb#L7

Josh

--
Josh Cooper
Developer, Puppet Labs

r0k5t4r

unread,
Nov 27, 2012, 6:04:47 AM11/27/12
to puppet...@googlegroups.com
Hi Josh,

thanks a lot for pointing this out. I will update the install on all windows machines to the latest puppet 2.7.x release. This updates facter and the architecture is correctly display unless it's running 32Bit on 64Bit hardware.

Regards,
Oliver

ad

unread,
Nov 27, 2012, 4:00:34 PM11/27/12
to puppet...@googlegroups.com
Hey Oliver,

You can use my winfacts module, or just strip out the os_archtecture fact from it:


That will correctly handle 32-bit OS on 64-bit hardware.

Adam

r0k5t4r

unread,
Nov 30, 2012, 8:16:11 AM11/30/12
to puppet...@googlegroups.com
Hi Adam,

thanks a lot. I have successfully implemented your or_architecture fact on our machines. But it looks like it is not workung under Windows 2003 32Bit.I have to check this...

Regards,
Oli

r0k5t4r

unread,
Nov 30, 2012, 10:27:05 AM11/30/12
to puppet...@googlegroups.com
Hi Adam,

The class Win32_OperatingSystem exists on Vista and above. For older systems you can use Win32_ComputerSystem. I found this information here:

http://www.adminarsenal.com/admin-arsenal-blog/bid/19689/Determining-OS-Architecture

The following minor change did the trick for windows 2003.

Facter.add(:os_architecture) do
  confine :operatingsystem => :windows
  setcode do
    result = ''
    require 'win32ole'
    wmi = WIN32OLE.connect('winmgmts://./root/CIMV2')
        winver = Facter.value('kernelmajversion')
        case winver
        when /5.2|5.1|5.0/
                query = wmi.ExecQuery('select SystemType from Win32_ComputerSystem')
                query.each do |os|
                        result = os.SystemType
                        break
                end
                if result == "X86-based PC"
                        result = "32-bit"
                else
                        result = "64-bit"
                end
                result
        else
                query = wmi.ExecQuery('select OSArchitecture from Win32_OperatingSystem')
                query.each do |os|
                        result = os.OSArchitecture
                        break
                end
    result
        end
  end
end

Have a nice weekend.

ad

unread,
Nov 30, 2012, 4:53:28 PM11/30/12
to puppet...@googlegroups.com
Hi Oliver,

Nice catch! Thanks for posting your patch.

Cheers,

Adam

ad

unread,
Dec 6, 2012, 2:51:00 PM12/6/12
to puppet...@googlegroups.com
Hey Oliver,

I finally got around to working on this today, and discovered I fixed it long ago and completely forgot to push the change to github. oops :)


I only run Puppet on Windows 7 and XP nodes (yeah that's right), but I can confirm this handles 32-bit OS on x64 and accounts for some variations I ran into with various embedded Windows.

Adam

On Friday, November 30, 2012 9:27:05 AM UTC-6, r0k5t4r wrote:
Reply all
Reply to author
Forward
0 new messages