elnappo.apt_cacher_ng
ansible-role-apt-cacher-ng
This role installs and starts apt-cacher-ng so that it runs automatically on boot. You can learn more about apt-cacher-ng at https://www.unix-ag.uni-kl.de/~bloch/acng/.
Requirements
You need to have Ubuntu or Debian.
Role Variables
apt_cacher_ng_port
: The port used (default is 3142)apt_cacher_ng_cache_dir
: Location of the cache directory (default is/var/cache/apt-cacher-ng
)apt_cacher_ng_setup_ufw
: Set to True to add a firewall rule for apt-cacher-ng.
Dependencies
There are no dependencies.
Example Playbook
- hosts: servers
remote_user: root
roles:
- { role: elnappo.apt_cacher_ng }
Client Configuration
Using Ansible
You can set the apt proxy as a host variable:
[host:vars]
apt_proxy=http://apt.example.com:3142/
For the entire system:
- name: Set up apt proxy
template: src=templates/apt_proxy.conf dest=/etc/apt/apt.conf.d/01proxy owner=root group=root mode=0644
when: ansible_os_family == "Debian" and apt_proxy is defined
Template: templates/apt_proxy.conf
:
# {{ ansible_managed }}
Acquire::http { Proxy "{{ apt_proxy }}"; };
Acquire::https { Proxy "https://"; };
For a single task:
- apt: name=ufw state=installed
environment:
http_proxy: "{{ apt_proxy }}"
Without Ansible
Make sure to replace the server IP or FQDN!
$ echo 'Acquire::http { Proxy "http://apt.example.com:3142"; };' > /etc/apt/apt.conf.d/01proxy
Importing Localhost Cache
$ echo 'Acquire::http { Proxy "http://localhost:3142"; };' > /etc/apt/apt.conf.d/01proxy
$ apt-get update
$ apt-get autoclean
$ mkdir -p /var/cache/apt-cacher-ng/_import
$ ln -s /var/cache/apt /var/cache/apt-cacher-ng/_import/apt
$ wget "http://localhost:3142/acng-report.html?abortOnErrors=aOe&doImport=Start+Import&calcSize=cs&asNeeded=an#bottom"
After the import, you can remove the symlink:
$ rm /var/cache/apt-cacher-ng/_import/apt
License
This role is licensed under MIT.
Author Information
elnappo elnappo@nerdpol.io
Installa
ansible-galaxy install elnappo.apt_cacher_ng
Licenza
mit
Download
23.7k
Proprietario