@@ -53,19 +53,19 @@ resource "local_file" "admin_networks" {
5353 file_permission = " 0644"
5454}
5555
56- output "cluster_nodes" {
57- description = " A list of the cluster nodes and their IP addresses which will be used by the Ansible inventory"
58- value = [{
59- name = openstack_compute_instance_v2.ansible_control.name
60- ip = openstack_compute_instance_v2.ansible_control.access_ip_v4
61- groups = [" multinode_ansible_control" ]
62- }]
63- }
56+ # output "cluster_nodes" {
57+ # description = "A list of the cluster nodes and their IP addresses which will be used by the Ansible inventory"
58+ # value = [{
59+ # name = openstack_compute_instance_v2.ansible_control.name
60+ # ip = openstack_compute_instance_v2.ansible_control.access_ip_v4
61+ # groups = ["multinode_ansible_control"]
62+ # }]
63+ # }
6464
65- # flatten([
66- # for node in openstack_compute_instance_v2.compute: {
67- # name = node.name
68- # ip = node.access_ip_v4
65+ # flatten([
66+ # for node in openstack_compute_instance_v2.compute: {
67+ # name = node.name
68+ # ip = node.access_ip_v4
6969# groups = ["compute"]
7070# }
7171# ])
@@ -97,38 +97,93 @@ resource "local_file" "deploy_openstack" {
9797 file_permission = " 0755"
9898}
9999
100- resource "ansible_host" "control_host" {
101- name = openstack_compute_instance_v2. ansible_control . access_ip_v4
102- groups = [" ansible_control" ]
100+ output "cluster_nodes" {
101+ description = " A list of the cluster nodes and their IP addresses which will be used by the Ansible inventory"
102+ value = concat (
103+ [
104+ {
105+ name = openstack_compute_instance_v2.ansible_control.name
106+ ip = openstack_compute_instance_v2.ansible_control.access_ip_v4
107+ groups = [" ansible_control" ]
108+ variables = {
109+ ansible_user = var.ssh_user
110+ }
111+ }
112+ ],
113+ flatten ([
114+ for node in openstack_compute_instance_v2 . compute : {
115+ name = node . name
116+ ip = node . access_ip_v4
117+ groups = [" compute" ]
118+ variables = {
119+ ansible_user = var.ssh_user
120+ }
121+ }
122+ ]),
123+ flatten ([
124+ for node in openstack_compute_instance_v2 . controller : {
125+ name = node . name
126+ ip = node . access_ip_v4
127+ groups = [" controllers" ]
128+ variables = {
129+ ansible_user = var.ssh_user
130+ }
131+ }
132+ ]),
133+ [{
134+ name = openstack_compute_instance_v2.seed.name
135+ ip = openstack_compute_instance_v2.seed.access_ip_v4
136+ groups = [" seed" ]
137+ variables = {
138+ ansible_user = var.ssh_user
139+ }
140+ }],
141+ flatten ([
142+ for node in openstack_compute_instance_v2 . storage : {
143+ name = node . name
144+ ip = node . access_ip_v4
145+ groups = [" storage" ]
146+ variables = {
147+ ansible_user = var.ssh_user
148+ }
149+ }
150+ ])
151+ )
103152}
104153
105- resource "ansible_host" "compute_host" {
106- for_each = { for host in openstack_compute_instance_v2 . compute : host . name => host . access_ip_v4 }
107- name = each . value
108- groups = [" compute " ]
109- }
154+ # For Backup
155+ # resource "ansible_host" "control_host" {
156+ # name = openstack_compute_instance_v2.ansible_control.access_ip_v4
157+ # groups = ["ansible_control "]
158+ # }
110159
111- resource "ansible_host" "controllers_hosts " {
112- for_each = { for host in openstack_compute_instance_v2 . controller : host . name => host . access_ip_v4 }
113- name = each. value
114- groups = [" controllers " ]
115- }
160+ # resource "ansible_host" "compute_host " {
161+ # for_each = { for host in openstack_compute_instance_v2.compute : host.name => host.access_ip_v4 }
162+ # name = each.value
163+ # groups = ["compute "]
164+ # }
116165
117- resource "ansible_host" "seed_host" {
118- name = openstack_compute_instance_v2. seed . access_ip_v4
119- groups = [" seed" ]
120- }
166+ # resource "ansible_host" "controllers_hosts" {
167+ # for_each = { for host in openstack_compute_instance_v2.controller : host.name => host.access_ip_v4 }
168+ # name = each.value
169+ # groups = ["controllers"]
170+ # }
121171
122- resource "ansible_host" "storage" {
123- for_each = { for host in openstack_compute_instance_v2 . storage : host . name => host . access_ip_v4 }
124- name = each. value
125- groups = [" storage" ]
126- }
172+ # resource "ansible_host" "seed_host" {
173+ # name = openstack_compute_instance_v2.seed.access_ip_v4
174+ # groups = ["seed"]
175+ # }
127176
128- resource "ansible_group" "cluster_group" {
129- name = " cluster"
130- children = [" compute" , " ansible_control" , " controllers" , " seed" , " storage" ]
131- variables = {
132- ansible_user = var.ssh_user
133- }
134- }
177+ # resource "ansible_host" "storage" {
178+ # for_each = { for host in openstack_compute_instance_v2.storage : host.name => host.access_ip_v4 }
179+ # name = each.value
180+ # groups = ["storage"]
181+ # }
182+
183+ # resource "ansible_group" "cluster_group" {
184+ # name = "cluster"
185+ # children = ["compute", "ansible_control", "controllers", "seed", "storage"]
186+ # variables = {
187+ # ansible_user = var.ssh_user
188+ # }
189+ # }
0 commit comments