-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
315 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vagrant | ||
vagrant.retry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
sudo: required | ||
dist: trusty | ||
|
||
language: python | ||
python: "2.7" | ||
|
||
env: | ||
- ANSIBLE_VERSION=latest | ||
- ANSIBLE_VERSION=2.1.0.0 | ||
- ANSIBLE_VERSION=2.0.2.0 | ||
- ANSIBLE_VERSION=2.0.0.0 | ||
|
||
before_install: | ||
- sudo apt-get update -qq | ||
|
||
install: | ||
# Install ansible. | ||
- if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install --no-binary ansible ansible; else pip install --no-binary ansible ansible==$ANSIBLE_VERSION; fi | ||
|
||
# Check ansible version. | ||
- ansible --version | ||
|
||
script: | ||
# Check the role/playbook's syntax. | ||
- ansible-playbook -i tests/inventory tests/test.yml --syntax-check | ||
|
||
# Run the role/playbook with ansible-playbook. | ||
- ansible-playbook -i tests/inventory tests/test.yml -vvvv | ||
|
||
# Run the role/playbook again, checking to make sure it's idempotent. | ||
- > | ||
ansible-playbook -i tests/inventory tests/test.yml | ||
| grep -q 'changed=0.*failed=0' | ||
&& (echo 'Idempotence test: pass' && exit 0) | ||
|| (echo 'Idempotence test: fail' && exit 1) | ||
notifications: | ||
webhooks: https://galaxy.ansible.com/api/v1/notifications/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Ansible Role for Apt-Cacher NG | ||
|
||
[![Build Status][1]][2] | ||
|
||
Installs and configures [Apt-Cacher NG][3] on Debian/Ubuntu servers and respective clients. | ||
|
||
## Requirements | ||
|
||
For clients, a running Apt-Cacher NG server they can connect to. | ||
|
||
## Role Variables | ||
|
||
``` | ||
# Define this in your playbook to set up on client. | ||
# apt_cacher_ng_server: "1.1.1.1" | ||
# Define this if you'd like to use the backports version. | ||
# (you must have the jessie-backports ource installed). | ||
# apt_cacher_ng_default_release: jessie-backports | ||
apt_cacher_ng_bind_address: "0.0.0.0" | ||
apt_cacher_ng_port: "3142" | ||
apt_cacher_ng_report_page: "acng-report.html" | ||
apt_cacher_ng_cache_dir: "/var/cache/apt-cacher-ng" | ||
apt_cacher_ng_log_dir: "/var/log/apt-cacher-ng" | ||
apt_cacher_ng_verbose_log: "0" | ||
apt_cacher_ng_local_dirs: "acng-doc /usr/share/doc/apt-cacher-ng" | ||
apt_cacher_ng_support_dir: "/usr/lib/apt-cacher-ng" | ||
apt_cacher_ng_pid_file: "/var/run/apt-cacher-ng/pid" | ||
apt_cacher_ng_ex_treshold: "4" | ||
#apt_cacher_ng_proxy: "https://username:proxypassword@proxy.example.net:3129" | ||
apt_cacher_ng_remap_debrep: "file:deb_mirror*.gz /debian ; file:backends_debian" | ||
apt_cacher_ng_remap_uburep: "file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu" | ||
apt_cacher_ng_remap_alxrep: "file:archlx_mirrors /archlinux ; file:backend_archlx" | ||
apt_cacher_ng_remap_fedora: "file:fedora_mirrors" | ||
apt_cacher_ng_remap_epel: "file:epel_mirrors" | ||
apt_cacher_ng_remap_slrep: "file:sl_mirrors" | ||
apt_cacher_ng_remap_gentoo: "file:gentoo_mirrors.gz /gentoo ; file:backends_gentoo" | ||
``` | ||
|
||
## Role Tags | ||
|
||
Each part of the setup has a tag. | ||
|
||
``` | ||
apt-cacher-ng:install | ||
apt-cacher-ng:configure | ||
apt-cacher-ng:client | ||
``` | ||
|
||
## Dependencies | ||
|
||
None. | ||
|
||
## Example Playbook | ||
|
||
``` | ||
# playbook.yml | ||
--- | ||
- hosts: servers | ||
become: yes | ||
vars_files: | ||
- vars/main.yml | ||
roles: | ||
- { role: noplanman.apt-cacher-ng } | ||
``` | ||
``` | ||
# vars/main.yml (server) | ||
--- | ||
apt_cacher_ng_port: "3142" | ||
apt_cacher_ng_cache_dir: "/var/cache/apt-cacher-ng" | ||
apt_cacher_ng_log_dir: "/var/log/apt-cacher-ng" | ||
``` | ||
``` | ||
# vars/main.yml (client) | ||
--- | ||
apt_cacher_ng_server: "1.1.1.1" | ||
apt_cacher_ng_port: "3142" | ||
``` | ||
|
||
## License | ||
|
||
MIT | ||
|
||
[1]: https://travis-ci.org/noplanman/ansible-apt-cacher-ng.svg?branch=master "Travis-CI Build Status" | ||
[2]: https://travis-ci.org/noplanman/ansible-apt-cacher-ng "Travis-CI Tests" | ||
[3]: https://www.unix-ag.uni-kl.de/~bloch/acng/ "Apt-Cacher NG" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
role = File.basename(File.expand_path(File.dirname(__FILE__))) | ||
|
||
boxes = [ | ||
{ | ||
:name => "ubuntu-1204", | ||
:box => "opscode-ubuntu-12.04", | ||
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box", | ||
}, | ||
{ | ||
:name => "ubuntu-1404", | ||
:box => "opscode-ubuntu-14.04", | ||
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box", | ||
}, | ||
{ | ||
:name => "ubuntu-1604", | ||
:box => "opscode-ubuntu-16.04", | ||
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-16.04_chef-provisionerless.box", | ||
}, | ||
{ | ||
:name => "debian-711", | ||
:box => "opscode-debian-7.11", | ||
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.11_chef-provisionerless.box", | ||
}, | ||
{ | ||
:name => "debian-85", | ||
:box => "opscode-debian-8.5", | ||
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-8.5_chef-provisionerless.box", | ||
}, | ||
] | ||
|
||
Vagrant.configure("2") do |config| | ||
boxes.each do |box| | ||
config.vm.define box[:name] do |vms| | ||
vms.vm.box = box[:box] | ||
vms.vm.box_url = box[:url] | ||
vms.vm.hostname = "ansible-#{role}-#{box[:name]}" | ||
|
||
vms.vm.provider "virtualbox" do |v| | ||
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"] | ||
v.customize ["modifyvm", :id, "--memory", "256"] | ||
end | ||
|
||
vms.vm.provision :ansible do |ansible| | ||
ansible.playbook = "tests/vagrant.yml" | ||
ansible.verbose = "vv" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
# Define this in your playbook to set up on client. | ||
# apt_cacher_ng_server: "1.1.1.1" | ||
|
||
# Define this if you'd like to use the backports version. | ||
# (you must have the jessie-backports ource installed). | ||
# apt_cacher_ng_default_release: jessie-backports | ||
|
||
apt_cacher_ng_bind_address: "0.0.0.0" | ||
apt_cacher_ng_port: "3142" | ||
apt_cacher_ng_report_page: "acng-report.html" | ||
apt_cacher_ng_cache_dir: "/var/cache/apt-cacher-ng" | ||
apt_cacher_ng_log_dir: "/var/log/apt-cacher-ng" | ||
apt_cacher_ng_verbose_log: "0" | ||
apt_cacher_ng_local_dirs: "acng-doc /usr/share/doc/apt-cacher-ng" | ||
apt_cacher_ng_support_dir: "/usr/lib/apt-cacher-ng" | ||
apt_cacher_ng_pid_file: "/var/run/apt-cacher-ng/pid" | ||
apt_cacher_ng_ex_treshold: "4" | ||
#apt_cacher_ng_proxy: "https://username:proxypassword@proxy.example.net:3129" | ||
apt_cacher_ng_remap_debrep: "file:deb_mirror*.gz /debian ; file:backends_debian" | ||
apt_cacher_ng_remap_uburep: "file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu" | ||
apt_cacher_ng_remap_alxrep: "file:archlx_mirrors /archlinux ; file:backend_archlx" | ||
apt_cacher_ng_remap_fedora: "file:fedora_mirrors" | ||
apt_cacher_ng_remap_epel: "file:epel_mirrors" | ||
apt_cacher_ng_remap_slrep: "file:sl_mirrors" | ||
apt_cacher_ng_remap_gentoo: "file:gentoo_mirrors.gz /gentoo ; file:backends_gentoo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- name: restart apt-cacher-ng | ||
service: name=apt-cacher-ng state=restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
galaxy_info: | ||
author: Armando Lüscher | ||
description: Install and run Apt-Cacher NG on a Debian-like system. | ||
license: MIT | ||
min_ansible_version: 2.0.0.0 | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- precise | ||
- trusty | ||
- xenial | ||
- name: Debian | ||
versions: | ||
- wheezy | ||
- jessie | ||
galaxy_tags: | ||
- apt | ||
- package | ||
- install | ||
- update | ||
- cache | ||
- caching | ||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- name: Add proxy server configuration to client | ||
template: | ||
src: 01proxy.j2 | ||
dest: /etc/apt/apt.conf.d/01proxy | ||
owner: root | ||
group: root | ||
mode: 0644 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- name: Ensure default configuration | ||
template: | ||
src: acng.conf.j2 | ||
dest: /etc/apt-cacher-ng/acng.conf | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: restart apt-cacher-ng |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: Update sources | ||
apt: update_cache=yes cache_valid_time=86400 | ||
changed_when: no | ||
|
||
- name: Install apt-cacher-ng | ||
apt: | ||
name: apt-cacher-ng | ||
default_release: "{{ apt_cacher_ng_default_release|default(omit) }}" | ||
state: present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- include: install.yml | ||
tags: apt-cacher-ng:install | ||
when: apt_cacher_ng_server is not defined | ||
- include: configure.yml | ||
tags: apt-cacher-ng:configure | ||
when: apt_cacher_ng_server is not defined | ||
- include: client.yml | ||
tags: apt-cacher-ng:client | ||
when: apt_cacher_ng_server is defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Acquire::http::Proxy "http://{{ apt_cacher_ng_server }}:{{ apt_cacher_ng_port }}"; | ||
Acquire::https::Proxy "false"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# {{ ansible_managed }} | ||
|
||
BindAddress: {{ apt_cacher_ng_bind_address }} | ||
CacheDir: {{ apt_cacher_ng_cache_dir }} | ||
ExTreshold: {{ apt_cacher_ng_ex_treshold }} | ||
LocalDirs: {{ apt_cacher_ng_local_dirs }} | ||
LogDir: {{ apt_cacher_ng_log_dir }} | ||
PidFile: {{ apt_cacher_ng_pid_file }} | ||
Port: {{ apt_cacher_ng_port }} | ||
Remap-debrep: {{ apt_cacher_ng_remap_debrep }} # Debian Archives | ||
Remap-uburep: {{ apt_cacher_ng_remap_uburep }} # Ubuntu Archives | ||
Remap-alxrep: {{ apt_cacher_ng_remap_alxrep }} # Arch Linux | ||
Remap-fedora: {{ apt_cacher_ng_remap_fedora }} # Fedora Linux | ||
Remap-epel: {{ apt_cacher_ng_remap_epel }} # Fedora EPEL | ||
Remap-slrep: {{ apt_cacher_ng_remap_slrep }} # Scientific Linux | ||
Remap-gentoo: {{ apt_cacher_ng_remap_gentoo }} # Gentoo Archives | ||
ReportPage: {{ apt_cacher_ng_report_page }} | ||
SupportDir: {{ apt_cacher_ng_support_dir }} | ||
VerboseLog: {{ apt_cacher_ng_verbose_log }} | ||
{% if apt_cacher_ng_proxy is defined %} | ||
Proxy: {{ apt_cacher_ng_proxy }} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- hosts: localhost | ||
connection: local | ||
become: yes | ||
roles: [../../] | ||
vars: | ||
apt_cacher_ng_bind_address: "127.0.0.1" | ||
apt_cacher_ng_port: "5555" | ||
apt_cacher_ng_report_page: "report-page.html" | ||
post_tasks: | ||
- name: Check if Apt-Cacher NG is running | ||
uri: url="http://127.0.0.1:5555/report-page.html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- hosts: all | ||
remote_user: vagrant | ||
become: yes | ||
roles: [../../] | ||
vars: | ||
apt_cacher_ng_bind_address: "127.0.0.1" | ||
apt_cacher_ng_port: "5555" | ||
apt_cacher_ng_report_page: "report-page.html" | ||
post_tasks: | ||
- name: Check if Apt-Cacher NG is running | ||
uri: url="http://127.0.0.1:5555/report-page.html" |