elnappo.apt_cacher_ng

ansible-role-apt-cacher-ng

构建状态 Ansible Galaxy

该角色简单地在启动时安装并启动 apt-cacher-ng。有关 apt-cacher-ng 的更多信息,请访问 https://www.unix-ag.uni-kl.de/~bloch/acng/

要求

Ubuntu 或 Debian

角色变量

  • apt_cacher_ng_port: 3142
  • apt_cacher_ng_cache_dir: /var/cache/apt-cacher-ng
  • apt_cacher_ng_setup_ufw: True 添加一个 ufw 规则以允许 apt-cacher-ng

依赖

无。

示例剧本

- hosts: servers
  remote_user: root
  roles:
   - { role: elnappo.apt_cacher_ng }

客户端配置

使用 ansible

将 apt_proxy 设置为主机变量

[host:vars]
apt_proxy=http://apt.example.com:3142/

对于整个系统:

- name: 设置 apt 代理
  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

templates/apt_proxy.conf:

# {{ ansible_managed }}
Acquire::http { Proxy "{{ apt_proxy }}"; };
Acquire::https { Proxy "https://"; };

仅针对一个任务:

- apt: name=ufw state=installed
  environment:
    http_proxy: "{{ apt_proxy }}"

不使用 ansible

替换服务器的 IP 或 FQDN!

$ echo 'Acquire::http { Proxy "http://apt.example.com:3142"; };' > /etc/apt/apt.conf.d/01proxy

导入 localhost 缓存

$ 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"

导入完成后,可以删除符号链接:

$ rm /var/cache/apt-cacher-ng/_import/apt

许可证

MIT

作者信息

elnappo elnappo@nerdpol.io

关于项目

Install apt-cacher-ng

安装
ansible-galaxy install elnappo.apt_cacher_ng
许可证
mit
下载
23.7k
拥有者