Defined Type: apt::repository

Defined in:
manifests/repository.pp

Overview

Define: apt::repository

Add repository to /etc/apt/sources.list.d

Parameters

name

Implicit parameter. Name of the repository to add

url

Url of the repository to add

distro

Name of the distribution to use

repository

Name of the sections (ie main, contrib, non-free, …) to use

src_repo

Is this repository a source one (ie deb-src instead of deb)

key

Fingerprint of the key to retrieve

keyserver

Keyserver to use

key_url

Url from which fetch the key

template

Custom template to use to fill the repository configuration (instead of the default one)

source

Source to copy for this repository configuration

keyring_package

Optional name of the keyring package for the repo

environment

Environment to pass to the executed commands

path

Path to pass to the executed commands

ensure

Whether to add or delete this repository

Examples

Usage:

apt::repository { "name":
  url        => 'repository url',
  distro     => 'distrib name',
  repository => 'repository name(s)'
}

For example, to add the standard Ubuntu Lucid repository, you can use

apt::repository { "ubuntu":
 url        => "http://it.archive.ubuntu.com/ubuntu/",
 distro     => 'lucid',
 repository => 'main restricted',
}

This will make the file /etc/apt/sources.list.d/ubuntu.list with content:

deb http://it.archive.ubuntu.com/ubuntu/ lucid main restricted

If you have specified the source => true (the default is false), the line was:

deb-src http://it.archive.ubuntu.com/ubuntu/ lucid main restricted

Parameters:

  • url (Any)
  • distro (Any)
  • repository (Any)
  • src_repo (Any) (defaults to: false)
  • key (Any) (defaults to: '')
  • key_url (Any) (defaults to: '')
  • keyserver (Any) (defaults to: '')
  • template (Any) (defaults to: '')
  • source (Any) (defaults to: '')
  • environment (Any) (defaults to: undef)
  • keyring_package (Any) (defaults to: '')
  • path (Any) (defaults to: '/usr/sbin:/usr/bin:/sbin:/bin')
  • ensure (Any) (defaults to: 'present')
  • trusted_source (Any) (defaults to: false)


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'manifests/repository.pp', line 78

define apt::repository (
  $url,
  $distro,
  $repository,
  $src_repo        = false,
  $key             = '',
  $key_url         = '',
  $keyserver       = '',
  $template        = '',
  $source          = '',
  $environment     = undef,
  $keyring_package = '',
  $path            = '/usr/sbin:/usr/bin:/sbin:/bin',
  $ensure          = 'present',
  $trusted_source  = false
  ) {
  include apt

  $real_keyserver = $keyserver ? {
    ''      => $apt::keyserver,
    default => $keyserver,
  }
  $manage_file_source = $source ? {
    ''        => undef,
    default   => $source,
  }

  $manage_file_content = $source ? {
    ''        => $template ? {
      ''      => template('apt/repository.list.erb'),
      default => template($template),
    },
    default   => undef,
  }

  file { "apt_repository_${name}":
    ensure  => $ensure,
    path    => "${apt::sourceslist_dir}/${name}.list",
    mode    => $apt::config_file_mode,
    owner   => $apt::config_file_owner,
    group   => $apt::config_file_group,
    require => Package[$apt::package],
    notify  => Exec['aptget_update'],
    source  => $manage_file_source,
    content => $manage_file_content,
    audit   => $apt::manage_audit,
  }

  if $key and $key != '' and ! defined(Apt::Key[$key]) {
    apt::key { $key:
      url         => $key_url,
      environment => $environment,
      keyserver   => $real_keyserver,
      path        => $path,
      fingerprint => $key,
      notify      => Exec['aptget_update'],
    }
  }

  if $keyring_package != '' {
    if !defined(Package[$keyring_package]) {
      package { $keyring_package:
        ensure  => present,
        require => [ File["apt_repository_${name}"] ],
      }
    }
  }

}