Skip to content

Commit

Permalink
Add support for http(s)_proxy to CoreOS, Fedora and OpenSUSE (kuberne…
Browse files Browse the repository at this point in the history
…tes-sigs#4669)

* Add support for http(s)_proxy to CoreOS and Fedora

* fix opensuse proxy support

* Fix CoreOS proxy support

* update documentation
  • Loading branch information
MarkusTeufelberger authored and k8s-ci-robot committed May 2, 2019
1 parent 3f45122 commit 560f50d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
1 change: 0 additions & 1 deletion roles/bootstrap-os/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Variables are listed with their default values, if applicable.

* `http_proxy`/`https_proxy`
The role will configure the package manager (if applicable) to download packages via a proxy.
This is currently implemented for CentOS/RHEL (`http_proxy` only) as well as Debian and Ubuntu (both `http_proxy` and `https_proxy` are respected)

* `override_system_hostname: true`
The role will set the hostname of the machine to the name it has according to Ansible's inventory (the variable `{{ inventory_hostname }}`).
Expand Down
3 changes: 3 additions & 0 deletions roles/bootstrap-os/tasks/bootstrap-coreos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
- name: Run bootstrap.sh
script: bootstrap.sh
become: true
environment:
http_proxy: "{{ http_proxy | default('') }}"
https_proxy: "{{ https_proxy | default('') }}"
when:
- need_bootstrap.rc != 0

Expand Down
20 changes: 20 additions & 0 deletions roles/bootstrap-os/tasks/bootstrap-fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@
tags:
- facts

- name: Check if a proxy is set in /etc/dnf/dnf.conf
raw: grep -qs 'proxy=' /etc/dnf/dnf.conf
register: need_http_proxy
failed_when: false
changed_when: false
# This command should always run, even in check mode
check_mode: false
environment: {}
when:
- http_proxy is defined

- name: Add http_proxy to /etc/dnf/dnf.conf if http_proxy is defined
raw: echo 'proxy={{ http_proxy }}' >> /etc/dnf/dnf.conf
become: true
environment: {}
when:
- http_proxy is defined
- need_http_proxy.rc != 0
- not is_atomic

# Fedora's policy as of Fedora 30 is to still install python2 as /usr/bin/python
# See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3 for the current status
- name: Install python on fedora
Expand Down
27 changes: 27 additions & 0 deletions roles/bootstrap-os/tasks/bootstrap-opensuse.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
---
# OpenSUSE ships with Python installed

- name: Set the http_proxy in /etc/sysconfig/proxy
lineinfile:
path: /etc/sysconfig/proxy
regexp: '^HTTP_PROXY='
line: 'HTTP_PROXY="{{ http_proxy }}"'
become: true
when:
- http_proxy is defined

- name: Set the https_proxy in /etc/sysconfig/proxy
lineinfile:
path: /etc/sysconfig/proxy
regexp: '^HTTPS_PROXY='
line: 'HTTPS_PROXY="{{ https_proxy }}"'
become: true
when:
- https_proxy is defined

- name: Enable proxies
lineinfile:
path: /etc/sysconfig/proxy
regexp: '^PROXY_ENABLED='
line: 'PROXY_ENABLED="yes"'
become: true
when:
- http_proxy is defined or https_proxy is defined

# Without this package, the get_url module fails when trying to handle https
- name: Install python-cryptography
zypper:
Expand Down

0 comments on commit 560f50d

Please sign in to comment.