Repository: openshift/openshift-ansible

Issue:
Adding zabbix template to config management

Remove images options in oadm command examples



Discussion:
:+1: 

@sdodson Yes, you are right.Thank you. I fixed them.

LGTM, just rebase

OK, rebased.

@sdodson @nak3 This readme is weird since it's titled "Installing OSEv3 from dev puddles using ansible". Should we have a public OSE readme that is separate and tuck this one away? Or should we say, "Hey! the real docs are over here < link >" in the top level readme and leave the internal bits in this one?

@abutcher I agree, we should get rid of discussion of internal processes and references to internal hostnames. We'd be better off hosting a set of inventories that set the right values on internal resources.

Can one of the admins verify this patch?

Can one of the admins verify this patch?

LGTM :+1:  @brenton docs changes only here, ready to merge


Resolving patch:
diff --git a/playbooks/openstack/sample-inventory/inventory.py b/playbooks/openstack/sample-inventory/inventory.py
new file mode 100755
--- /dev/null
+++ b/playbooks/openstack/sample-inventory/inventory.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+"""
+This is an Ansible dynamic inventory for OpenStack.
+
+It requires your OpenStack credentials to be set in clouds.yaml or your shell
+environment.
+
+"""
+
+from __future__ import print_function
+
+import json
+
+import shade
+
+
+def build_inventory():
+    '''Build the dynamic inventory.'''
+    cloud = shade.openstack_cloud()
+
+    inventory = {}
+
+    # TODO(shadower): filter the servers based on the `OPENSHIFT_CLUSTER`
+    # environment variable.
+    cluster_hosts = [
+        server for server in cloud.list_servers()
+        if 'metadata' in server and 'clusterid' in server.metadata]
+
+    masters = [server.name for server in cluster_hosts
+               if server.metadata['host-type'] == 'master']
+
+    etcd = [server.name for server in cluster_hosts
+            if server.metadata['host-type'] == 'etcd']
+    if not etcd:
+        etcd = masters
+
+    infra_hosts = [server.name for server in cluster_hosts
+                   if server.metadata['host-type'] == 'node' and
+                   server.metadata['sub-host-type'] == 'infra']
+
+    app = [server.name for server in cluster_hosts
+           if server.metadata['host-type'] == 'node' and
+           server.metadata['sub-host-type'] == 'app']
+
+    nodes = list(set(masters + infra_hosts + app))
+
+    dns = [server.name for server in cluster_hosts
+           if server.metadata['host-type'] == 'dns']
+
+    load_balancers = [server.name for server in cluster_hosts
+                      if server.metadata['host-type'] == 'lb']
+
+    osev3 = list(set(nodes + etcd + load_balancers))
+
+    inventory['cluster_hosts'] = {'hosts': [s.name for s in cluster_hosts]}
+    inventory['OSEv3'] = {'hosts': osev3}
+    inventory['masters'] = {'hosts': masters}
+    inventory['etcd'] = {'hosts': etcd}
+    inventory['nodes'] = {'hosts': nodes}
+    inventory['infra_hosts'] = {'hosts': infra_hosts}
+    inventory['app'] = {'hosts': app}
+    inventory['dns'] = {'hosts': dns}
+    inventory['lb'] = {'hosts': load_balancers}
+
+    for server in cluster_hosts:
+        if 'group' in server.metadata:
+            group = server.metadata.group
+            if group not in inventory:
+                inventory[group] = {'hosts': []}
+            inventory[group]['hosts'].append(server.name)
+
+    inventory['_meta'] = {'hostvars': {}}
+
+    for server in cluster_hosts:
+        ssh_ip_address = server.public_v4 or server.private_v4
+        hostvars = {
+            'ansible_host': ssh_ip_address
+        }
+
+        public_v4 = server.public_v4 or server.private_v4
+        if public_v4:
+            hostvars['public_v4'] = public_v4
+        # TODO(shadower): what about multiple networks?
+        if server.private_v4:
+            hostvars['private_v4'] = server.private_v4
+
+        node_labels = server.metadata.get('node_labels')
+        if node_labels:
+            hostvars['openshift_node_labels'] = node_labels
+
+        inventory['_meta']['hostvars'][server.name] = hostvars
+    return inventory
+
+
+if __name__ == '__main__':
+    print(json.dumps(build_inventory(), indent=4, sort_keys=True))


Test patch: