summaryrefslogtreecommitdiffstats
path: root/roles/openshift_openstack/tasks
diff options
context:
space:
mode:
authorTomas Sedovic <tomas@sedovic.cz>2017-11-01 16:43:13 +0100
committerTomas Sedovic <tomas@sedovic.cz>2017-11-07 14:35:47 +1100
commit79f29bc825286c4f69073827a5b6d71f71f47c91 (patch)
treedb91c04c153aef1419871a7843e8d415c49e0a60 /roles/openshift_openstack/tasks
parent23674d565f2801d88060bd0443ec384fbdcdad59 (diff)
downloadopenshift-79f29bc825286c4f69073827a5b6d71f71f47c91.tar.gz
openshift-79f29bc825286c4f69073827a5b6d71f71f47c91.tar.bz2
openshift-79f29bc825286c4f69073827a5b6d71f71f47c91.tar.xz
openshift-79f29bc825286c4f69073827a5b6d71f71f47c91.zip
Add the DNS updates and rename the openstack vars
Most of the vars in `roles/openshift_openstack/defaults/main.yml` are now prefixed with `openstack_`.
Diffstat (limited to 'roles/openshift_openstack/tasks')
-rw-r--r--roles/openshift_openstack/tasks/check-prerequisites.yml4
-rw-r--r--roles/openshift_openstack/tasks/generate-templates.yml3
-rw-r--r--roles/openshift_openstack/tasks/hostname.yml49
-rw-r--r--roles/openshift_openstack/tasks/populate-dns.yml187
-rw-r--r--roles/openshift_openstack/tasks/provision.yml5
5 files changed, 97 insertions, 151 deletions
diff --git a/roles/openshift_openstack/tasks/check-prerequisites.yml b/roles/openshift_openstack/tasks/check-prerequisites.yml
index 4d7cfbf11..13000e31f 100644
--- a/roles/openshift_openstack/tasks/check-prerequisites.yml
+++ b/roles/openshift_openstack/tasks/check-prerequisites.yml
@@ -76,13 +76,13 @@
- name: Try to show keypair
command: >
python -c 'import shade; cloud = shade.openstack_cloud();
- exit(cloud.get_keypair("{{ openstack_ssh_public_key }}") is None)'
+ exit(cloud.get_keypair("{{ openstack_keypair_name }}") is None)'
ignore_errors: yes
register: key_result
- name: Check that keypair is available
assert:
that: 'key_result.rc == 0'
- msg: "Keypair {{ openstack_ssh_public_key }} is not available"
+ msg: "Keypair {{ openstack_keypair_name }} is not available"
# Check that custom images are available
- include: custom_image_check.yaml
diff --git a/roles/openshift_openstack/tasks/generate-templates.yml b/roles/openshift_openstack/tasks/generate-templates.yml
index 0ff50a095..3a8b588e9 100644
--- a/roles/openshift_openstack/tasks/generate-templates.yml
+++ b/roles/openshift_openstack/tasks/generate-templates.yml
@@ -10,6 +10,9 @@
stack_template_path: "{{ stack_template_pre.path }}/stack.yaml"
user_data_template_path: "{{ stack_template_pre.path }}/user-data"
+- name: Print out the Heat template directory
+ debug: var=stack_template_pre
+
- name: generate HOT stack template from jinja2 template
template:
src: heat_stack.yaml.j2
diff --git a/roles/openshift_openstack/tasks/hostname.yml b/roles/openshift_openstack/tasks/hostname.yml
index 0fc8fbc4c..9815d0e80 100644
--- a/roles/openshift_openstack/tasks/hostname.yml
+++ b/roles/openshift_openstack/tasks/hostname.yml
@@ -1,33 +1,26 @@
---
-- name: "Verify hostname"
- command: hostnamectl status --static
- register: hostname_fqdn
+- name: Setting Hostname Fact
+ set_fact:
+ new_hostname: "{{ custom_hostname | default(inventory_hostname_short) }}"
-- name: "Set hostname if required"
- when: hostname_fqdn.stdout != ansible_fqdn
- block:
- - name: Setting Hostname Fact
- set_fact:
- new_hostname: "{{ custom_hostname | default(inventory_hostname_short) }}"
+- name: Setting FQDN Fact
+ set_fact:
+ new_fqdn: "{{ new_hostname }}.{{ full_dns_domain }}"
- - name: Setting FQDN Fact
- set_fact:
- new_fqdn: "{{ new_hostname }}.{{ full_dns_domain }}"
+- name: Setting hostname and DNS domain
+ hostname: name="{{ new_fqdn }}"
- - name: Setting hostname and DNS domain
- hostname: name="{{ new_fqdn }}"
+- name: Check for cloud.cfg
+ stat: path=/etc/cloud/cloud.cfg
+ register: cloud_cfg
- - name: Check for cloud.cfg
- stat: path=/etc/cloud/cloud.cfg
- register: cloud_cfg
-
- - name: Prevent cloud-init updates of hostname/fqdn (if applicable)
- lineinfile:
- dest: /etc/cloud/cloud.cfg
- state: present
- regexp: "{{ item.regexp }}"
- line: "{{ item.line }}"
- with_items:
- - { regexp: '^ - set_hostname', line: '# - set_hostname' }
- - { regexp: '^ - update_hostname', line: '# - update_hostname' }
- when: cloud_cfg.stat.exists == True
+- name: Prevent cloud-init updates of hostname/fqdn (if applicable)
+ lineinfile:
+ dest: /etc/cloud/cloud.cfg
+ state: present
+ regexp: "{{ item.regexp }}"
+ line: "{{ item.line }}"
+ with_items:
+ - { regexp: '^ - set_hostname', line: '# - set_hostname' }
+ - { regexp: '^ - update_hostname', line: '# - update_hostname' }
+ when: cloud_cfg.stat.exists == True
diff --git a/roles/openshift_openstack/tasks/populate-dns.yml b/roles/openshift_openstack/tasks/populate-dns.yml
index c8243dc1f..669b65a01 100644
--- a/roles/openshift_openstack/tasks/populate-dns.yml
+++ b/roles/openshift_openstack/tasks/populate-dns.yml
@@ -1,37 +1,26 @@
-# TODO: use nsupdate to populate the DNS servers using the keys
-# specified in the inventory.
-
-# this is an optional step -- the deployers may do whatever else they
-# wish here.
-
-
-# TODO: build records
-# TODO: run nsupdate
-
-
- name: "Generate list of private A records"
set_fact:
- private_records: "{{ [ { 'type': 'A', 'hostname': hostvars[item]['ansible_hostname'], 'ip': hostvars[item]['private_v4'] } ] }}"
+ private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': hostvars[item]['ansible_hostname'], 'ip': hostvars[item]['private_v4'] } ] }}"
with_items: "{{ groups['cluster_hosts'] }}"
-# - name: "Add wildcard records to the private A records for infrahosts"
-# set_fact:
-# private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': '*.' + openshift_app_domain, 'ip': hostvars[item]['private_v4'] } ] }}"
-# with_items: "{{ groups['infra_hosts'] }}"
-
-# - name: "Add public master cluster hostname records to the private A records (single master)"
-# set_fact:
-# private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.masters[0]].private_v4 } ] }}"
-# when:
-# - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
-# - openstack_num_masters == 1
-
-# - name: "Add public master cluster hostname records to the private A records (multi-master)"
-# set_fact:
-# private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.lb[0]].private_v4 } ] }}"
-# when:
-# - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
-# - openstack_num_masters > 1
+- name: "Add wildcard records to the private A records for infrahosts"
+ set_fact:
+ private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': '*.' + openshift_app_domain, 'ip': hostvars[item]['private_v4'] } ] }}"
+ with_items: "{{ groups['infra_hosts'] }}"
+
+- name: "Add public master cluster hostname records to the private A records (single master)"
+ set_fact:
+ private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.masters[0]].private_v4 } ] }}"
+ when:
+ - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
+ - openstack_num_masters == 1
+
+- name: "Add public master cluster hostname records to the private A records (multi-master)"
+ set_fact:
+ private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.lb[0]].private_v4 } ] }}"
+ when:
+ - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
+ - openstack_num_masters > 1
- name: "Set the private DNS server to use the external value (if provided)"
set_fact:
@@ -55,102 +44,67 @@
key_algorithm: "{{ nsupdate_key_algorithm_private | lower }}"
entries: "{{ private_records }}"
-# - name: "Generate list of public A records"
-# set_fact:
-# public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': hostvars[item]['ansible_hostname'], 'ip': hostvars[item]['public_v4'] } ] }}"
-# with_items: "{{ groups['cluster_hosts'] }}"
-# when: hostvars[item]['public_v4'] is defined
-
-# - name: "Add wildcard records to the public A records"
-# set_fact:
-# public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': '*.' + openshift_app_domain, 'ip': hostvars[item]['public_v4'] } ] }}"
-# with_items: "{{ groups['infra_hosts'] }}"
-# when: hostvars[item]['public_v4'] is defined
-
-# - name: "Add public master cluster hostname records to the public A records (single master)"
-# set_fact:
-# public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.masters[0]].public_v4 } ] }}"
-# when:
-# - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
-# - openstack_num_masters == 1
-# - not use_bastion|bool
-
-# - name: "Add public master cluster hostname records to the public A records (single master behind a bastion)"
-# set_fact:
-# public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.bastions[0]].public_v4 } ] }}"
-# when:
-# - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
-# - openstack_num_masters == 1
-# - use_bastion|bool
-
-# - name: "Add public master cluster hostname records to the public A records (multi-master)"
-# set_fact:
-# public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.lb[0]].public_v4 } ] }}"
-# when:
-# - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
-# - openstack_num_masters > 1
-
-# - name: "Set the public DNS server details to use the external value (if provided)"
-# set_fact:
-# nsupdate_server_public: "{{ external_nsupdate_keys['public']['server'] }}"
-# nsupdate_key_secret_public: "{{ external_nsupdate_keys['public']['key_secret'] }}"
-# nsupdate_key_algorithm_public: "{{ external_nsupdate_keys['public']['key_algorithm'] }}"
-# nsupdate_public_key_name: "{{ external_nsupdate_keys['public']['key_name']|default('public-' + full_dns_domain) }}"
-# when:
-# - external_nsupdate_keys is defined
-# - external_nsupdate_keys['public'] is defined
-
-# - name: "Set the public DNS server details to use the provisioned value"
-# set_fact:
-# nsupdate_server_public: "{{ hostvars[groups['dns'][0]].public_v4 }}"
-# nsupdate_key_secret_public: "{{ hostvars[groups['dns'][0]].nsupdate_keys['public-' + full_dns_domain].key_secret }}"
-# nsupdate_key_algorithm_public: "{{ hostvars[groups['dns'][0]].nsupdate_keys['public-' + full_dns_domain].key_algorithm }}"
-# when:
-# - nsupdate_server_public is undefined
-
-# - name: "Generate the public Add section for DNS"
-# set_fact:
-# public_named_records:
-# - view: "public"
-# zone: "{{ full_dns_domain }}"
-# server: "{{ nsupdate_server_public }}"
-# key_name: "{{ nsupdate_public_key_name|default('public-' + full_dns_domain) }}"
-# key_secret: "{{ nsupdate_key_secret_public }}"
-# key_algorithm: "{{ nsupdate_key_algorithm_public | lower }}"
-# entries: "{{ public_records }}"
-
+- name: "Generate list of public A records"
+ set_fact:
+ public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': hostvars[item]['ansible_hostname'], 'ip': hostvars[item]['public_v4'] } ] }}"
+ with_items: "{{ groups['cluster_hosts'] }}"
+ when: hostvars[item]['public_v4'] is defined
+- name: "Add wildcard records to the public A records"
+ set_fact:
+ public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': '*.' + openshift_app_domain, 'ip': hostvars[item]['public_v4'] } ] }}"
+ with_items: "{{ groups['infra_hosts'] }}"
+ when: hostvars[item]['public_v4'] is defined
+- name: "Add public master cluster hostname records to the public A records (single master)"
+ set_fact:
+ public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.masters[0]].public_v4 } ] }}"
+ when:
+ - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
+ - openstack_num_masters == 1
+ - not openstack_use_bastion|bool
+- name: "Add public master cluster hostname records to the public A records (single master behind a bastion)"
+ set_fact:
+ public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.bastions[0]].public_v4 } ] }}"
+ when:
+ - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
+ - openstack_num_masters == 1
+ - openstack_use_bastion|bool
+- name: "Add public master cluster hostname records to the public A records (multi-master)"
+ set_fact:
+ public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.lb[0]].public_v4 } ] }}"
+ when:
+ - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
+ - openstack_num_masters > 1
-- name: "Generate the final dns_records_add"
+- name: "Set the public DNS server details to use the external value (if provided)"
set_fact:
- # TODO(shadower): enable this when we add public records
- #dns_records_add: "{{ private_named_records + public_named_records }}"
- dns_records_add: "{{ private_named_records }}"
+ nsupdate_server_public: "{{ external_nsupdate_keys['public']['server'] }}"
+ nsupdate_key_secret_public: "{{ external_nsupdate_keys['public']['key_secret'] }}"
+ nsupdate_key_algorithm_public: "{{ external_nsupdate_keys['public']['key_algorithm'] }}"
+ nsupdate_public_key_name: "{{ external_nsupdate_keys['public']['key_name']|default('public-' + full_dns_domain) }}"
+ when:
+ - external_nsupdate_keys is defined
+ - external_nsupdate_keys['public'] is defined
+- name: "Generate the public Add section for DNS"
+ set_fact:
+ public_named_records:
+ - view: "public"
+ zone: "{{ full_dns_domain }}"
+ server: "{{ nsupdate_server_public }}"
+ key_name: "{{ nsupdate_public_key_name|default('public-' + full_dns_domain) }}"
+ key_secret: "{{ nsupdate_key_secret_public }}"
+ key_algorithm: "{{ nsupdate_key_algorithm_public | lower }}"
+ entries: "{{ public_records }}"
-# RUN NSUPDATE
+- name: "Generate the final dns_records_add"
+ set_fact:
+ dns_records_add: "{{ private_named_records + public_named_records }}"
-- name: "Remove any deleted DNS A records"
- nsupdate:
- key_name: "{{ item.0.key_name }}"
- key_secret: "{{ item.0.key_secret }}"
- key_algorithm: "{{ item.0.key_algorithm }}"
- server: "{{ item.0.server }}"
- zone: "{{ item.0.zone }}"
- record: "{{ item.1.hostname }}"
- type: "{{ item.1.type }}"
- state: absent
- with_subelements:
- - "{{ dns_records_rm | default({}) }}"
- - entries
- register: nsupdate_remove_result
- until: nsupdate_remove_result|succeeded
- retries: 10
- delay: 1
- name: "Add DNS A records"
nsupdate:
@@ -162,6 +116,7 @@
record: "{{ item.1.hostname }}"
value: "{{ item.1.ip }}"
type: "{{ item.1.type }}"
+ # TODO(shadower): add a cleanup playbook that removes these records, too!
state: present
with_subelements:
- "{{ dns_records_add | default({}) }}"
diff --git a/roles/openshift_openstack/tasks/provision.yml b/roles/openshift_openstack/tasks/provision.yml
index 8ebda8100..e693f535a 100644
--- a/roles/openshift_openstack/tasks/provision.yml
+++ b/roles/openshift_openstack/tasks/provision.yml
@@ -16,11 +16,6 @@
- name: Add the new nodes to the inventory
meta: refresh_inventory
-- name: Populate DNS entries
- include: populate-dns.yml
- when:
- - stack_state == 'present'
-
- name: CleanUp
include: cleanup.yml
when: