summaryrefslogtreecommitdiff
path: root/manifests/os/debian.pp
blob: c821ba670dbf3cdd07cc92762fe26533c2e28507 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
define nspawn::os::debian (
  String $os_version,
  String $machine = $name,
) {
  ensure_packages(['debootstrap'])

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

  file { "/var/lib/machines/${machine}/etc/network/interfaces":
    ensure  => file,
    content => @(EOF)
    # File managed by puppet
    # See interfaces(5)
    source-directory /etc/network/interfaces.d
    | EOF
  }

  file { "/var/lib/machines/${machine}/etc/network/interfaces.d":
    ensure  => directory,
  }

  file { "/var/lib/machines/${machine}/etc/network/interfaces.d/puppet":
    ensure  => file,
    content => @(EOF)
    # File managed by puppet
    auto host0
    # allow-hotplug host0

    iface host0 inet static
    address 10.0.0.42/23
    gateway 10.0.0.1

    iface host0 inet6 auto
    private 0
    | EOF
  }

  file { "/var/lib/machines/${machine}/tmp/puppet7-release/${os_version}.deb":
    ensure => file,
    source => "https://apt.puppet.com/puppet7-release-${os_version}.deb"
  }
  ~> exec { "Set up puppet repo for ${machine}":
    command => [ '/usr/bin/systemd-nspawn',
    '-M', $machine,
    '--quiet', 
    '/bin/sh', '-c', 
    "dpkg -i '/tmp/puppet7-release-${os_version}.deb' && apt update"
    ],
  }

  exec { "install puppet-agent on ${machine}":
    command => [ '/usr/bin/systemd-nspawn',
    '-M', $machine,
    '--quiet', 
    'apt', 'install', 'puppet-agent',
    ],
    creates => "/var/lib/machines/${machine}/opt/puppetlabs/bin/puppet",
  }
}