summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
Diffstat (limited to 'roles')
-rw-r--r--roles/common/pre_tasks/pre_tasks.yml21
-rw-r--r--roles/hostnames/tasks/main.yaml4
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 }}"