Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在puppet模块中处理linux和windows?_Puppet - Fatal编程技术网

如何在puppet模块中处理linux和windows?

如何在puppet模块中处理linux和windows?,puppet,Puppet,我有一个为linux系统编写的大型模块。但是我需要它来为windows工作,所以我想重写它来处理这两个问题 有很多清单,从我目前所看到的来看,大部分清单都可以在Windows上运行,因为puppet会看到它在Windows上运行,并选择最好的提供者 然而,也有一些部分不起作用。例如,此exec将无法在windows上工作 exec { 'touch_file' : command => 'touch /etc/test.txt', path =>

我有一个为linux系统编写的大型模块。但是我需要它来为windows工作,所以我想重写它来处理这两个问题

有很多清单,从我目前所看到的来看,大部分清单都可以在Windows上运行,因为puppet会看到它在Windows上运行,并选择最好的提供者

然而,也有一些部分不起作用。例如,此exec将无法在windows上工作

    exec { 'touch_file' :
      command => 'touch /etc/test.txt',
      path    => ['/bin', '/usr/bin'],
      cwd     => '/tmp',
      creates => '/etc/test.txt',
    }

这在linux中可以工作,但在Windows中,我会将其更改为powershell命令,并更改creates、cwd和path。我可以将每个部分更改为${variable},并在Exec语句上方使用case语句,根据::osgroup选择正确的变量,但我不确定这是否是处理此问题的最佳方法。有没有更好的方法来处理多操作系统模块

有时,最好根据您的目标操作系统设置不同的执行器。请参见以下示例:

    if $::osfamily == 'windows' {
      class { '::puppet_agent::prepare': } ->
      class { '::puppet_agent::windows::install': }
    }
    else {

      if $::operatingsystem == 'SLES' and $::operatingsystemmajrelease == '10' {
        $_package_file_name = "${puppet_agent::package_name}-${puppet_agent::params::master_agent_version}-1.sles10.${::architecture}.rpm"
      } elsif $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '10' {
        $_package_file_name = "${puppet_agent::package_name}-${puppet_agent::params::master_agent_version}-1.i386.pkg.gz"
      }

      class { '::puppet_agent::prepare':
        package_file_name => $_package_file_name,
      } ->
      class { '::puppet_agent::install':
        package_file_name => $_package_file_name,
      } ->
      class { '::puppet_agent::service': }

      contain '::puppet_agent::prepare'
      contain '::puppet_agent::install'
      contain '::puppet_agent::service'
    }