summaryrefslogtreecommitdiffstats
path: root/roles/static_inventory
diff options
context:
space:
mode:
authorTomas Sedovic <tomas@sedovic.cz>2017-09-06 10:24:16 +0200
committerGitHub <noreply@github.com>2017-09-06 10:24:16 +0200
commitdaa0b91119d2c16860a19b4ead2d0d128f8bc5ce (patch)
treec6b8f333cb16048e68983a0b885eb74830577cfc /roles/static_inventory
parent06abd17792fafc3adec3916f56c69800690b1431 (diff)
downloadopenshift-daa0b91119d2c16860a19b4ead2d0d128f8bc5ce.tar.gz
openshift-daa0b91119d2c16860a19b4ead2d0d128f8bc5ce.tar.bz2
openshift-daa0b91119d2c16860a19b4ead2d0d128f8bc5ce.tar.xz
openshift-daa0b91119d2c16860a19b4ead2d0d128f8bc5ce.zip
Allow using a provider network (#701)
* Allow using a provider network This adds a new option `openstack_provider_network_name` which will take a name of an existing network and put the servers there. It will also prevent creating floating IP addresses as the provider network's IPs should already be accessible without any additional routing required. Fixes #622 * Requested changes Don't fail on external/private networks and use role defaults for the provider network. * Add missing endif
Diffstat (limited to 'roles/static_inventory')
-rw-r--r--roles/static_inventory/tasks/openstack.yml25
1 files changed, 23 insertions, 2 deletions
diff --git a/roles/static_inventory/tasks/openstack.yml b/roles/static_inventory/tasks/openstack.yml
index 75d0ee6d5..e36974d93 100644
--- a/roles/static_inventory/tasks/openstack.yml
+++ b/roles/static_inventory/tasks/openstack.yml
@@ -24,6 +24,15 @@
when:
- refresh_inventory|bool
+ - name: set_fact for openstack inventory nodes with provider network
+ set_fact:
+ registered_nodes_floating: "{{ (registered_nodes_output.stdout | from_json) | json_query(q) }}"
+ vars:
+ q: "[] | [?metadata.clusterid=='{{stack_name}}'] | [?public_v4=='']"
+ when:
+ - refresh_inventory|bool
+ - openstack_provider_network_name|default(None)
+
- name: Add cluster nodes w/o floating IPs to inventory
with_items: "{{ registered_nodes|difference(registered_nodes_floating) }}"
add_host:
@@ -49,7 +58,14 @@
add_host:
name: '{{ item.name }}'
groups: '{{ item.metadata.group }}'
- ansible_host: "{% if use_bastion|bool %}{{ item.name }}{% else %}{{ item.public_v4 }}{% endif %}"
+ ansible_host: >-
+ {% if use_bastion|bool -%}
+ {{ item.name }}
+ {%- elif openstack_provider_network_name|default(None) -%}
+ {{ item.private_v4 }}
+ {%- else -%}
+ {{ item.public_v4 }}
+ {%- endif %}
ansible_fqdn: '{{ item.name }}'
ansible_user: '{{ ssh_user }}'
ansible_private_key_file: '{{ private_ssh_key }}'
@@ -57,7 +73,12 @@
private_v4: >-
{% set node = registered_nodes | json_query("[?name=='" + item.name + "']") -%}
{{ node[0].addresses[openstack_private_network|quote][0].addr }}
- public_v4: '{{ item.public_v4 }}'
+ public_v4: >-
+ {% if openstack_provider_network_name|default(None) -%}
+ {{ item.private_v4 }}
+ {%- else -%}
+ {{ item.public_v4 }}
+ {%- endif %}
- name: Add bastion node to inventory
add_host: