summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
Diffstat (limited to 'roles')
-rw-r--r--roles/common/pre_tasks/pre_tasks.yml2
-rw-r--r--roles/hostnames/tasks/main.yaml17
-rw-r--r--roles/hostnames/templates/records.template.yaml28
-rw-r--r--roles/hostnames/test/inv12
l---------roles/hostnames/test/roles1
-rw-r--r--roles/hostnames/test/test.retry3
-rw-r--r--roles/hostnames/test/test.yaml21
-rw-r--r--roles/hostnames/vars/main.yaml2
-rw-r--r--roles/hostnames/vars/records.yaml28
9 files changed, 113 insertions, 1 deletions
diff --git a/roles/common/pre_tasks/pre_tasks.yml b/roles/common/pre_tasks/pre_tasks.yml
index c573bff8c..9dd14c30c 100644
--- a/roles/common/pre_tasks/pre_tasks.yml
+++ b/roles/common/pre_tasks/pre_tasks.yml
@@ -1,4 +1,4 @@
---
- name: Generate Environment ID
shell: echo "$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 8)"
- register: env_random_id \ No newline at end of file
+ register: env_random_id
diff --git a/roles/hostnames/tasks/main.yaml b/roles/hostnames/tasks/main.yaml
new file mode 100644
index 000000000..921cd664b
--- /dev/null
+++ b/roles/hostnames/tasks/main.yaml
@@ -0,0 +1,17 @@
+---
+ - name: Setting master(s) hostname
+ hostname: name="{% for thishost in groups['openshift_masters'] %}{% if inventory_hostname == thishost %}master{{ counter }}.{{ dns_domain }}{% endif %}{% set counter = counter + 1 %}{% endfor %}"
+ when: "'openshift_masters' in group_names"
+
+ - name: Setting node(s) hostname
+ hostname: name="{% for thishost in groups['openshift_nodes'] %}{% if inventory_hostname == thishost %}node{{ counter }}.{{ dns_domain }}{% endif %}{% set counter = counter + 1 %}{% endfor %}"
+ when: "'openshift_nodes' in group_names"
+
+ - name: "Templating records"
+ become: false
+ remote_user: cloud-user
+ template:
+ src: "{{ role_path }}/templates/records.template.yaml"
+ dest: "/tmp/records.yaml"
+ force: yes
+ delegate_to: localhost
diff --git a/roles/hostnames/templates/records.template.yaml b/roles/hostnames/templates/records.template.yaml
new file mode 100644
index 000000000..a916fd2b3
--- /dev/null
+++ b/roles/hostnames/templates/records.template.yaml
@@ -0,0 +1,28 @@
+---
+dns_records_add:
+ - view: private
+ zone: {{ dns_domain }}
+ entries:
+{% for mst in groups['openshift_masters'] %}
+ - type: A
+ hostname: {{ hostvars[mst]['ansible_hostname'] }}
+ ip: {{ hostvars[mst]['dns_private_ip'] }}
+{% endfor %}
+{% for node in groups['openshift_nodes'] %}
+ - type: A
+ hostname: {{ hostvars[node]['ansible_hostname'] }}
+ ip: {{ hostvars[node]['dns_private_ip'] }}
+{% endfor %}
+ - view: public
+ zone: {{ dns_domain}}
+ entries:
+{% for mst in groups['openshift_masters']%}
+ - type: A
+ hostname: {{ hostvars[mst]['ansible_hostname'] }}
+ ip: {{ hostvars[mst]['dns_public_ip'] }}
+{% endfor %}
+{% for node in groups['openshift_nodes'] %}
+ - type: A
+ hostname: {{ hostvars[node]['ansible_hostname'] }}
+ ip: {{ hostvars[node]['dns_public_ip'] }}
+{% endfor %}
diff --git a/roles/hostnames/test/inv b/roles/hostnames/test/inv
new file mode 100644
index 000000000..ffbe6e03d
--- /dev/null
+++ b/roles/hostnames/test/inv
@@ -0,0 +1,12 @@
+[all:vars]
+dns_domain=example.com
+
+[openshift_masters]
+192.168.124.41 dns_private_ip=1.1.1.41 dns_public_ip=192.168.124.41
+192.168.124.117 dns_private_ip=1.1.1.117 dns_public_ip=192.168.124.117
+
+[openshift_nodes]
+192.168.124.40 dns_private_ip=1.1.1.40 dns_public_ip=192.168.124.40
+
+#[dns]
+#192.168.124.117 dns_private_ip=1.1.1.117
diff --git a/roles/hostnames/test/roles b/roles/hostnames/test/roles
new file mode 120000
index 000000000..e2b799b9d
--- /dev/null
+++ b/roles/hostnames/test/roles
@@ -0,0 +1 @@
+../../../roles/ \ No newline at end of file
diff --git a/roles/hostnames/test/test.retry b/roles/hostnames/test/test.retry
new file mode 100644
index 000000000..63fc08e4c
--- /dev/null
+++ b/roles/hostnames/test/test.retry
@@ -0,0 +1,3 @@
+192.168.124.117
+192.168.124.40
+192.168.124.41
diff --git a/roles/hostnames/test/test.yaml b/roles/hostnames/test/test.yaml
new file mode 100644
index 000000000..34bf37942
--- /dev/null
+++ b/roles/hostnames/test/test.yaml
@@ -0,0 +1,21 @@
+---
+- hosts: all
+ roles:
+ - role: hostnames
+
+# - debug:
+#
+# - hosts: dns
+# roles:
+# - role: dns-server
+# named_config_views:
+# - name: private
+# acl_entry:
+# - 192.168.124.40/32
+# - 192.168.124.40/32
+# zone:
+# - dns_domain: example.com
+# - name: public
+# zone:
+# - dns_domain: example.com
+# - role: dns
diff --git a/roles/hostnames/vars/main.yaml b/roles/hostnames/vars/main.yaml
new file mode 100644
index 000000000..3eecb8dc4
--- /dev/null
+++ b/roles/hostnames/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+counter: 1
diff --git a/roles/hostnames/vars/records.yaml b/roles/hostnames/vars/records.yaml
new file mode 100644
index 000000000..3bf12ae2b
--- /dev/null
+++ b/roles/hostnames/vars/records.yaml
@@ -0,0 +1,28 @@
+---
+ - name: "Building Records"
+ set_fact:
+ dns_records_add:
+ - view: private
+ zone: example.com
+ entries:
+ - type: A
+ hostname: master1.example.com
+ ip: 172.16.15.94
+ - type: A
+ hostname: node1.example.com
+ ip: 172.16.15.86
+ - type: A
+ hostname: node2.example.com
+ ip: 172.16.15.87
+ - view: public
+ zone: example.com
+ entries:
+ - type: A
+ hostname: master1.example.com
+ ip: 10.3.10.116
+ - type: A
+ hostname: node1.example.com
+ ip: 10.3.11.46
+ - type: A
+ hostname: node2.example.com
+ ip: 10.3.12.6