Code Monkey home page Code Monkey logo

Comments (3)

bastelfreak avatar bastelfreak commented on September 18, 2024

Hi!
I thought a bit about this. If you set active to true on the systemd::unit_file defined resources, it creates the service resource for you:
https://github.com/camptocamp/puppet-systemd/blob/8f68b0dcf3bbbafc60c025879a28004fc9815aab/manifests/unit_file.pp#L91-L98

You basically define the service twice, once in your profile and once via the defined resource. This works by accident because the defined resource references the service with send_downtime.service and the profile with send_downtime. This means that you could shorten the profiles:

class profile::monitoring {
  systemd::unit_file { 'send_downtime.service':
    content => file('profile/send_downtime.service'),
    active  => true,
    enable => true,
  }
}

class profile::base_os {
  systemd::unit_file { 'remove_check_mk_cache.service':
    content => file('profile/remove_checkmk_cache.service'),
    active  => true,
    enable => true,
  }
}

While this is shorter, it indeed creates the dependency loop you mentioned. On a few of my profiles I workaround this by not ordering the profiles like you did in your role. I set explicit dependencies in my profile to resources to the other profiles. In your case that would mean:

class profile::monitoring {
  systemd::unit_file { 'send_downtime.service':
    content => file('profile/send_downtime.service'),
    active  => true,
    enable => true,
  }
  Service['remove_check_mk_cache.service'] -> Service['send_downtime.service']
}

class profile::base_os {
  systemd::unit_file { 'remove_check_mk_cache.service':
    content => file('profile/remove_checkmk_cache.service'),
    active  => true,
    enable => true,
  }
}

But I understand that ordering profiles in a role is a common pattern and I do that myself alot as well. In that case just remove the active => true, line from your two systemd::unit_file and all works as well.

from puppet-systemd.

tuxmea avatar tuxmea commented on September 18, 2024

Fix is available in #171

from puppet-systemd.

ekohl avatar ekohl commented on September 18, 2024

#171 has been merged so I think this can be closed now.

from puppet-systemd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.