Skip to content

Conversation

JGodin-C2C
Copy link

Pull Request (PR) description

This PR allows quadlets to be referenced as units.
As the puppet-quadlet uses systemd::unit to validate the entry , it think that is an interesting feature.
Reference here.

https://github.com/voxpupuli/puppet-quadlets/blob/master/REFERENCE.md#unit_entry

HOWEVER, i understand that systemd module should not bear this burden, I would be more than happy to implement alternative solutions.

This Pull Request (PR) is indirectly related to #540

@kenyon kenyon changed the title feat: Allow quadletes to be referenced as units. feat: Allow quadlets to be referenced as units Aug 6, 2025
@kenyon kenyon added the enhancement New feature or request label Aug 6, 2025
@kenyon kenyon changed the title feat: Allow quadlets to be referenced as units Allow quadlets to be referenced as units Aug 6, 2025
@traylenator
Copy link
Contributor

traylenator commented Aug 11, 2025

puppet-quadlet uses systemd::unit to validate the entry

It does not really ?

Things like activate, deactivate make no sense to a .container file , its not a unit.

This is a close from me.

I agree though actually this directory "https://github.com/voxpupuli/puppet-quadlets/tree/master/types/unit" is named incorrectly.

@JGodin-C2C
Copy link
Author

I think we mixed up things here.
I am specifically speaking about this .
The data type is Optional[Systemd::Unit::Unit] and this is enforced by the type unit. If i want to mount a volume before launching a pod for example, you cannot do that as the .volume is forbidden in the "Require" or "Before". As per my request.

@traylenator
Copy link
Contributor

traylenator commented Sep 16, 2025

Can you give me a puppet example of what you want to work ? To be clean .vollume will not be support in the type Systemd::Unit::Unit since its not a unit.

It is supported in the type Quadlets::Quadlet_name

@JGodin-C2C
Copy link
Author

Sure ! here you go :

  quadlets::quadlet { 'openvoxservercode.volume':
    ensure       => present,
    unit_entry   => {
      'Description' => 'openvoxserver Code Volume',
    },
    volume_entry => {
      'VolumeName' => 'openvoxservercode',
      'Type'       => 'nfs',
      'Device'     => 'mynfsserver.com:/mynfspath',
      'Options'    => 'o=rw,nfsvers=4',
    },
  }
  
  
  quadlets::quadlet{'centos.container':
  ensure          => present,
  unit_entry     => {
   'Description' => 'Trivial Container that will be very lazy',
   'Requires'    => 'openvoxservercode.volume', 	< This one
   'Wants'       => 'openvoxservercode.volume'          < or this one 
  },
  service_entry       => {
    'TimeoutStartSec' => '900',
  },
  container_entry => {
    'Image' => 'quay.io/centos/centos:latest',
    'Exec'  => 'sh -c "sleep inf"'
    'Mount' => ['openvoxservercode:/openvoxservercode'] < Not sure about this syntax, but you get the idea
  },
  install_entry   => {
    'WantedBy' => 'default.target'
  },
  active          => true,
}

So, I would like the volume to be mounted BEFORE the container is launched.
I came up with this solution.
The problem is , if we do not add the Requires or Wants here, a new named volume is created and that could lead to errors.

@traylenator
Copy link
Contributor

Thanks for the example, I played and I now understood.

quadlets::quadlet { 'openvoxservercode.volume':
    ensure       => present,
    unit_entry   => {
      'Description' => 'openvoxserver Code Volume',
    },
    volume_entry => {
      'VolumeName' => 'openvoxservercode',
      'Driver'     => 'local',
    },
  }
  
  
  quadlets::quadlet{'centos.container':
  ensure          => present,
  unit_entry     => {
   'Description' => 'Trivial Container that will be very lazy',
   'Requires'    => 'openvoxservercode.volume',
   'After'       => 'openvoxservercode.volume',
  },
  service_entry       => {
    'TimeoutStartSec' => '900',
  },
  container_entry => {
    'Image' => 'quay.io/centos/centos:latest',
    'Exec'  => 'sh -c "sleep inf"',
    'Volume' => ['openvoxservercode:/foobar:Z'],
  },
  install_entry   => {
    'WantedBy' => 'default.target'
  },
  active          => true,
}

as you say this needs to be possible.

However this patch is the wrong fix for that.

We should change the type here

https://github.com/voxpupuli/puppet-quadlets/blob/master/manifests/quadlet.pp#L59C3-L59C52

and create a new type Quadlet::Unit::Unit its annoying we will have to duplicate much of Systemd::Unit::Unit but they are as demonstrated here not the same.

In the immediate term to unstick your self

'Requires'    => 'volume-openvoxservercode.service',
'After'       => 'volume-openvoxservercode.service',

Will presumably work.

@JGodin-C2C Can you create a new issue or patch in the quadlets module?

@traylenator
Copy link
Contributor

Needs some tests but voxpupuli/puppet-quadlets#52 good hopefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants