• Stars
    star
    203
  • Rank 192,890 (Top 4 %)
  • Language
    Ruby
  • License
    Apache License 2.0
  • Created over 12 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Development repository for the apt cookbook

apt Cookbook

Cookbook Version CI State OpenCollective OpenCollective License

This cookbook includes recipes to execute apt-get update to ensure the local APT package cache is up to date. There are recipes for managing the apt-cacher-ng caching proxy and proxy clients. It also includes a custom resource for pinning packages via /etc/apt/preferences.d.

Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.

Requirements

Platforms

  • Ubuntu 12.04+
  • Debian 7+

May work with or without modification on other Debian derivatives.

Chef

  • Chef 13.3+

Cookbooks

  • None

Recipes

default

This recipe manually updates the timestamp file used to only run apt-get update if the cache is more than one day old.

This recipe should appear first in the run list of Debian or Ubuntu nodes to ensure that the package cache is up to date before managing any package resources with Chef.

This recipe also sets up a local cache directory for preseeding packages.

Including the default recipe on a node that does not support apt (such as Windows or RHEL) results in a noop.

cacher-client

Configures the node to use a apt-cacher-ng server to cache apt requests. Configuration of the server to use is located in default['apt']['cacher_client']['cacher_server'] which is a hash containing host, port, proxy_ssl, and bypass keys. Example:

{
  "apt": {
    "cacher_client": {
      "cacher_server": {
        "host": "cache_server.mycorp.dmz",
        "port": 1234,
        "proxy_ssl": true,
        "cache_bypass": {
          "download.oracle.com": "http"
        }
      }
    }
  }
}

Bypassing the cache

Occasionally you may come across repositories that do not play nicely when the node is using an apt-cacher-ng server. You can configure cacher-client to bypass the server and connect directly to the repository with the cache_bypass attribute.

To do this, you need to override the cache_bypass attribute with an hash of repositories, with each key as the repository URL and value as the protocol to use:

{
  "apt": {
    "cacher_client": {
      "cacher_server": {
        "cache_bypass": {
          "URL": "PROTOCOL"
        }
      }
    }
  }
}

For example, to prevent caching and directly connect to the repository at download.oracle.com via http and the repo at nginx.org via https

{
  "apt": {
    "cacher_client": {
      "cacher_server": {
        "cache_bypass": {
          "download.oracle.com": "http",
          "nginx.org": "https"
        }
      }
    }
  }
}

cacher-ng

Installs the apt-cacher-ng package and service so the system can provide APT caching. You can check the usage report at http://{hostname}:3142/acng-report.html.

If you wish to help the cacher-ng recipe seed itself, you must now explicitly include the cacher-client recipe in your run list after cacher-ng or you will block your ability to install any packages (ie. apt-cacher-ng).

unattended-upgrades

Installs and configures the unattended-upgrades package to provide automatic package updates. This can be configured to upgrade all packages or to just install security updates by setting ['apt']['unattended_upgrades']['allowed_origins'].

To pull just security updates, set origins_patterns to something like ["origin=Ubuntu,archive=trusty-security"] (for Ubuntu trusty) or ["origin=Debian,label=Debian-Security"] (for Debian).

Attributes

General

  • ['apt']['compile_time_update'] - force the default recipe to run apt-get update at compile time.
  • ['apt']['periodic_update_min_delay'] - minimum delay (in seconds) between two actual executions of apt-get update by the execute[apt-get-update-periodic] resource, default is '86400' (24 hours)

Caching

  • ['apt']['cacher_client']['cacher_server'] - Hash containing server information used by clients for caching. See the example in the recipes section above for the full format of the hash.
  • ['apt']['cacher_interface'] - interface to connect to the cacher-ng service, no default.
  • ['apt']['cacher_port'] - port for the cacher-ng service (used by server recipe only), default is '3142'
  • ['apt']['cacher_dir'] - directory used by cacher-ng service, default is '/var/cache/apt-cacher-ng'
  • ['apt']['compiletime'] - force the cacher-client recipe to run before other recipes. It forces apt to use the proxy before other recipes run. Useful if your nodes have limited access to public apt repositories. This is overridden if the cacher-ng recipe is in your run list. Default is 'false'

Unattended Upgrades

  • ['apt']['unattended_upgrades']['enable'] - enables unattended upgrades, default is false
  • ['apt']['unattended_upgrades']['update_package_lists'] - automatically update package list (apt-get update) daily, default is true
  • ['apt']['unattended_upgrades']['allowed_origins'] - array of allowed apt origins from which to pull automatic upgrades, defaults to a guess at the system's main origin and should almost always be overridden
  • ['apt']['unattended_upgrades']['origins_patterns'] - array of allowed apt origin patterns from which to pull automatic upgrades, defaults to none.
  • ['apt']['unattended_upgrades']['package_blacklist'] - an array of package which should never be automatically upgraded, defaults to none
  • ['apt']['unattended_upgrades']['auto_fix_interrupted_dpkg'] - attempts to repair dpkg state with dpkg --force-confold --configure -a if it exits uncleanly, defaults to false (contrary to the unattended-upgrades default)
  • ['apt']['unattended_upgrades']['minimal_steps'] - Split the upgrade into the smallest possible chunks. This makes the upgrade a bit slower but it has the benefit that shutdown while a upgrade is running is possible (with a small delay). Defaults to false.
  • ['apt']['unattended_upgrades']['install_on_shutdown'] - Install upgrades when the machine is shuting down instead of doing it in the background while the machine is running. This will (obviously) make shutdown slower. Defaults to false.
  • ['apt']['unattended_upgrades']['mail'] - Send email to this address for problems or packages upgrades. Defaults to no email.
  • ['apt']['unattended_upgrades']['sender'] - Send email from this address for problems or packages upgrades. Defaults to 'root'.
  • ['apt']['unattended_upgrades']['mail_only_on_error'] - If set, email will only be set on upgrade errors. Otherwise, an email will be sent after each upgrade. Defaults to true.
  • ['apt']['unattended_upgrades']['remove_unused_dependencies'] Do automatic removal of new unused dependencies after the upgrade. Defaults to false.
  • ['apt']['unattended_upgrades']['automatic_reboot'] - Automatically reboots without confirmation if a restart is required after the upgrade. Defaults to false.
  • ['apt']['unattended_upgrades']['dl_limit'] - Limits the bandwidth used by apt to download packages. Value given as an integer in kb/sec. Defaults to nil (no limit).
  • ['apt']['unattended_upgrades']['random_sleep'] - Wait a random number of seconds up to this value before running daily periodic apt actions. System default is 1800 seconds (30 minutes).
  • ['apt']['unattended_upgrades']['syslog_enable'] - Enable logging to syslog. Defaults to false.
  • ['apt']['unattended_upgrades']['syslog_facility'] - Specify syslog facility. Defaults to 'daemon'.
  • ['apt']['unattended_upgrades']['dpkg_options'] An array of dpkg options to be used specifically only for unattended upgrades. Defaults to [] which will prevent it from being rendered from the template in the resulting file.

Configuration for APT

  • ['apt']['confd']['force_confask'] - Prompt when overwriting configuration files. (default: false)
  • ['apt']['confd']['force_confdef'] - Don't prompt when overwriting configuration files. (default: false)
  • ['apt']['confd']['force_confmiss'] - Install removed configuration files when upgrading packages. (default: false)
  • ['apt']['confd']['force_confnew'] - Overwrite configuration files when installing packages. (default: false)
  • ['apt']['confd']['force_confold'] - Keep modified configuration files when installing packages. (default: false)
  • ['apt']['confd']['install_recommends'] - Consider recommended packages as a dependency for installing. (default: true)
  • ['apt']['confd']['install_suggests'] - Consider suggested packages as a dependency for installing. (default: false)

Libraries

There is an interface_ipaddress method that returns the IP address for a particular host and interface, used by the cacher-client recipe. To enable it on the server use the ['apt']['cacher_interface'] attribute.

Usage

Put recipe[apt] first in the run list. If you have other recipes that you want to use to configure how apt behaves, like new sources, notify the execute resource to run, e.g.:

template '/etc/apt/sources.list.d/my_apt_sources.list' do
  notifies :run, 'execute[apt-get update]', :immediately
end

The above will run during execution phase since it is a normal template resource, and should appear before other package resources that need the sources in the template.

Put recipe[apt::cacher-ng] in the run_list for a server to provide APT caching and add recipe[apt::cacher-client] on the rest of the Debian-based nodes to take advantage of the caching server.

If you want to cleanup unused packages, there is also the apt-get autoclean and apt-get autoremove resources provided for automated cleanup.

Resources

apt_preference

The apt_preference resource has been moved into chef-client in Chef 13.3.

See https://docs.chef.io/resource_apt_preference.html for usage details

apt_repository

The apt_repository resource has been moved into chef-client in Chef 12.9.

See https://docs.chef.io/resource_apt_repository.html for usage details

apt_update

The apt_update resource has been moved into chef-client in Chef 12.7.

See https://docs.chef.io/resource_apt_update.html for usage details

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website

More Repositories

1

docker

Development repository for the docker cookbook
Ruby
1,348
star
2

elasticsearch

Development repository for the elasticsearch cookbook
Ruby
882
star
3

aws

Development repository for the aws cookbook
Ruby
594
star
4

nginx

Development repository for the nginx cookbook
Ruby
551
star
5

rvm

Development repository for the rvm cookbook
Ruby
516
star
6

php

Development repository for the php cookbook
HTML
445
star
7

jenkins

Development repository for the jenkins cookbook
Ruby
424
star
8

java

Development repository for the java cookbook
Ruby
397
star
9

postgresql

Development repository for the postgresql cookbook
Ruby
357
star
10

mysql

Development repository for the mysql cookbook
Ruby
336
star
11

ruby_rbenv

Development repository for the ruby_rbenv cookbook
Ruby
332
star
12

redisio

Development repository for the redisio cookbook
HTML
297
star
13

apache2

Development repository for the apache2 cookbook
Ruby
282
star
14

nodejs

Development repository for the nodejs cookbook
Ruby
228
star
15

consul

Development repository for the consul cookbook
Ruby
191
star
16

haproxy

Development repository for the haproxy cookbook
Ruby
156
star
17

graphite

Development repository for the graphite cookbook
Ruby
154
star
18

homebrew

Development repository for the homebrew cookbook
Ruby
151
star
19

users

Development repository for the users cookbook
Ruby
138
star
20

nagios

Development repository for the nagios cookbook
Ruby
125
star
21

ruby_build

Development repository for the ruby_build cookbook
Ruby
123
star
22

git

Development repository for the git cookbook
Ruby
123
star
23

logrotate

Development repository for the logrotate cookbook
Ruby
122
star
24

percona

Development repository for the percona cookbook
Ruby
117
star
25

openssh

Development repository for the openssh cookbook
Ruby
114
star
26

powershell

Development repository for the powershell cookbook
Ruby
110
star
27

postfix

Development repository for the postfix cookbook
Ruby
103
star
28

tomcat

Development repository for the tomcat cookbook
Ruby
99
star
29

openvpn

Development repository for the openvpn cookbook
Ruby
98
star
30

ark

Development repository for the ark cookbook
Ruby
98
star
31

line

Development repository for the line cookbook
Ruby
97
star
32

firewall

Development repository for the firewall cookbook
Ruby
95
star
33

yum

Development repository for the yum cookbook
Ruby
95
star
34

kafka

Development repository for the kafka cookbook
Ruby
91
star
35

erlang

Development repository for the erlang cookbook
Ruby
87
star
36

sublimechef

A Sublime Text 2 Package for authoring Chef related files
84
star
37

iis

Development repository for the iis cookbook
Ruby
82
star
38

etcd

Development repository for the etcd cookbook
Ruby
79
star
39

cron

Development repository for the cron cookbook
Ruby
77
star
40

grafana

Development repository for the grafana cookbook
Ruby
76
star
41

chef-splunk

Development repository for the chef-splunk cookbook
Ruby
76
star
42

sc-mongodb

Development repository for the sc-mongodb cookbook
Ruby
75
star
43

certificate

Development repository for the certificate cookbook
Ruby
73
star
44

ntp

Development repository for the ntp cookbook
Ruby
68
star
45

rsyslog

Development repository for the rsyslog cookbook
Ruby
65
star
46

sql_server

Development repository for the sql_server cookbook
Ruby
63
star
47

fail2ban

Development repository for the fail2ban cookbook
Ruby
58
star
48

selinux

Development repository for the selinux cookbook
Ruby
58
star
49

windows_ad

Development repository for the windows_ad cookbook
Ruby
58
star
50

vagrant

Development repository for the vagrant cookbook
Ruby
57
star
51

varnish

Development repository for the varnish cookbook
Ruby
56
star
52

lvm

Development repository for the lvm cookbook
Ruby
56
star
53

perl

Development repository for the perl cookbook
Ruby
52
star
54

golang

Development repository for the golang cookbook
Ruby
50
star
55

memcached

Development repository for the memcached cookbook
Ruby
49
star
56

mariadb

Development repository for the mariadb cookbook
Ruby
48
star
57

hashicorp-vault

Development repository for the hashicorp-vault cookbook
Ruby
46
star
58

rundeck

Development repository for the rundeck cookbook
Ruby
46
star
59

ossec

Development repository for the ossec cookbook
Ruby
44
star
60

ufw

Development repository for the ufw cookbook
Ruby
44
star
61

confluence

Development repository for the confluence cookbook
Ruby
43
star
62

openldap

Development repository for the openldap cookbook
Ruby
42
star
63

nfs

Development repository for the nfs cookbook
Ruby
40
star
64

kubernetes

Development repository for the kubernetes cookbook
Ruby
39
star
65

vim

Development repository for the vim cookbook
Ruby
38
star
66

maven

Development repository for the maven cookbook
Ruby
36
star
67

bind

Development repository for the bind cookbook
Ruby
36
star
68

passenger_apache2

Development repository for the passenger_apache2 cookbook
Ruby
36
star
69

keepalived

Development repository for the keepalived cookbook
Ruby
33
star
70

aptly

Development repository for the aptly cookbook
Ruby
31
star
71

samba

Development repository for the samba cookbook
Ruby
30
star
72

resolver

Development repository for the resolver cookbook
Ruby
28
star
73

squid

Development repository for the squid cookbook
Ruby
28
star
74

snort

Development repository for the snort cookbook
Ruby
27
star
75

pyenv

Development repository for the pyenv cookbook
Ruby
27
star
76

freebsd

Development repository for the freebsd cookbook
Ruby
27
star
77

dhcp

Development repository for the dhcp cookbook
Ruby
27
star
78

nrpe

Development repository for the nrpe cookbook
Ruby
25
star
79

rsync

Development repository for the rsync cookbook
Ruby
24
star
80

github

Development repository for the github cookbook
Ruby
24
star
81

filesystem

Development repository for the filesystem cookbook
Ruby
24
star
82

yum-epel

Development repository for the yum-epel cookbook
Ruby
23
star
83

network_interfaces

Development repository for the network_interfaces cookbook
Ruby
23
star
84

drbd

Development repository for the drbd cookbook
Ruby
19
star
85

djbdns

Development repository for the djbdns cookbook
Ruby
19
star
86

sssd_ldap

Development repository for the sssd_ldap cookbook
Ruby
18
star
87

dpkg_autostart

Development repository for the dpkg_autostart cookbook
Ruby
18
star
88

packagecloud

Development repository for the packagecloud cookbook
Ruby
17
star
89

webpi

Development repository for the webpi cookbook
Ruby
17
star
90

gems

Development repository for the gems cookbook
Ruby
17
star
91

language-chef

Development repository for the language-chef plugin for the Atom text editor
JavaScript
17
star
92

elixir

Development repository for the elixir cookbook
Ruby
17
star
93

htpasswd

Development repository for the htpasswd cookbook
Ruby
15
star
94

stunnel

Development repository for the stunnel cookbook
Ruby
14
star
95

apparmor

Development repository for the apparmor cookbook
Ruby
14
star
96

smartmontools

Development repository for the smartmontools cookbook
HTML
13
star
97

transmission

Development repository for the transmission cookbook
Ruby
13
star
98

gpg

Development repository for the gpg cookbook
Ruby
12
star
99

wix

Development repository for the wix cookbook
Ruby
12
star
100

tftp

Development repository for the tftp cookbook
Ruby
11
star