summaryrefslogtreecommitdiffstats
path: root/roles/common/pre_tasks/pre_tasks.yml
blob: 71a989b307a42a0c5a606da00e5e8d8b579d9917 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
---
- name: Generate Environment 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: Set Dynamic Inventory Filters
  shell: >
    export OS_INV_FILTER_KEY=clusterid && OS_INV_FILTER_VALUE={{ 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