My first module

57 views
Skip to first unread message

Nicolas lino

unread,
Sep 30, 2014, 2:50:50 PM9/30/14
to puppet...@googlegroups.com
Hello and sorry for my English.

I have my first module but I have a prblem:

My manifest:
#
#
#
class nginx {
  $nginx_conf = '/etc/nginx/conf.d'

  service { 'nginx':
    ensure     => running,
    enable     => true,
    hasrestart => true,
    require    => File['/etc/nginx/nginx.conf'],
    restart    => '/etc/init.d/nginx reload'
  }

  file { '/etc/nginx/nginx.conf':
    ensure  => latest,
    mode    => '0644',
    owner   => 'root',
    group   => 'root',
    source => "puppet:///modules/nginx/nginx.conf",
  }            ////////line22

  file { $nginx_conf:
    ensure  => directory,
    mode    => '0644',
    owner   => 'root',
    group   => 'root',
  }

}

Directory structure:
[root@v702uprod manifests]# tree /etc/puppet/modules/
/etc/puppet/modules/
├── API
└── nginx
    ├── files
    │   └── nginx.conf
    ├── manifests
    │   └── init.pp
    └── templates


The problem:
Error: Failed to apply catalog: Validation of File[/etc/nginx/nginx.conf] failed: You cannot specify more than one of content, source, target at /etc/puppet/m
odules/nginx/manifests/init.pp:22
Wrapped exception:
You cannot specify more than one of content, source, target



someone comes up with the problem???





Peter Bukowinski

unread,
Sep 30, 2014, 3:11:02 PM9/30/14
to puppet...@googlegroups.com
On Sep 30, 2014, at 2:50 PM, Nicolas lino <nicola...@gmail.com> wrote:

> Hello and sorry for my English.
>
> I have my first module but I have a prblem:
>
> My manifest:
> #
> #
> #
> class nginx {
> $nginx_conf = '/etc/nginx/conf.d'
>
> service { 'nginx':
> ensure => running,
> enable => true,
> hasrestart => true,
> require => File['/etc/nginx/nginx.conf'],
> restart => '/etc/init.d/nginx reload'
> }
>
> file { '/etc/nginx/nginx.conf':
> ensure => latest,
> mode => '0644',
> owner => 'root',
> group => 'root',
> source => "puppet:///modules/nginx/nginx.conf",
> } ////////line22

Hi Nicolas,

You cannot use 'latest' for the file resource's ensure parameter. That value only applies to package resources. Puppet will always ensure that the file on a client matches whatever version of file exists at the path specified in the manifest. You should use one of the following values for the ensure parameter: file, directory, link, absent. 'present' is also supported, but I encourage you to avoid it and be explicit by specifying the type of file. In your case, 'file' is the correct choice.

--
Peter Bukowinski

Garrett Honeycutt

unread,
Sep 30, 2014, 3:44:39 PM9/30/14
to puppet...@googlegroups.com
> --

Hi Nicolas,

Try changing the file's ensure from 'latest' to file.

You might also try using an existing module instead of reinventing the
wheel.

https://forge.puppetlabs.com/modules?utf-8=%E2%9C%93&sort=rank&q=nginx

Best regards,
-g

--
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658
Reply all
Reply to author
Forward
0 new messages