title: How to provide a startup service file in Puppet
body: <p>We have RedHat 7.2 Linux OS and use puppet to perform our tasks. I am using puppet to install some software, which has worked fine and now the final step is to create an OS level service. In earlier versions of RHEL, we used chkconfig but that has been replaced with systemctl. Of course, the recommended way of performing this task is using a service. Since this is a custom software, I have my own startup script that I usually copy over to /etc/init.d, run chkconfig and then startup the service. How do I perform these tasks via Puppet for RedHat 7.2 OS ? I only want to create the service (not start it up or anything). This way, when the server reboots, the service will startup the app.</p>
  
  <p>EDIT :</p>
  
  <p>@redstonemercury for RHEL 7 I would think the following would be required. But your suggestion definitely helps as I was thinking along the same lines.</p>
  
  <p><a href="https://serverfault.com/questions/814611/puppet-generated-systemd-unit-files">https://serverfault.com/questions/814611/puppet-generated-systemd-unit-files</a></p>
  
  <pre><code>file { '/lib/systemd/system/myservice.service':
    mode    =&gt; '0644',
    owner   =&gt; 'root',
    group   =&gt; 'root',
    content =&gt; template('modulename/myservice.systemd.erb'),
  }~&gt;
  exec { 'myservice-systemd-reload':
    command     =&gt; 'systemctl daemon-reload',
    path        =&gt; [ '/usr/bin', '/bin', '/usr/sbin' ],
    refreshonly =&gt; true,
  }
  </code></pre>