diff --git a/.gitignore b/.gitignore index a8ea09d..27dd786 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -.terraform +.terraform* *.tfstate.backup base/images/* -!base/images/.gitkeep \ No newline at end of file +!base/images/.gitkeep diff --git a/applications/stack_address.toml b/applications/stack_address.toml index 15d927b..5078dbf 100755 --- a/applications/stack_address.toml +++ b/applications/stack_address.toml @@ -1,7 +1,14 @@ -[all] -compute-0 ansible_host=100.64.0.113 index=0 -compute-1 ansible_host=100.64.0.251 index=1 -compute-2 ansible_host=100.64.0.114 index=2 -compute-3 ansible_host=100.64.0.124 index=3 +# two first domain is controller domain +[controller] +compute-0 ansible_host=100.64.0.146 index=0 +compute-1 ansible_host=100.64.0.214 index=1 +# next domain is worker domain +[worker] +compute-2 ansible_host=100.64.0.79 index=0 +compute-3 ansible_host=100.64.0.86 index=1 + +[all:children] +controller +worker [all:vars] -ansible_ssh_common_args='-o StrictHostKeyChecking=no' +ansible_ssh_extra_args='-o StrictHostKeyChecking=no' diff --git a/stack/cloud_init_user_data.yml b/stack/cloud_init_user_data.yml index 357ee24..c3e4316 100644 --- a/stack/cloud_init_user_data.yml +++ b/stack/cloud_init_user_data.yml @@ -22,6 +22,7 @@ users: - name: antoine ssh_authorized_keys: - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCuLVDINxqYow17v9oovyqG3Ok5mOa36U3f+D7CtY8cS7jZavx7A6h2DAtlNzzJl3AxRtk3JY1rmV2fhwB+lVA1S8WT61/qHZH+smjbt6YCp6/ICMKPR8tKtbFUnXn+o9tAhqa7cryWs2LerJasXaSUUguIb6Lr0teSM6enzmtNShjiUta+6HlN+M91n/tp4pjn+tvNUSFETg1JVX1DIG/6U43N8V+fu6xsN5ceoPNGpBpikP0ZYmKYdcPMqqcWJkkaLGwh/u4R98BUVSPor/OFaMw3IZ6Nr7yCdWPCe/8SvEkbd2iMQm5dQjqEFEJUyPwoE18lfM2VnVwlaKsFN9Cmu2J5H4w9qlkZCSG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P-de-Antoine sudo: ["ALL=(ALL) NOPASSWD:ALL"] shell: /bin/bash groups: wheel diff --git a/stack/computes.tf b/stack/computes.tf index ac04fa4..e3ada81 100644 --- a/stack/computes.tf +++ b/stack/computes.tf @@ -22,11 +22,11 @@ resource "libvirt_domain" "domains" { } disk { - volume_id = element(libvirt_volume.root_debian.*.id, count.index) + volume_id = libvirt_volume.root_debian[count.index].id } disk { - volume_id = element(libvirt_volume.external_disk.*.id, count.index) + volume_id = libvirt_volume.external_disk[count.index].id } cloudinit = libvirt_cloudinit_disk.commoninit[count.index].id diff --git a/stack/libvirtd.tf b/stack/libvirtd.tf index cb80128..2e95ad1 100644 --- a/stack/libvirtd.tf +++ b/stack/libvirtd.tf @@ -52,12 +52,26 @@ output "ip" { resource "local_file" "write_address" { content = <<-EOT -[all] -%{ for idx, s in libvirt_domain.domains.*.network_interface.0 ~} -${s.hostname} ansible_host=${s.addresses.0} index=${idx} +# two first domain is controller domain +[controller] +%{ for idx, s in slice(libvirt_domain.domains, 0, 2) ~} +%{ if length(s.network_interface.0.addresses) > 0 ~} +${s.network_interface.0.hostname} ansible_host=${s.network_interface.0.addresses.0} index=${idx} +%{ endif ~} %{ endfor ~} +# next domain is worker domain +[worker] +%{ for idx, s in slice(libvirt_domain.domains, 2, length(libvirt_domain.domains)) ~} +%{ if length(s.network_interface.0.addresses) > 0 ~} +${s.network_interface.0.hostname} ansible_host=${s.network_interface.0.addresses.0} index=${idx} +%{ endif ~} +%{ endfor ~} + +[all:children] +controller +worker [all:vars] -ansible_ssh_common_args='-o StrictHostKeyChecking=no' +ansible_ssh_extra_args='-o StrictHostKeyChecking=no' EOT filename = "../applications/stack_address.toml"