puppet-prod/modules/incus/manifests/init.pp
Ben Vincent 05df72e710 chore: set core.https_address for incus
- check the current config and update core.https_address if its wrong
2025-04-07 11:03:08 +10:00

66 lines
1.7 KiB
Puppet

class incus (
Array[String] $packages = [
'incus',
'incus-tools',
'incus-client'
],
Boolean $cluster = false,
Boolean $init = true,
String $bridge = 'incusbr0',
Stdlib::Port $server_port = 8443,
Stdlib::IP::Address $server_addr = $facts['networking']['ip'],
) {
package { $packages:
ensure => installed,
}
service { 'incus':
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
file_line { 'subuid_root':
ensure => present,
path => '/etc/subuid',
line => 'root:1000000:1000000000',
match => '^root:',
notify => Service['incus'],
}
file_line { 'subgid_root':
ensure => present,
path => '/etc/subgid',
line => 'root:1000000:1000000000',
match => '^root:',
notify => Service['incus'],
}
if $init {
file {'/root/incus.preseed.yaml':
ensure => file,
owner => root,
group => root,
content => template('incus/join_preseed.yaml.erb')
}
exec { 'initiate_incus':
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
command => 'cat /root/incus.preseed.yaml | incus admin init --preseed && touch /root/.incus_initialized',
refreshonly => true,
creates => '/root/.incus_initialized',
subscribe => File['/root/incus.preseed.yaml'],
}
}
# set core.https_address
if $facts['incus']['config']['core.https_address'] != "${server_addr}:${server_port}" {
exec { 'incus_config_set_core_https_address':
path => ['/bin', '/usr/bin'],
command => "incus config set core.https_address ${server_addr}:${server_port}",
}
}
}