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

Error installing Sensu on Windows Server 2012R2 #646

Closed
poolski opened this issue Apr 27, 2017 · 7 comments · Fixed by #699
Closed

Error installing Sensu on Windows Server 2012R2 #646

poolski opened this issue Apr 27, 2017 · 7 comments · Fixed by #699
Assignees

Comments

@poolski
Copy link
Contributor

poolski commented Apr 27, 2017

When trying to install Sensu fresh on a Win2012R2 server, I get the following error:

Invalid relationship: File[C:/opt/sensu/ssl] {require => Package[sensu]}, because Package[sensu] doesn't seem to be in the catalog

I have a feeling it's because the module is expecting to see a package called 'sensu' whereas on Windows, the package name gets changed to 'Sensu' (uppercase S) and this is throwing the module right off.

Is this a known issue and is there a fix somewhere?

jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 28, 2017
Without this patch there is no test coverage for Package[sensu] when the
client is a windows node.  This patch adds test coverage to fix the bug
reported in sensuGH-646.
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 28, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 28, 2017
Without this patch there isn't a Vagrant VM for Win2012r2.  Windows is
necessary to reproduce the issue in sensuGH-646 and smoke test the fix.

Relates to sensu#681
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 28, 2017
Without this patch there is no test coverage for Package[sensu] when the
client is a windows node.  This patch adds test coverage to fix the bug
reported in sensuGH-646.
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 28, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 28, 2017
Without this patch there isn't a Vagrant VM for Win2012r2.  Windows is
necessary to reproduce the issue in sensuGH-646 and smoke test the fix.

Using opentable/win-2012r2 Vagrant vm client

RDP port is exposed.  Login is vagrant / vagrant.

Relates to sensu#681
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Without this patch there is no test coverage for Package[sensu] when the
client is a windows node.  This patch adds test coverage to fix the bug
reported in sensuGH-646.
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Without this patch there isn't a Vagrant VM for Win2012r2.  Windows is
necessary to reproduce the issue in sensuGH-646 and smoke test the fix.

Using opentable/win-2012r2 Vagrant vm client

RDP port is exposed.  Login is vagrant / vagrant.

Relates to sensu#681
jeffmccune pushed a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
@jeffmccune
Copy link
Collaborator

@ghoneycutt I've resolved the Package[Sensu] error by rebasing the work in #635. I'm running into this issue now:

vagrant provision win2012r2-client
==> win2012r2-client: Running provisioner: shell...
    win2012r2-client: Running: tests/provision_client_win.ps1 as c:\tmp\vagrant-shell.ps1
==> win2012r2-client: Info: Loading facts
==> win2012r2-client: Info: Loading facts
...
==> win2012r2-client: Warning: Scope(Class[Sensu::Package]): Managing a local windows user is not supported
==> win2012r2-client: Notice: Compiled catalog for win2012r2-client.home in environment production in 1.59 seconds
==> win2012r2-client: Error: Parameter ensure failed on Package[sensu]: Provider windows must have features 'upgradeable' to set 'ensure' to 'latest' at C:/ProgramData/PuppetLabs/code/environments/production/modules/sensu/manifests/package.pp:64

It seems we need to specify an explicit version for windows. I notice sensu::version defaults to latest though.

Do you have any guidance on how to handle this for windows? Maybe specify an explicit default version via hiera data in the module with an entry in the hierarchy for osfamily?

jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Without this patch there is no test coverage for Package[sensu] when the
client is a windows node.  This patch adds test coverage to fix the bug
reported in sensuGH-646.
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Without this patch there isn't a Vagrant VM for Win2012r2.  Windows is
necessary to reproduce the issue in sensuGH-646 and smoke test the fix.

Using opentable/win-2012r2 Vagrant vm client

RDP port is exposed.  Login is vagrant / vagrant.

Relates to sensu#681
jeffmccune pushed a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Partially resolves sensu#646

Still running into this error:

    Error: Parameter ensure failed on Package[sensu]: Provider windows
    must have features 'upgradeable' to set 'ensure' to 'latest' at
    sensu/manifests/package.pp:64
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Without this patch there is no test coverage for Package[sensu] when the
client is a windows node.  This patch adds test coverage to fix the bug
reported in sensuGH-646.
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Without this patch there isn't a Vagrant VM for Win2012r2.  Windows is
necessary to reproduce the issue in sensuGH-646 and smoke test the fix.

Using opentable/win-2012r2 Vagrant vm client

RDP port is exposed.  Login is vagrant / vagrant.

Relates to sensu#681
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Partially resolves sensu#646

Still running into this error:

    Error: Parameter ensure failed on Package[sensu]: Provider windows
    must have features 'upgradeable' to set 'ensure' to 'latest' at
    sensu/manifests/package.pp:64
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Without this patch there is no test coverage for Package[sensu] when the
client is a windows node.  This patch adds test coverage to fix the bug
reported in sensuGH-646.
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Without this patch there isn't a Vagrant VM for Win2012r2.  Windows is
necessary to reproduce the issue in sensuGH-646 and smoke test the fix.

Using opentable/win-2012r2 Vagrant vm client

RDP port is exposed.  Login is vagrant / vagrant.

Relates to sensu#681
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
The name parameter of Package[sensu] needs to match Add/Remove programs,
which is `Sensu`
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Partially resolves sensu#646

Still running into this error:

    Error: Parameter ensure failed on Package[sensu]: Provider windows
    must have features 'upgradeable' to set 'ensure' to 'latest' at
    sensu/manifests/package.pp:64
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Without this patch the default package version for sensu is `latest`.
This is a problem for two reasons, first the package may be
automatically upgraded on Linux systems, which is a burden for
Operations when behavior changes.  Second, Windows does not have a
provider supporting the upgradable feature which results in an error in
the default case.

This path addresses both issues by defaulting the version to
`installed`.

For the Windows 2012r2 Vagrant box, the version is explicitly passed in
tests/sensu-client-windows.pp because
http://repositories.sensuapp.org/msi/ does not have sensu-latest.msi,
which is used in the default case.
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Without this patch the computation of the package source URL will
inevitably be incorrect for some users.  To avoid support issues, this
patch adds an override as an escape hatch.  The user may specific the
specific package source URL which will override the computation.
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
The name parameter of Package[sensu] needs to match Add/Remove programs,
which is `Sensu`
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
The OS expects version numbers to be dotted, e.g. 0.29.0.11, whereas the
file paths have a hyphen denoting the release component.  This patch
maps the file version ID to the package version ID to allow the catalog
to converge.
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
The name parameter of Package[sensu] needs to match Add/Remove programs,
which is `Sensu`
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
The OS expects version numbers to be dotted, e.g. 0.29.0.11, whereas the
file paths have a hyphen denoting the release component.  This patch
maps the file version ID to the package version ID to allow the catalog
to converge.
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
The name parameter of Package[sensu] needs to match Add/Remove programs,
which is `Sensu`
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
The OS expects version numbers to be dotted, e.g. 0.29.0.11, whereas the
file paths have a hyphen denoting the release component.  This patch
maps the file version ID to the package version ID to allow the catalog
to converge.
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jun 29, 2017
Remove agent install log only if the log exists.  Avoids this error:

    ==> win2012r2-client: Log will be written to C:/vagrant/puppet-agent.log
    ==> win2012r2-client: Remove-Item : Cannot find path 'C:\vagrant\puppet-agent.log' because it does
    ==> win2012r2-client: not exist.
    ==> win2012r2-client: At C:\tmp\vagrant-shell.ps1:9 char:3
    ==> win2012r2-client: +   Remove-Item $log
    ==> win2012r2-client: +   ~~~~~~~~~~~~~~~~
    ==> win2012r2-client:     + CategoryInfo          : ObjectNotFound: (C:\vagrant\puppet-agent.log:Str
    ==> win2012r2-client:    ing) [Remove-Item], ItemNotFoundException
    ==> win2012r2-client:     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.Remov
    ==> win2012r2-client:    eItemCommand
@ghoneycutt
Copy link
Collaborator

Fixed in v2.8.0

@cdenneen
Copy link
Contributor

@jeffmccune this seemed to work from my Mac -> Windows doing acceptance testing which includes the sensu module in my profile for windows but had someone run from Windows -> Windows and there is a newline/CR between 2012r2 and sensu-version...

https://github.com/sensu/sensu-puppet/blame/master/manifests/package.pp#L72

Guessing possibly something with how the template is rendered from Windows vs a *nix platform? Template should be working without carriage return -%> but I figured I'd pass along that there might be issue here that I'm missing with $pkg_url_dir

@ghoneycutt
Copy link
Collaborator

What do you mean running acceptance tests windows to windows? I'm not following you.

@cdenneen
Copy link
Contributor

@ghoneycutt I have a profile_base::windows class that includes sensu module and configurations.
So when I run these beaker tests from Mac to windows 2012r2 nodeset it works fine. When run from Windows 10 to same windows 2012r2 nodeset it has issues with carriage return.
To get around conditional here I hardcoded value for windows_pkg_url and it still has another carriage return issue:

  Notice: /Stage[main]/Sensu::Package/Package[sensu]/ensure: ensure changed '0.28.5.2' to '0.28.5.2
  '
  Info: Class[Sensu::Package]: Scheduling refresh of Service[sensu-client]

@cdenneen
Copy link
Contributor

@ghoneycutt just to give full code:

class profile_base::windows {
  include ::profile_base::sensu
}
class profile_base::sensu (
  Boolean $server,
  String $rabbitmq_host,
  String $rabbitmq_password,
  String $rabbitmq_vhost,
  Array[String] $subscriptions,
  Array[String] $sensu_additional_plugins,
  String $client_bind,
  String $client_port,
  Hash $client_plugins_script,
  Hash $client_keepalive,
  Hash $client_custom,
  String $default_client_name,
  Array[String] $sensu_plugins,
  String $sensu_client_prefix,
  String $version,
  Optional[Boolean] $enterprise,
  Optional[Boolean] $enterprise_dashboard,
  Optional[String] $enterprise_user,
  Optional[String] $enterprise_pass,
  Optional[Boolean] $manage_user = false,
  Optional[String] $package_checksum = undef,
  Optional[String] $windows_repo_prefix = undef,
  Optional[Boolean] $windows_logrotate = false,
  Optional[String] $windows_log_number = undef,
  Optional[String] $windows_log_size = undef,
  Optional[String] $windows_pkg_url = undef,
)
{
  assert_private()
  #notify { 'Applying class profile_base::sensu': }

  if $facts['ec2_metadata'] {
    $client_name = $facts['ec2_metadata']['instance-id']
  } elsif $::hostname {
    $client_name = $::hostname
  } else {
    $client_name = $default_client_name
  }

  $client_name_with_prefix="${sensu_client_prefix}${client_name}"

  if $::ipaddress {
    $client_address = $::ipaddress
  } else {
    $client_address   = '127.0.0.1'
  }

  class { '::sensu':
    version              => $version,
    install_repo         => true,
    server               => $server,
    api                  => $server,
    client               => true,
    use_embedded_ruby    => true,
    rabbitmq_host        => $rabbitmq_host,
    rabbitmq_password    => $rabbitmq_password,
    rabbitmq_vhost       => $rabbitmq_vhost,
    subscriptions        => $subscriptions,
    client_name          => $client_name_with_prefix,
    client_address       => $client_address,
    client_keepalive     => $client_keepalive,
    client_custom        => $client_custom,
    client_port          => $client_port,
    client_bind          => $client_bind,
    enterprise           => $enterprise,
    enterprise_dashboard => $enterprise_dashboard,
    enterprise_user      => $enterprise_user,
    enterprise_pass      => $enterprise_pass,
    package_checksum     => $package_checksum,
    windows_repo_prefix  => $windows_repo_prefix,
    windows_logrotate    => $windows_logrotate,
    windows_log_size     => $windows_log_size,
    windows_log_number   => $windows_log_number,
    manage_user          => $manage_user,
    windows_pkg_url      => $windows_pkg_url,
  }


# Install plugins and scripts
...
}
profile_base::sensu::version: '0.28.5-2'
profile_base::sensu::package_checksum: 'ae321125091331771aa6f9edbcbacb0a'
profile_base::sensu::windows_repo_prefix: 'http://artifactory.domain.local/sensu/msi'
profile_base::sensu::windows_logrotate: true
profile_base::sensu::manage_user: false
profile_base::sensu::windows_pkg_url: 'http://artifactory.domain.local/sensu/msi/2012r2/sensu-0.28.5-2-x64.msi'

So without windows_pkg_url it seems to have a carriage return after pkg_url_dir but when I use the windows_pkg_url it has issue with carriage return with sensu::version.

Checked and not sure if this is correct but his git config core.autocrlf = true (on my mac it's false) is set which is normally necessary for windows users checking out code and spinning up linux vagrant boxes to run puppet code on... but maybe when it's windows it needs to be different? Sorry for so much info just wanted to provide as much detail as possible.

@ghoneycutt
Copy link
Collaborator

@cdenneen I appreciate all the effort on this.

We aren't planning to support running tests from a windows host and we don't have the platform to test with. If there's an issue with the module running on Windows, we certainly do want to get that fixed. Is that the case or is the issue only with running acceptance tests?

If you can figure out how to get the acceptance tests to work with windows, we are more than happy to accept a pull request.

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 a pull request may close this issue.

6 participants