Skip to content

Commit

Permalink
Merge pull request #14 from fidanf/feat-wget
Browse files Browse the repository at this point in the history
Feat: configure wget using proxy for all users
  • Loading branch information
sandvige authored Sep 23, 2021
2 parents d7f88eb + 7348afb commit 64caada
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ proxy_password: ''
proxy_ignore: [] # Proxy whitelist : array of values such as ['localhost', '192.168.0.0/16']
proxy_url: "http://{{ proxy_ip }}:{{ proxy_port }}"
proxy_configure_apt: yes # set to no if you wish apt not to be configured by the role
proxy_configure_wget: yes # set to no if you wish wget not to be configured by the role
proxy_wgetrc_path: /etc/wgetrc
proxy_npm_users: # since proxy configuration is set in a per-user file (~/.npmrc), the task needs to run for a list of users running npm commands on the host
- root
proxy_git_users: # same as npm but lies in ~/.gitconfig
Expand All @@ -66,6 +68,7 @@ proxy_docker_users: # same as npm but lies in ~/.docker/config.json. File permis
group: root
proxy_docker_update_systemd: yes # update docker's systemd unit with env variables
proxy_docker_restart_on_change: yes # allows docker daemon to be restarted

```
## Troubleshooting
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ proxy_ignore: []
proxy_url: "http://{{ proxy_ip }}:{{ proxy_port }}"
# Setup apt
proxy_configure_apt: yes
# Setup wget in /etc/wgetrc
proxy_configure_wget: yes
proxy_wgetrc_path: /etc/wgetrc
# User list for ~/.npmrc file
proxy_npm_users:
- root
Expand Down
5 changes: 5 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
- php-pear
state: present

- name: Ensure wget is present
apt:
name: wget
state: present

roles:
- name: geerlingguy.nodejs
vars:
Expand Down
15 changes: 15 additions & 0 deletions tasks/_wget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: Configure wget
lineinfile:
dest: "{{ proxy_wgetrc_path }}"
regexp: "^#?{{ item.key }}"
backrefs: yes
line: "{{ item.key }} = {{ item.value }}"
state: present
loop:
- key: use_proxy
value: "yes"
- key: http_proxy
value: "{{ proxy_ip }}"
- key: https_proxy
value: "{{ proxy_port }}"
7 changes: 7 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
when: proxy_configure_apt
tags: ['apt']

- name: Configure wget
import_tasks: _wget.yml
when:
- proxy_configure_wget
- '"wget" in apt_packages'
tags: ['wget']

- name: Configure Git
import_tasks: _git.yml
when: '"git" in apt_packages'
Expand Down

0 comments on commit 64caada

Please sign in to comment.