summaryrefslogtreecommitdiffstats
path: root/roles/static_inventory/tasks/openstack.yml
diff options
context:
space:
mode:
authorBogdan Dobrelya <bdobreli@redhat.com>2017-07-05 12:46:57 +0200
committerBogdan Dobrelya <bdobreli@redhat.com>2017-07-25 17:05:43 +0200
commit677fd46cf37cab5f995170b3567939d784ebb07a (patch)
tree9b9ae66c75607e513434c43337bb67a22100a378 /roles/static_inventory/tasks/openstack.yml
parentc0deeb4439f68a5cc514392a97927808532a3893 (diff)
downloadopenshift-677fd46cf37cab5f995170b3567939d784ebb07a.tar.gz
openshift-677fd46cf37cab5f995170b3567939d784ebb07a.tar.bz2
openshift-677fd46cf37cab5f995170b3567939d784ebb07a.tar.xz
openshift-677fd46cf37cab5f995170b3567939d784ebb07a.zip
Add bastion and ssh config for the static inventory role
* Autogenerate SSH config for static inventory and bastion. * When using bastion, use FQDN for inventory's ansible_host and SSH config's Hostname. Simplifies accessing nodes by names instead of private IPs. Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
Diffstat (limited to 'roles/static_inventory/tasks/openstack.yml')
-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 a25502835..95d0d172f 100644
--- a/roles/static_inventory/tasks/openstack.yml
+++ b/roles/static_inventory/tasks/openstack.yml
@@ -16,12 +16,14 @@
- name: set_fact for openstack inventory nodes
set_fact:
+ registered_bastion_nodes: "{{ (registered_nodes_output.stdout | from_json) | json_query(q) }}"
registered_nodes_floating: "{{ (registered_nodes_output.stdout | from_json) | json_query(q2) }}"
vars:
q: "[] | [?metadata.group=='infra.{{stack_name}}']"
q2: "[] | [?metadata.clusterid=='{{stack_name}}'] | [?public_v4!='']"
when:
- refresh_inventory|bool
+ - use_bastion|bool
- name: Add cluster nodes w/o floating IPs to inventory
with_items: "{{ registered_nodes }}"
@@ -29,9 +31,11 @@
add_host:
name: '{{ item.name }}'
groups: '{{ item.metadata.group }}'
- ansible_host: '{{ item.private_v4 }}'
+ ansible_host: "{% if use_bastion|bool %}{{ item.name }}{% else %}{{ item.private_v4 }}{% endif %}"
ansible_fqdn: '{{ item.name }}'
+ ansible_user: '{{ ssh_user }}'
ansible_private_key_file: '{{ private_ssh_key }}'
+ ansible_ssh_extra_args: '-F {{ ssh_config_path }}'
private_v4: '{{ item.private_v4 }}'
- name: Add cluster nodes with floating IPs to inventory
@@ -40,8 +44,25 @@
add_host:
name: '{{ item.name }}'
groups: '{{ item.metadata.group }}'
- ansible_host: '{{ item.public_v4 }}'
+ ansible_host: "{% if use_bastion|bool %}{{ item.name }}{% else %}{{ item.private_v4 }}{% endif %}"
ansible_fqdn: '{{ item.name }}'
+ ansible_user: '{{ ssh_user }}'
ansible_private_key_file: '{{ private_ssh_key }}'
+ ansible_ssh_extra_args: '-F {{ ssh_config_path }}'
private_v4: '{{ item.private_v4 }}'
public_v4: '{{ item.public_v4 }}'
+
+ - name: Add bastion node to inventory
+ add_host:
+ name: bastion
+ groups: bastions
+ ansible_host: '{{ registered_bastion_nodes[0].public_v4 }}'
+ ansible_fqdn: '{{ registered_bastion_nodes[0].name }}'
+ ansible_user: '{{ ssh_user }}'
+ ansible_private_key_file: '{{ private_ssh_key }}'
+ ansible_ssh_extra_args: '-F {{ ssh_config_path }}'
+ private_v4: '{{ registered_bastion_nodes[0].private_v4 }}'
+ public_v4: '{{ registered_bastion_nodes[0].public_v4 }}'
+ when:
+ - registered_bastion_nodes is defined
+ - use_bastion|bool