Repository: openshift/openshift-ansible

Issue:
origin-master service wont start with proxy configured 
#### Description

On a clean server, the default BYO is not working with proxy configured. 

##### Version

ansible 2.2.0.0
openshift-ansible-3.5.2-1-2-gc5a1e1e

##### Steps To Reproduce

1. Use the following config https://gist.github.com/aerialls/f45abab663233d5f2a63eda37d6f8789
2. Launch ansible with `ansible-playbook playbooks/byo/config.yml`

##### Expected Results

The service origin-master starts successfully.

##### Observed Results

The origin-master is not starting.

```
TASK [openshift_master : Start and enable master] ******************************
FAILED - RETRYING: TASK: openshift_master : Start and enable master (1 retries left).
fatal: [os01.foobar.com]: FAILED! => {"attempts": 1, "changed": false, "failed": true, "msg": "Unable to start service origin-master: Job for origin-master.service failed because the control process exited with error code. See \"systemctl status origin-master.service\" and \"journalctl -xe\" for details.\n"}
```

In the server logs, I can see the following error

```
Jan 25 16:34:13 os01 origin-master: F0125 16:34:13.845990    3399 plugins.go:140] Couldn't init admission plugin "BuildDefaults": error reading config: [pos 197]: json: expect char '"' but got char '['
```

If the lines `openshift_http_proxy` and `openshift_https_proxy` are commented, the service starts. 

##### Additional Information

I'm using `CentOS Linux release 7.3.1611 (Core)`


Discussion:
Hey @aerialls, what does that section of your `/etc/origin/master/master-config.yaml` look like when it fails? I'd expect the `BuildDefaults` plugin to look something like this based on your inventory but it must not be formatted correctly.

```
admissionConfig:
  pluginConfig:
    BuildDefaults:
      configuration:
        apiVersion: v1
        env:
        - name: HTTP_PROXY
          value: http://proxy.foobar.com:8080
        - name: HTTPS_PROXY
          value: http://proxy.foobar.com:8080
        - name: NO_PROXY
          value: .foobar.com
        gitHTTPProxy: http://proxy.foobar.com:8080
        gitHTTPSProxy: http://proxy.foobar.com:8080
        kind: BuildDefaultsConfig
```
Hey @abutcher! Thanks for the quick answer.

The config is currently this one:
```
admissionConfig:
  pluginConfig:
    BuildDefaults:
      configuration:
        apiVersion: v1
        env:
        - name: HTTP_PROXY
          value: http://proxy.foobar.com:8080
        - name: HTTPS_PROXY
          value: http://proxy.foobar.com:8080
        - name: NO_PROXY
          value:
          - .cluster.local
          - .foobar.com
          - os01.foobar.com
        - name: http_proxy
          value: http://proxy.foobar.com:8080
        - name: https_proxy
          value: http://proxy.foobar.com:8080
        - name: no_proxy
          value:
          - .cluster.local
          - .foobar.com
          - os01.foobar.com
        gitHTTPProxy: http://proxy.foobar.com:8080
        gitHTTPSProxy: http://proxy.foobar.com:8080
        gitNoProxy:
        - .cluster.local
        - .foobar.com
        - os01.foobar.com
        kind: BuildDefaultsConfig
        resources:
          limits: {}
          requests: {}
```
I think I found the problem. The problem is located with the list for the NO_PROXY section.

This configuration is not working:

```
        - name: NO_PROXY
          value:
          - .cluster.local
          - .foobar.com
          - os01.foobar.com
```

But this configuration is working:

```
        - name: NO_PROXY
          value: .cluster.local, .foobar.com, os01.foobar.com
```

The service waits for a string but the list serialized in JSON should be something like ["item1", "item2, "item3"].

The documentation seems to confirm this point (https://docs.openshift.org/latest/install_config/build_defaults_overrides.html) : `gitNoProxy: somedomain.com, otherdomain.com `.
Nice find @aerialls! Let me see if I can figure out what went wrong.

Resolving patch:
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -1641,7 +1641,7 @@ def set_proxy_facts(facts):
             # We always add local dns domain and ourselves no matter what
             common['no_proxy'].append('.' + common['dns_domain'])
             common['no_proxy'].append(common['hostname'])
-            common['no_proxy'] = sort_unique(common['no_proxy'])
+            common['no_proxy'] = ','.join(sort_unique(common['no_proxy']))
         facts['common'] = common
     return facts
 


Test patch: