summaryrefslogtreecommitdiff
path: root/modules/nspawn/manifests/os/arch.pp
blob: 0affee19a9e121dc5cd9de0dd4b3a492b4804e4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
define nspawn::os::arch (
  String $machine = $name,
) {

  ensure_packages(['arch-install-scripts'])

  exec { "/usr/bin/pacstrap /var/lib/machines/${machine} base puppet":
    creates => "/var/lib/machines/${machine}/etc/os-release",
  }

  file { "/var/lib/machines/${machine}/etc/systemd/network/20-puppet.conf":
    content => @(EOF)
    [Match]
    Name=host0

    [Network]
    Address=10.0.0.43/23
    Gateway=10.0.0.1
    IPv6AcceptRA=1
    | EOF
  }

  if $facts['machined-info'][$machine]['State'] == 'running' {
    notify { "Notify skipping ${machine} setup":
      message => "Skipping setup for ${machine}, already running",
    }
  } else {
    exec { "Enable systemd-networkd on ${machine}":
      command => [ '/usr/bin/systemd-nspawn',
        '-M', $machine,
        '--quiet',
        'systemctl', 'enable', 'systemd-networkd',
      ],
      # among others
      creates => "/var/lib/machines/${machine}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service",
    }
  }
}