简体   繁体   中英

Error using source in Puppet manifest

I am trying to change a file in puppet agents and I have written the below code.

modules/
├── helloworld
│   └── manifests
│       ├── init.pp
│       └── motd.pp
└── ssh
    ├── manifests
    |    └── init.pp
    └── ssh_config

my Puppet manifest code:

# modules/ssh/manifests/init.pp 
class ssh {
  package { 'openssl':
    ensure => present,
    before => File['/etc/ssh/sshd_config'],
  }

  file {'ssh_config':
    ensure => file,
    path   => '/etc/ssh/sshd_config',
    mode   => "600",
    source => "puppet:///modules/ssh/ssh_config",
  }

  service {'sshd':
    ensure    => running, 
    enable    => true,
    subscribe => File['/etc/ssh/sshd_config'],
  }
}

Below is the main manifest's code:

# manifests/site.pp 
node default {
  class { 'ssh': }
}

Below is the error I am receiving:

Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for dheera.asicdesigners.com
Info: Applying configuration version '1478497316'
Error: /Stage[main]/Ssh/File[ssh_config]: Could not evaluate: Could not retrieve information from environment production        source(s)       
puppet:///modules/ssh/ssh_config
Notice: /Stage[main]/Ssh/Service[sshd]: Dependency File[ssh_config] has failures: true
Warning: /Stage[main]/Ssh/Service[sshd]: Skipping because of failed dependencies
Notice: Applied catalog in 0.21 seconds

Your ssh_config file location needs to be in the files directory of your module to be used with the Puppet URI in the source attribute like you are doing.

modules/
├── helloworld
│   └── manifests
│       ├── init.pp
│       └── motd.pp
└── ssh
    ├── manifests
    |    └── init.pp
    └── files
         ├── ssh_config

Also, you probably meant your package resource to be openssh and not openssl .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM