From 5a99c7b6acf1c4bc0f1a83af77bf434ac5b45548 Mon Sep 17 00:00:00 2001 From: Tomas Sedovic Date: Fri, 8 Dec 2017 11:54:36 +0100 Subject: Fix yaml syntax error in the sample inventory --- playbooks/openstack/sample-inventory/group_vars/OSEv3.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'playbooks/openstack/sample-inventory') diff --git a/playbooks/openstack/sample-inventory/group_vars/OSEv3.yml b/playbooks/openstack/sample-inventory/group_vars/OSEv3.yml index 933117127..481807dc9 100644 --- a/playbooks/openstack/sample-inventory/group_vars/OSEv3.yml +++ b/playbooks/openstack/sample-inventory/group_vars/OSEv3.yml @@ -14,12 +14,12 @@ openshift_hosted_router_wait: True openshift_hosted_registry_wait: True ## Openstack credentials -#openshift_cloudprovider_kind=openstack +#openshift_cloudprovider_kind: openstack #openshift_cloudprovider_openstack_auth_url: "{{ lookup('env','OS_AUTH_URL') }}" #openshift_cloudprovider_openstack_username: "{{ lookup('env','OS_USERNAME') }}" #openshift_cloudprovider_openstack_password: "{{ lookup('env','OS_PASSWORD') }}" #openshift_cloudprovider_openstack_tenant_name: "{{ lookup('env','OS_TENANT_NAME') }}" -#openshift_cloudprovider_openstack_region="{{ lookup('env', 'OS_REGION_NAME') }}" +#openshift_cloudprovider_openstack_region: "{{ lookup('env', 'OS_REGION_NAME') }}" ## Use Cinder volume for Openshift registry: -- cgit v1.2.3 From 4514a0ddb20480d43f153f25de94a267f10f0696 Mon Sep 17 00:00:00 2001 From: Jiri Mencak Date: Sun, 17 Dec 2017 23:54:51 +0100 Subject: OpenStack provisioning -- support cns. --- playbooks/openstack/sample-inventory/group_vars/all.yml | 5 +++++ playbooks/openstack/sample-inventory/inventory.py | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'playbooks/openstack/sample-inventory') diff --git a/playbooks/openstack/sample-inventory/group_vars/all.yml b/playbooks/openstack/sample-inventory/group_vars/all.yml index c7afe9a24..d63229120 100644 --- a/playbooks/openstack/sample-inventory/group_vars/all.yml +++ b/playbooks/openstack/sample-inventory/group_vars/all.yml @@ -7,6 +7,7 @@ openshift_openstack_dns_nameservers: [] # # - set custom hostnames for roles by uncommenting corresponding lines #openshift_openstack_master_hostname: "master" #openshift_openstack_infra_hostname: "infra-node" +#openshift_openstack_cns_hostname: "cns" #openshift_openstack_node_hostname: "app-node" #openshift_openstack_lb_hostname: "lb" #openshift_openstack_etcd_hostname: "etcd" @@ -30,6 +31,7 @@ openshift_openstack_external_network_name: "public" # # - note: do not remove openshift_openstack_default_image_name definition #openshift_openstack_master_image_name: "centos7" #openshift_openstack_infra_image_name: "centos7" +#openshift_openstack_cns_image_name: "centos7" #openshift_openstack_node_image_name: "centos7" #openshift_openstack_lb_image_name: "centos7" #openshift_openstack_etcd_image_name: "centos7" @@ -37,6 +39,7 @@ openshift_openstack_default_image_name: "centos7" openshift_openstack_num_masters: 1 openshift_openstack_num_infra: 1 +openshift_openstack_num_cns: 0 openshift_openstack_num_nodes: 2 # # Used Flavors @@ -44,6 +47,7 @@ openshift_openstack_num_nodes: 2 # # - note: do note remove openshift_openstack_default_flavor definition #openshift_openstack_master_flavor: "m1.medium" #openshift_openstack_infra_flavor: "m1.medium" +#openshift_openstack_cns_flavor: "m1.medium" #openshift_openstack_node_flavor: "m1.medium" #openshift_openstack_lb_flavor: "m1.medium" #openshift_openstack_etcd_flavor: "m1.medium" @@ -57,6 +61,7 @@ openshift_openstack_default_flavor: "m1.medium" # # - note: do not remove docker_default_volume_size definition #openshift_openstack_docker_master_volume_size: "15" #openshift_openstack_docker_infra_volume_size: "15" +#openshift_openstack_docker_cns_volume_size: "15" #openshift_openstack_docker_node_volume_size: "15" #openshift_openstack_docker_etcd_volume_size: "2" #openshift_openstack_docker_lb_volume_size: "5" diff --git a/playbooks/openstack/sample-inventory/inventory.py b/playbooks/openstack/sample-inventory/inventory.py index ad3fd936b..084b5c0a0 100755 --- a/playbooks/openstack/sample-inventory/inventory.py +++ b/playbooks/openstack/sample-inventory/inventory.py @@ -42,7 +42,10 @@ def build_inventory(): if server.metadata['host-type'] == 'node' and server.metadata['sub-host-type'] == 'app'] - nodes = list(set(masters + infra_hosts + app)) + cns = [server.name for server in cluster_hosts + if server.metadata['host-type'] == 'cns'] + + nodes = list(set(masters + infra_hosts + app + cns)) dns = [server.name for server in cluster_hosts if server.metadata['host-type'] == 'dns'] @@ -59,6 +62,7 @@ def build_inventory(): inventory['nodes'] = {'hosts': nodes} inventory['infra_hosts'] = {'hosts': infra_hosts} inventory['app'] = {'hosts': app} + inventory['glusterfs'] = {'hosts': cns} inventory['dns'] = {'hosts': dns} inventory['lb'] = {'hosts': load_balancers} @@ -93,6 +97,9 @@ def build_inventory(): hostvars['openshift_hostname'] = server.private_v4 hostvars['openshift_public_hostname'] = server.name + if server.metadata['host-type'] == 'cns': + hostvars['glusterfs_devices'] = ['/dev/nvme0n1'] + node_labels = server.metadata.get('node_labels') if node_labels: hostvars['openshift_node_labels'] = node_labels -- cgit v1.2.3 From ff1d04276bbc8a7542ff0e33a12e1b971e2745b7 Mon Sep 17 00:00:00 2001 From: Tomas Sedovic Date: Tue, 2 Jan 2018 16:11:29 +0100 Subject: Return a openshift_node_labels as a dict The OpenStack dynamic inventory was setting the `openshift_node_labels` value as a string which causes a failure with the `lib_utils_oo_dict_to_keqv_list` filter. Fixes #6555 --- playbooks/openstack/sample-inventory/inventory.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'playbooks/openstack/sample-inventory') diff --git a/playbooks/openstack/sample-inventory/inventory.py b/playbooks/openstack/sample-inventory/inventory.py index ad3fd936b..55d2f7211 100755 --- a/playbooks/openstack/sample-inventory/inventory.py +++ b/playbooks/openstack/sample-inventory/inventory.py @@ -9,6 +9,7 @@ environment. from __future__ import print_function +from collections import Mapping import json import shade @@ -94,6 +95,10 @@ def build_inventory(): hostvars['openshift_public_hostname'] = server.name node_labels = server.metadata.get('node_labels') + # NOTE(shadower): the node_labels value must be a dict not string + if not isinstance(node_labels, Mapping): + node_labels = json.loads(node_labels) + if node_labels: hostvars['openshift_node_labels'] = node_labels -- cgit v1.2.3 From de44771f97d506f0dbbbcff90938fc566e8a9ac1 Mon Sep 17 00:00:00 2001 From: Tomas Sedovic Date: Thu, 4 Jan 2018 16:12:11 +0100 Subject: Specify the Cinder version in the inventory As described in[1], OpenShift currently only works with Block Storage API v2 and the version autodetection is failing to figure that out. [1]: https://github.com/openshift/openshift-docs/issues/5730 --- playbooks/openstack/sample-inventory/group_vars/OSEv3.yml | 1 + 1 file changed, 1 insertion(+) (limited to 'playbooks/openstack/sample-inventory') diff --git a/playbooks/openstack/sample-inventory/group_vars/OSEv3.yml b/playbooks/openstack/sample-inventory/group_vars/OSEv3.yml index 481807dc9..a8663f946 100644 --- a/playbooks/openstack/sample-inventory/group_vars/OSEv3.yml +++ b/playbooks/openstack/sample-inventory/group_vars/OSEv3.yml @@ -20,6 +20,7 @@ openshift_hosted_registry_wait: True #openshift_cloudprovider_openstack_password: "{{ lookup('env','OS_PASSWORD') }}" #openshift_cloudprovider_openstack_tenant_name: "{{ lookup('env','OS_TENANT_NAME') }}" #openshift_cloudprovider_openstack_region: "{{ lookup('env', 'OS_REGION_NAME') }}" +#openshift_cloudprovider_openstack_blockstorage_version: v2 ## Use Cinder volume for Openshift registry: -- cgit v1.2.3 From c35c8f3e8369eb3d2ab7675c30e8d258eccd6a18 Mon Sep 17 00:00:00 2001 From: Tomas Sedovic Date: Thu, 4 Jan 2018 16:15:44 +0100 Subject: Allow using server names in openstack dynamic inv When deploying on OpenStack with internal DNS configured, this will set `openshift_hostname` to the Nova server name instead of its IP address. Without those two matching, the OpenStack cloud provider configuration will fail and the OpenShift nodes will not start. --- playbooks/openstack/sample-inventory/inventory.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'playbooks/openstack/sample-inventory') diff --git a/playbooks/openstack/sample-inventory/inventory.py b/playbooks/openstack/sample-inventory/inventory.py index 45cc4e15a..76e658eb7 100755 --- a/playbooks/openstack/sample-inventory/inventory.py +++ b/playbooks/openstack/sample-inventory/inventory.py @@ -89,13 +89,15 @@ def build_inventory(): # TODO(shadower): what about multiple networks? if server.private_v4: hostvars['private_v4'] = server.private_v4 + hostvars['openshift_ip'] = server.private_v4 + # NOTE(shadower): Yes, we set both hostname and IP to the private # IP address for each node. OpenStack doesn't resolve nodes by # name at all, so using a hostname here would require an internal # DNS which would complicate the setup and potentially introduce # performance issues. - hostvars['openshift_ip'] = server.private_v4 - hostvars['openshift_hostname'] = server.private_v4 + hostvars['openshift_hostname'] = server.metadata.get( + 'openshift_hostname', server.private_v4) hostvars['openshift_public_hostname'] = server.name if server.metadata['host-type'] == 'cns': -- cgit v1.2.3 From d82066b0d47b35c56da95cf75649b75de0ccdaff Mon Sep 17 00:00:00 2001 From: Tomas Sedovic Date: Fri, 12 Jan 2018 14:14:30 +0100 Subject: Move the OpenStack dynamic inventory from sample Keeping the dynamic inventory in the `sample-inventory` alongside the `group_vars` poses a problem: when we update the inventory, our users won't get the latest version. The dynamic inventory should be independent of the OpenShift or OpenStack configuration and the users should be able to either pass it explicitly or create a symlink if they want. --- playbooks/openstack/sample-inventory/inventory.py | 119 ---------------------- 1 file changed, 119 deletions(-) delete mode 100755 playbooks/openstack/sample-inventory/inventory.py (limited to 'playbooks/openstack/sample-inventory') diff --git a/playbooks/openstack/sample-inventory/inventory.py b/playbooks/openstack/sample-inventory/inventory.py deleted file mode 100755 index 76e658eb7..000000000 --- a/playbooks/openstack/sample-inventory/inventory.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/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 - -from collections import Mapping -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'] - - cns = [server.name for server in cluster_hosts - if server.metadata['host-type'] == 'cns'] - - nodes = list(set(masters + infra_hosts + app + cns)) - - 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['glusterfs'] = {'hosts': cns} - 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'] = server.public_v4 - hostvars['openshift_public_ip'] = server.public_v4 - # TODO(shadower): what about multiple networks? - if server.private_v4: - hostvars['private_v4'] = server.private_v4 - hostvars['openshift_ip'] = server.private_v4 - - # NOTE(shadower): Yes, we set both hostname and IP to the private - # IP address for each node. OpenStack doesn't resolve nodes by - # name at all, so using a hostname here would require an internal - # DNS which would complicate the setup and potentially introduce - # performance issues. - hostvars['openshift_hostname'] = server.metadata.get( - 'openshift_hostname', server.private_v4) - hostvars['openshift_public_hostname'] = server.name - - if server.metadata['host-type'] == 'cns': - hostvars['glusterfs_devices'] = ['/dev/nvme0n1'] - - node_labels = server.metadata.get('node_labels') - # NOTE(shadower): the node_labels value must be a dict not string - if not isinstance(node_labels, Mapping): - node_labels = json.loads(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)) -- cgit v1.2.3