Repository: openshift/openshift-ansible

Issue:
OverflowError on openshift_control_plane : set_fact task
#### Description

During initial installation, failure occurs on `openshift_control_plane : set_fact` task, with python error `OverflowError: cannot convert float infinity to integer`


##### Version

```
Red Hat Enterprise Linux Server release 7.6 (Maipo)
Ansible version: ansible 2.8.1
openshift-ansible-3.11.128-1
Python 3.6.8
```

##### Steps To Reproduce
1. run `ansible-playbook -i inventory/inventory playbooks/deploy_cluster.yml`


##### Expected Results
Expected for installation to continue
```
Example command and output or error messages
```

##### Observed Results
Playbook fails on step `openshift_control_plane : set_fact` with error `OverflowError: cannot convert float infinity to integer` and no additional useful information. Below is output of task:

```
TASK [openshift_control_plane : set_fact] ******************************************************************************************************
task path: /root/bostjan_openshift/openshift-ansible/roles/openshift_control_plane/tasks/main.yml:163
Monday 08 July 2019  14:22:39 +0200 (0:00:00.735)       0:05:46.143 ***********
The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 144, in run
    res = self._execute()
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 576, in _execute
    self._task.post_validate(templar=templar)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/task.py", line 268, in post_validate
    super(Task, self).post_validate(templar)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/base.py", line 384, in post_validate
    value = templar.template(getattr(self, name))
  File "/usr/lib/python2.7/site-packages/ansible/template/__init__.py", line 584, in template
    disable_lookups=disable_lookups,
  File "/usr/lib/python2.7/site-packages/ansible/template/__init__.py", line 539, in template
    disable_lookups=disable_lookups,
  File "/usr/lib/python2.7/site-packages/ansible/template/__init__.py", line 804, in do_template
    res = j2_concat(rf)
  File "<template>", line 9, in root
  File "/root/bostjan_openshift/openshift-ansible/roles/lib_utils/filter_plugins/openshift_master.py", line 495, in translate_idps
    Dumper=AnsibleDumper))
  File "/usr/lib64/python2.7/site-packages/yaml/__init__.py", line 202, in dump
    return dump_all([data], stream, Dumper=Dumper, **kwds)
  File "/usr/lib64/python2.7/site-packages/yaml/__init__.py", line 186, in dump_all
    explicit_start=explicit_start, explicit_end=explicit_end)
  File "/usr/lib64/python2.7/site-packages/yaml/cyaml.py", line 64, in __init__
    version=version, tags=tags)
  File "_yaml.pyx", line 973, in _yaml.CEmitter.__init__ (ext/_yaml.c:11787)
OverflowError: cannot convert float infinity to integer

fatal: [vlo7top002.example.com]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}
```

##### Additional Information

It seems that problem is with parsing `openshift_master_identity_providers` variable; even if I do not specify it in inventory file, same error occurs.

Below is used inventory file:
```
[masters]
vlo7top00[2:4].example.com

[etcd]
vlo7top00[2:4].example.com

[lb]
vlo7top001.example.com

[nodes]
vlo7top002.example.com openshift_node_group_name="node-config-master-crio" openshift_public_hostname=vlo7top002.example.com openshift_public_ip=x.x.x.x
vlo7top003.example.com openshift_node_group_name="node-config-master-crio" openshift_public_hostname=vlo7top003.example.com openshift_public_ip=x.x.x.x
vlo7top004.example.com openshift_node_group_name="node-config-master-crio" openshift_public_hostname=vlo7top004.example.com openshift_public_ip=x.x.x.x
vlo7top005.example.com openshift_node_group_name="node-config-infra-crio" openshift_public_hostname=vlo7top005.example.com openshift_public_ip=x.x.x.x
vlo7top006.example.com openshift_node_group_name="node-config-infra-crio" openshift_public_hostname=vlo7top006.example.com openshift_public_ip=x.x.x.x
vlo7top007.example.com openshift_node_group_name="node-config-infra-crio" openshift_public_hostname=vlo7top007.example.com openshift_public_ip=x.x.x.x
vlo7top008.example.com openshift_node_group_name="node-config-compute-crio" openshift_public_hostname=vlo7top008.example.com openshift_public_ip=x.x.x.x
vlo7top009.example.com openshift_node_group_name="node-config-compute-crio" openshift_public_hostname=vlo7top009.example.com openshift_public_ip=x.x.x.x
vlo7top010.example.com openshift_node_group_name="node-config-compute-crio" openshift_public_hostname=vlo7top010.example.com openshift_public_ip=x.x.x.x
vlo7top011.example.com openshift_node_group_name="node-config-compute-crio" openshift_public_hostname=vlo7top011.example.com openshift_public_ip=x.x.x.x

[glusterfs]
vlo7top005.example.com glusterfs_ip=x.x.x.x glusterfs_devices='[ "/dev/sdc" ]'
vlo7top006.example.com glusterfs_ip=x.x.x.x glusterfs_devices='[ "/dev/sdc" ]'
vlo7top007.example.com glusterfs_ip=x.x.x.x glusterfs_devices='[ "/dev/sdc" ]'


[OSEv3:children]
masters
etcd
lb
nodes
glusterfs


[OSEv3:vars]
ansible_ssh_user=root
openshift_deployment_type=origin
openshift_release="3.11"

openshift_use_crio=True
openshift_use_crio_only=False
openshift_crio_enable_docker_gc=True

openshift_master_cluster_hostname=vlo7top001.example.com
openshift_master_cluster_public_hostname=vlo7top001.example.com
openshift_master_cluster_method=native
openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider'}]
os_firewall_use_firewalld=true
openshift_docker_additional_registries=index.docker.io:443

openshift_master_default_subdomain=o7t.example.com
os_sdn_network_plugin_name=redhat/openshift-ovs-multitenant
osm_cluster_network_cidr=10.52.0.0/14
openshift_portal_net=10.56.0.0/16

openshift_storage_glusterfs_namespace=storage
openshift_storage_glusterfs_storageclass=true
openshift_storage_glusterfs_storageclass_default=true
openshift_storage_glusterfs_block_deploy=true
openshift_storage_glusterfs_block_host_vol_size=100
openshift_storage_glusterfs_block_storageclass=true
openshift_storage_glusterfs_block_storageclass_default=true
openshift_storage_glusterfs_is_native=false
openshift_storage_glusterfs_heketi_is_native=true
openshift_storage_glusterfs_heketi_executor=ssh
openshift_storage_glusterfs_heketi_ssh_port=22
openshift_storage_glusterfs_heketi_ssh_user=root
openshift_storage_glusterfs_heketi_ssh_sudo=false
openshift_storage_glusterfs_heketi_ssh_keyfile="/root/.ssh/id_rsa"

openshift_http_proxy=http://test.proxy:8080
openshift_https_proxy=http://test.proxy:8080
openshift_no_proxy=localhost,127.0.0.1,.example.com,.cluster.local,.svc,.o7t.example.com,172.30.0.1,10.52.0.0/14,10.56.0.0/16
```



Discussion:

Resolving patch:
diff --git a/roles/lib_utils/filter_plugins/openshift_master.py b/roles/lib_utils/filter_plugins/openshift_master.py
--- a/roles/lib_utils/filter_plugins/openshift_master.py
+++ b/roles/lib_utils/filter_plugins/openshift_master.py
@@ -10,10 +10,18 @@
 from ansible.parsing.yaml.dumper import AnsibleDumper
 from ansible.plugins.filter.core import to_bool as ansible_bool
 
-from ansible.module_utils.six import string_types, u
+from ansible.module_utils.six import string_types, u, PY2
 
 import yaml
 
+if PY2:
+    INFINITY = float('inf')
+else:
+    import math
+    # AUDIT: this member was added in py3 only
+    # pylint: disable=no-member
+    INFINITY = math.inf
+
 
 class IdentityProviderBase(object):
     """ IdentityProviderBase
@@ -491,7 +499,7 @@ def translate_idps(idps, api_version):
         return u(yaml.dump([idp.to_dict() for idp in idp_list],
                            allow_unicode=True,
                            default_flow_style=False,
-                           width=float("inf"),
+                           width=INFINITY,
                            Dumper=AnsibleDumper))
 
     @staticmethod


Test patch: