Skip to content

Commit f922cc9

Browse files
author
Paul Kehle
authored
Merge pull request #1 from pgkehle/develop
Develop
2 parents 1de1f6e + 6c04b5f commit f922cc9

File tree

9 files changed

+157
-2
lines changed

9 files changed

+157
-2
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.yaml linguist-language=Ruby
2+
*.yml linguist-language=Ruby

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
language: python
3+
python: "2.7"
4+
before_install:
5+
- sudo apt-get update -qq
6+
- sudo apt-get install -qq python-apt python-pycurl
7+
install:
8+
- pip install ansible
9+
script:
10+
- echo travis.dev > inventory
11+
- ansible-playbook -i inventory --syntax-check --list-tasks test.yml
12+
- ansible-playbook -i inventory --extra-vars "sc_common_name=travis.dev" --connection=local --sudo -vvvv test.yml
13+
addons:
14+
hosts:
15+
- travis.dev

README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,31 @@
1-
# ansible-proxy-setup
2-
Enable a Proxy Server for a VM
1+
# Ansible: proxy-setup
2+
3+
Configure packages to use a Proxy Server
4+
5+
Available on Ansible Galaxy: [pgkehle.proxy-setup](https://galaxy.ansible.com/pgkehle/proxy-setup)
6+
7+
8+
# Examples
9+
10+
```YAML
11+
12+
- hosts: all
13+
14+
roles:
15+
- pgkehle.proxy-setup
16+
```
17+
18+
## License
19+
20+
MIT
21+
22+
## Author Information
23+
24+
Paul Kehle
25+
@pgkehle ([twitter](https://twitter.com/pgkehle), [github](https://github.com/pgkehle), [linkedin](https://www.linkedin.com/in/pgkehle))
26+
27+
### References
28+
29+
* http://digitaldrummerj.me/proxy-configurations/
30+
* http://askubuntu.com/questions/664777/systemwide-proxy-settings-in-ubuntu
31+
* http://www.linuxsecrets.com/blog/6managing-linux-systems/2015/05/26/1490-manually-change-ubuntu-proxy-settings-from-cli-command-line-terminal

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+

meta/main.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
galaxy_info:
2+
author: Paul Kehle <twitter.com/pgkehle>
3+
description: Configure packages to use a Proxy Server
4+
company: pgkehle
5+
license: MIT
6+
min_ansible_version: 1.9
7+
platforms:
8+
- name: Ubuntu
9+
versions:
10+
- xenial
11+
galaxy_tags:
12+
- system
13+
dependencies: []

tasks/main.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
3+
- set_fact:
4+
b1: []
5+
b2: []
6+
b3: []
7+
8+
#
9+
# /etc/environment
10+
#
11+
- name: Create the environment block
12+
set_fact:
13+
b1: "{{ b1 }} + ['{{ item }}=http://{{ proxy_addr }}:{{ proxy_port }}/']"
14+
with_items:
15+
- http_proxy
16+
- https_proxy
17+
- ftp_proxy
18+
- HTTP_PROXY
19+
- HTTPS_PROXY
20+
- FTP_PROXY
21+
22+
- name: Append to the environment block
23+
set_fact:
24+
b1: "{{ b1 }} + ['{{ item }}=\"localhost,127.0.0.1,localaddress,.localdomain.com\"']"
25+
with_items:
26+
- no_proxy
27+
- NO_PROXY
28+
29+
- name: Update /etc/environment
30+
blockinfile:
31+
dest: /etc/environment
32+
block: "{{ b1 | join('\n') }}"
33+
insertafter: EOF
34+
marker: "# {mark} ANSIBLE MANAGED BLOCK - PROXY"
35+
become: true
36+
37+
#
38+
# /etc/profile.d/proxy.sh
39+
#
40+
41+
- name: Create the profile block
42+
set_fact:
43+
b2: "{{ b2 }} + ['export {{ item.opt }}={{ item.prot }}://{{ proxy_addr }}:{{ proxy_port }}/']"
44+
with_items:
45+
- {opt: http_proxy, prot: http}
46+
- {opt: https_proxy, prot: http}
47+
- {opt: ftp_proxy, prot: http}
48+
- {opt: socks_proxy,prot: socks}
49+
- {opt: npm_config_proxy, prot: http}
50+
- {opt: npm_config_https_proxy, prot: http}
51+
52+
- name: Update /etc/profile.d/proxy.sh
53+
blockinfile:
54+
dest: /etc/profile.d/proxy.sh
55+
block: "{{ b2 | join('\n') }}"
56+
insertafter: EOF
57+
marker: "# {mark} ANSIBLE MANAGED BLOCK - PROXY"
58+
become: true
59+
60+
#
61+
# /etc/apt/apt.conf.d/80proxy
62+
#
63+
64+
- name: Create the apt.conf block
65+
set_fact:
66+
b3: "{{ b3 }} + ['{{ item }};']"
67+
with_items:
68+
- Acquire::http::proxy "http://{{ proxy_addr }}:{{ proxy_port }}/"
69+
- Acquire::ftp::proxy "ftp://{{ proxy_addr }}:{{ proxy_port }}/"
70+
- Acquire::https::proxy "https://{{ proxy_addr }}:{{ proxy_port }}/"
71+
72+
- name: Update /etc/apt/apt.conf.d/80proxy
73+
blockinfile:
74+
dest: /etc/apt/apt.conf.d/80proxy
75+
block: "{{ b3 | join('\n') }}"
76+
insertafter: EOF
77+
marker: "# {mark} ANSIBLE MANAGED BLOCK - PROXY"
78+
become: true
79+
80+
#
81+
# git
82+
#
83+
84+
- name: Add proxy to git
85+
shell: git config --global {{ item.opt }} {{ item.prot }}://{{ proxy_addr }}:{{ proxy_port }}
86+
with_items:
87+
- { opt: http.proxy, prot: http }
88+
- { opt: https.proxy, prot: https }
89+
90+
- name: Set git to https
91+
shell: git config --global url."https://github.com/".insteadOf git://github.com/

templates/.keep

Whitespace-only changes.

vars/main.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+

0 commit comments

Comments
 (0)