Skip to content

Commit

Permalink
Merge pull request #5 from stone-payments/feat/proxy_redhat
Browse files Browse the repository at this point in the history
Make possible to not manage RedHat package tools
  • Loading branch information
bcdonadio authored Aug 20, 2018
2 parents d2fcd28 + 583dde1 commit 7971ed2
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 68 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ proxy_port: ""
proxy_auth: false
proxy_user: ""
proxy_pass: ""
proxy_redhat: true #configure yum and RHSM to use the proxy
proxy_whitelist:
- "127.0.0.1"
- "localhost"
64 changes: 33 additions & 31 deletions tasks/linux/disable.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
---
- name: configure yum to not use the proxy
lineinfile:
path: "/etc/yum.conf"
regexp: '^proxy\s*=.*'
state: absent
- block:
- name: configure yum to not use the proxy
lineinfile:
path: "/etc/yum.conf"
regexp: '^proxy\s*=.*'
state: absent

- name: configure RHSM to not use the proxy
lineinfile:
path: "/etc/rhsm/rhsm.conf"
regexp: "{{ item.regexp }}"
state: absent
with_items:
- regexp: '^proxy_hostname\s*=.*'
- regexp: '^proxy_port\s*=.*'
when: ansible_distribution == "RedHat"
- name: configure RHSM to not use the proxy
lineinfile:
path: "/etc/rhsm/rhsm.conf"
regexp: "{{ item.regexp }}"
state: absent
with_items:
- regexp: '^proxy_hostname\s*=.*'
- regexp: '^proxy_port\s*=.*'
when: ansible_distribution == "RedHat"

- name: configure yum to not use proxy authentication
lineinfile:
path: "/etc/yum.conf"
regexp: "{{ item.regexp }}"
state: absent
with_items:
- regexp: '^proxy_username\s*=.*'
- regexp: '^proxy_password\s*=.*'
- name: configure yum to not use proxy authentication
lineinfile:
path: "/etc/yum.conf"
regexp: "{{ item.regexp }}"
state: absent
with_items:
- regexp: '^proxy_username\s*=.*'
- regexp: '^proxy_password\s*=.*'

- name: configure RHSM to not use the proxy authentication
lineinfile:
path: "/etc/rhsm/rhsm.conf"
regexp: "{{ item.regexp }}"
state: absent
with_items:
- regexp: '^proxy_user\s*=.*'
- regexp: '^proxy_password\s*=.*'
when: ansible_distribution == "RedHat"
- name: configure RHSM to not use the proxy authentication
lineinfile:
path: "/etc/rhsm/rhsm.conf"
regexp: "{{ item.regexp }}"
state: absent
with_items:
- regexp: '^proxy_user\s*=.*'
- regexp: '^proxy_password\s*=.*'
when: ansible_distribution == "RedHat"
when: proxy_redhat

- name: configure the default profile to not use a proxy
file:
Expand Down
76 changes: 39 additions & 37 deletions tasks/linux/enable.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,56 @@
---
- name: configure yum to use the proxy
lineinfile:
path: "/etc/yum.conf"
regexp: '^proxy\s*=.*'
line: "proxy={{proxy_proto}}://{{proxy_address}}:{{proxy_port}}"

- name: configure RHSM to use the proxy (HTTP-only)
lineinfile:
path: "/etc/rhsm/rhsm.conf"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items:
- regexp: '^proxy_hostname\s*=.*'
line: "proxy_hostname={{proxy_address}}"
- regexp: '^proxy_port\s*=.*'
line: "proxy_port={{proxy_port}}"
when:
- ansible_distribution == "RedHat"
- proxy_proto is defined
- proxy_proto == "http"

- block:
- name: configure yum to use the proxy authentication
- name: configure yum to use the proxy
lineinfile:
path: "/etc/yum.conf"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items:
- regexp: '^proxy_username\s*=.*'
line: "proxy_username={{proxy_user}}"
- regexp: '^proxy_password\s*=.*'
line: "proxy_password={{proxy_pass}}"
regexp: '^proxy\s*=.*'
line: "proxy={{proxy_proto}}://{{proxy_address}}:{{proxy_port}}"

- name: configure RHSM to use the proxy authentication (HTTP-only)
- name: configure RHSM to use the proxy (HTTP-only)
lineinfile:
path: "/etc/rhsm/rhsm.conf"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items:
- regexp: '^proxy_user\s*=.*'
line: "proxy_user={{proxy_user}}"
- regexp: '^proxy_password\s*=.*'
line: "proxy_password={{proxy_pass}}"
- regexp: '^proxy_hostname\s*=.*'
line: "proxy_hostname={{proxy_address}}"
- regexp: '^proxy_port\s*=.*'
line: "proxy_port={{proxy_port}}"
when:
- ansible_distribution == "RedHat"
- proxy_proto is defined
- proxy_proto == "http"
when:
- proxy_auth is defined
- proxy_auth

- block:
- name: configure yum to use the proxy authentication
lineinfile:
path: "/etc/yum.conf"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items:
- regexp: '^proxy_username\s*=.*'
line: "proxy_username={{proxy_user}}"
- regexp: '^proxy_password\s*=.*'
line: "proxy_password={{proxy_pass}}"

- name: configure RHSM to use the proxy authentication (HTTP-only)
lineinfile:
path: "/etc/rhsm/rhsm.conf"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items:
- regexp: '^proxy_user\s*=.*'
line: "proxy_user={{proxy_user}}"
- regexp: '^proxy_password\s*=.*'
line: "proxy_password={{proxy_pass}}"
when:
- ansible_distribution == "RedHat"
- proxy_proto is defined
- proxy_proto == "http"
when:
- proxy_auth is defined
- proxy_auth
when: proxy_redhat

- name: configure the default profile to use the proxy
template:
Expand Down

0 comments on commit 7971ed2

Please sign in to comment.