diff options
author | Øystein Bedin <bedin@redhat.com> | 2016-08-21 02:12:53 -0400 |
---|---|---|
committer | Øystein Bedin <bedin@redhat.com> | 2016-08-21 02:12:53 -0400 |
commit | c757fd690d24865ef3b5b9a1b536120299b39a6c (patch) | |
tree | e6e893eec0d0ea0c66eab3fe9192dad9ac270583 | |
parent | 3e3c7761068ed57b7cbee0329bd02d234b82e0e1 (diff) | |
download | openshift-c757fd690d24865ef3b5b9a1b536120299b39a6c.tar.gz openshift-c757fd690d24865ef3b5b9a1b536120299b39a6c.tar.bz2 openshift-c757fd690d24865ef3b5b9a1b536120299b39a6c.tar.xz openshift-c757fd690d24865ef3b5b9a1b536120299b39a6c.zip |
Updated env_id to be a sub-domain + make the logic a bit more flexible
-rw-r--r-- | roles/common/pre_tasks/pre_tasks.yml | 21 | ||||
-rw-r--r-- | roles/hostnames/tasks/main.yaml | 4 |
2 files changed, 21 insertions, 4 deletions
diff --git a/roles/common/pre_tasks/pre_tasks.yml b/roles/common/pre_tasks/pre_tasks.yml index ed57a2993..1ba1ea55d 100644 --- a/roles/common/pre_tasks/pre_tasks.yml +++ b/roles/common/pre_tasks/pre_tasks.yml @@ -1,4 +1,21 @@ --- - name: Generate Environment ID - shell: echo "$(date +%s)" - register: env_random_id + set_fact: + env_random_id: "{{ ansible_date_time.epoch }}" + run_once: true + delegate_to: localhost + +- name: Set default Environment ID + set_fact: + default_env_id: "casl-{{ lookup('env','OS_USERNAME') }}-{{ env_random_id }}" + delegate_to: localhost + +- name: Setting Common Facts + set_fact: + env_id: "{{ env_id | default(default_env_id) }}" + delegate_to: localhost + +- name: Updating DNS domain to include env_id (if not empty) + set_fact: + full_dns_domain: "{{ (env_id|trim == '') | ternary(dns_domain, env_id + '.' + dns_domain) }}" + delegate_to: localhost diff --git a/roles/hostnames/tasks/main.yaml b/roles/hostnames/tasks/main.yaml index bb45445f5..bf142d653 100644 --- a/roles/hostnames/tasks/main.yaml +++ b/roles/hostnames/tasks/main.yaml @@ -1,11 +1,11 @@ --- - name: Setting Hostname Fact set_fact: - new_hostname: "{{ custom_hostname | default(inventory_hostname) }}" + new_hostname: "{{ custom_hostname | default(inventory_hostname_short) }}" - name: Setting FQDN Fact set_fact: - new_fqdn: "{{ new_hostname }}.{{ dns_domain }}" + new_fqdn: "{{ new_hostname }}.{{ full_dns_domain }}" - name: Setting hostname and DNS domain hostname: name="{{ new_fqdn }}" |