-
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
14 changed files
with
258 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,35 @@ | ||
--- | ||
# Based on ansible-lint config | ||
extends: default | ||
|
||
rules: | ||
braces: | ||
max-spaces-inside: 1 | ||
level: error | ||
brackets: | ||
max-spaces-inside: 1 | ||
level: error | ||
colons: | ||
max-spaces-after: -1 | ||
level: error | ||
commas: | ||
max-spaces-after: -1 | ||
level: error | ||
comments: disable | ||
comments-indentation: disable | ||
document-start: disable | ||
empty-lines: | ||
max: 3 | ||
level: error | ||
hyphens: | ||
level: error | ||
indentation: disable | ||
key-duplicates: enable | ||
line-length: | ||
max: 120 | ||
level: warning | ||
new-line-at-end-of-file: enable | ||
new-lines: | ||
type: unix | ||
trailing-spaces: disable | ||
truthy: enable |
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,34 @@ | ||
## only run the linter, no testing | ||
.PHONY: lint | ||
lint: | ||
@molecule lint | ||
|
||
## molecule test already does linting | ||
.PHONY: test | ||
test: | ||
@molecule test --all | ||
|
||
## Spin up an instance | ||
.PHONY: create | ||
create: | ||
@molecule create | ||
|
||
## Converge (run the playbook) | ||
.PHONY: converge | ||
converge: create | ||
@molecule converge | ||
|
||
## Log into the running instance | ||
.PHONY: login | ||
login: | ||
@molecule login -h $1 | ||
|
||
## Destroy the instance | ||
.PHONY: destroy | ||
destroy: | ||
@molecule destroy | ||
|
||
.PHONY: run | ||
## Run the playbook locally without molecule | ||
run: | ||
@ansible-playbook -v tests/test.yml -i tests/inventory |
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,48 @@ | ||
apt_proxy | ||
========= | ||
|
||
Configure proxy settings for APT | ||
|
||
Requirements | ||
------------ | ||
|
||
None | ||
|
||
Role Variables | ||
-------------- | ||
|
||
`apt_proxy__filename` Filename to be used to store the proxy configuration | ||
`apt_proxy__http_url`: HTTP proxy URL. Default is the remote value or empty | ||
`apt_proxy__https_url`: HTTPS proxy URL. Default is the remote value or empty | ||
`apt_proxy__ftp_url`: FTP proxy URL. Default is the remote value or empty | ||
|
||
By default the role takes proxy settings found in the remote host and will use those in `apt_proxy__filename`. | ||
If the user does not specify any custom values in those url variables above, then the role will check if proxy settings are found in the remote host environment. If they are not found, and the user did not specify custom ones, then the role won't create the `apt_proxy__filename` | ||
|
||
Dependencies | ||
------------ | ||
|
||
none | ||
|
||
Example Playbook | ||
---------------- | ||
|
||
```yaml | ||
- hosts: servers | ||
roles: | ||
- role: donhector.apt_proxy | ||
vars: | ||
apt_proxy__http_url: http://user:pass@server.com:3128 | ||
apt_proxy__https_url: https://user:pass@server.com:3128 | ||
apt_proxy__ftp_url: ftp://user:pass@server.com:3128 | ||
``` | ||
|
||
License | ||
------- | ||
|
||
MIT | ||
|
||
Author Information | ||
------------------ | ||
|
||
github.com/donhector |
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,7 @@ | ||
--- | ||
# defaults file for apt_proxy | ||
|
||
apt_proxy__filename: '99proxy.conf' | ||
apt_proxy__http_url: '{{ ansible_env.http_proxy | default() }}' | ||
apt_proxy__https_url: '{{ ansible_env.https_proxy | default() }}' | ||
apt_proxy__ftp_url: '{{ ansible_env.ftp_proxy | default() }}' |
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 @@ | ||
--- | ||
# handlers file for apt_proxy |
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 @@ | ||
--- | ||
galaxy_info: | ||
role_name: apt_proxy | ||
description: apt proxy configuration settings | ||
author: donhector | ||
company: darkenv.com | ||
|
||
license: MIT | ||
|
||
min_ansible_version: 2.11 | ||
|
||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- all | ||
- name: Debian | ||
versions: | ||
- all | ||
|
||
galaxy_tags: | ||
- apt | ||
- proxy | ||
- ubuntu | ||
- debian | ||
|
||
dependencies: [] |
5 changes: 5 additions & 0 deletions
5
donhector/workstation/roles/apt_proxy/molecule/default/converge.yml
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,5 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
roles: | ||
- role: donhector.apt_proxy |
62 changes: 62 additions & 0 deletions
62
donhector/workstation/roles/apt_proxy/molecule/default/molecule.yml
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,62 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
|
||
driver: | ||
name: docker | ||
|
||
lint: | | ||
set -e | ||
yamllint . | ||
ansible-lint | ||
platforms: | ||
|
||
- name: ubuntu2004 | ||
image: ${MOLECULE_DISTRO:-geerlingguy/docker-ubuntu2004-ansible:latest} | ||
# Needed for systemd | ||
command: ${MOLECULE_DOCKER_COMMAND:-/lib/systemd/systemd} | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
capabilities: | ||
- SYS_ADMIN | ||
pre_build_image: true | ||
|
||
- name: debian9 | ||
image: ${MOLECULE_DISTRO:-geerlingguy/docker-debian9-ansible:latest} | ||
# Needed for systemd | ||
command: ${MOLECULE_DOCKER_COMMAND:-/lib/systemd/systemd} | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
capabilities: | ||
- SYS_ADMIN | ||
pre_build_image: true | ||
|
||
- name: debian10 | ||
image: ${MOLECULE_DISTRO:-geerlingguy/docker-debian10-ansible:latest} | ||
# Needed for systemd | ||
command: ${MOLECULE_DOCKER_COMMAND:-/lib/systemd/systemd} | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
capabilities: | ||
- SYS_ADMIN | ||
pre_build_image: true | ||
|
||
- name: debian11 | ||
image: ${MOLECULE_DISTRO:-geerlingguy/docker-debian11-ansible:latest} | ||
# Needed for systemd | ||
command: ${MOLECULE_DOCKER_COMMAND:-/lib/systemd/systemd} | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
capabilities: | ||
- SYS_ADMIN | ||
pre_build_image: true | ||
|
||
provisioner: | ||
name: ansible | ||
playbooks: | ||
converge: ${MOLECULE_PLAYBOOK:-converge.yml} | ||
|
||
verifier: | ||
name: ansible | ||
enabled: false |
10 changes: 10 additions & 0 deletions
10
donhector/workstation/roles/apt_proxy/molecule/default/verify.yml
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 @@ | ||
--- | ||
# This is an example playbook to execute Ansible tests. | ||
|
||
- name: Verify | ||
hosts: all | ||
gather_facts: false | ||
tasks: | ||
- name: Example assertion | ||
assert: | ||
that: true |
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,11 @@ | ||
--- | ||
# tasks file for apt_proxy | ||
|
||
- name: Configure APT to use HTTP/HTTPS proxy | ||
become: true | ||
ansible.builtin.template: | ||
src: 'proxy.conf.j2' | ||
dest: '/etc/apt/apt.conf.d/{{ apt_proxy__filename }}' | ||
mode: '0644' | ||
when: ansible_os_family == 'Debian' and | ||
(apt_proxy__http_url or apt_proxy__https_url or apt_proxy__ftp_url) |
9 changes: 9 additions & 0 deletions
9
donhector/workstation/roles/apt_proxy/templates/proxy.conf.j2
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 @@ | ||
{% if apt_proxy__http_url %} | ||
Acquire::http::Proxy "{{ apt_proxy__http_url }}"; | ||
{% endif %} | ||
{% if apt_proxy__https_url %} | ||
Acquire::https::Proxy "{{ apt_proxy__https_url }}"; | ||
{% endif %} | ||
{% if apt_proxy__ftp_url %} | ||
Acquire::ftp::Proxy "{{ apt_proxy__ftp_url }}"; | ||
{% 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,6 @@ | ||
--- | ||
- hosts: localhost | ||
vars: | ||
ansible_connection: local | ||
roles: | ||
- { role: donhector.apt_proxy } |
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 @@ | ||
--- | ||
# vars file for apt_proxy |