title: service already declared in puppet
body: <p>I created a ntp module where I started a service and then I want to stop it. I wrote the entire code in a single <code>ntp.pp</code> file. Did writing the code in a single file create this problem?</p>
  
  <p>My code is:</p>
  
  <pre><code>package { 'ntp': ensure =&gt; installed }
  
  service { 'ntp-run':
    name    =&gt; 'ntpd',
    ensure  =&gt; running,
    require =&gt; Package['ntp'],
  }
  
  file { '/tmp/classtest': ensure =&gt; file }
  
  file { '/tmp/ntplink':
    ensure  =&gt; link,
    target  =&gt; '/tmp/classtest',
    require =&gt; File['/tmp/classtest'],
  }
  
  file { '/tmp/classdir': ensure =&gt; directory }
  
  exec { '/tmp/classtest':
    command =&gt; "mv /tmp/classtest /tmp/classdir",
    path    =&gt; '/bin/mv',
    require =&gt; File['/tmp/classtest'],
  }
  
  service { 'ntp-stop':
    ensure  =&gt; stopped,
    require =&gt; Service['ntp-run'],
  }
  
  package { 'ntp': ensure =&gt; absent }
  
  file { '/tmp/classtest':
    ensure  =&gt; absent,
    require =&gt; Exec['/tmp/classtest'],
  }
  </code></pre>
  
  <p>but I am getting this error:</p>
  
  <pre><code>Error: Duplicate declaration: Package[ntp] is already declared in file /etc/puppet/ntp.pp:3; cannot redeclare at /etc/puppet/ntp.pp:34 on node ip-172-31-41-100.us-west-2.compute.internal
  Error: Duplicate declaration: Package[ntp] is already declared in file /etc/puppet/ntp.pp:3; cannot redeclare at /etc/puppet/ntp.pp:34 on node ip-172-31-41-100.us-west-2.compute.internal
  </code></pre>