Procházet zdrojové kódy

Add inventory generation

Michael Gugino před 6 roky
rodič
revize
8d81d41abc

+ 2 - 0
.gitignore

@@ -27,3 +27,5 @@ cover/
 test/libvirt/install-config.yml
 test/libvirt/terraform/terraform.tfvars
 test/libvirt/terraform/.terraform
+*.tfstate
+test/libvirt/inventory.txt

+ 2 - 1
test/libvirt/deploy.sh

@@ -1,4 +1,5 @@
 #!/bin/bash
-
+#. installrc
 ./generate_assets.sh
 ./terraform_provision.sh
+./run_ansible.sh

+ 2 - 1
test/libvirt/generate_assets.sh

@@ -1,5 +1,6 @@
 #!/bin/bash
 # run this file directly via ./generate_assets.sh; sh generate_assets.sh won't work.
-. installrc
+
+./generate_inventory.sh
 cat install-config.yml.template | envsubst > install-config.yml
 cat terraform/terraform.tfvars.template | envsubst > terraform/terraform.tfvars

+ 22 - 0
test/libvirt/generate_inventory.sh

@@ -0,0 +1,22 @@
+#!/bin/bash
+
+MASTERS_LIST="${OCP_CLUSTER_NAME}-master-0.${OCP_BASE_DOMAIN}"
+WORKERS_LIST=""
+NEW_LINE_SUB="__new_line__"
+
+
+# Generate masters for inventory
+for (( c=1; c<$OCP_MASTERS; c++ ))
+do
+    MASTERS_LIST="${MASTERS_LIST}${NEW_LINE_SUB}${OCP_CLUSTER_NAME}-master-${c}.${OCP_BASE_DOMAIN}"
+done
+
+# Generate masters for inventory
+for (( c=0; c<$OCP_WORKERS; c++ ))
+do
+    WORKERS_LIST="${WORKERS_LIST}${NEW_LINE_SUB}${OCP_CLUSTER_NAME}-worker-${c}.${OCP_BASE_DOMAIN}"
+done
+export WORKERS_LIST=$WORKERS_LIST
+export MASTERS_LIST=$MASTERS_LIST
+cat inv.txt.template | envsubst > inventory.txt
+sed -i "s/${NEW_LINE_SUB}/\n/g" inventory.txt

+ 1 - 0
test/libvirt/installrc

@@ -15,3 +15,4 @@ export OCP_NETCIDR="192.168.126.0/24"
 export OCP_MASTER_IPS=\"192.168.126.11\"
 export OCP_BOOTSTRAP_IP="192.168.126.10"
 export OCP_LIBVIRT_URI='qemu+tcp://192.168.124.1/system'
+export OCP_INSTALL_CONFIG_PATH="$PWD/install-config.yml"

+ 16 - 0
test/libvirt/inv.txt.template

@@ -0,0 +1,16 @@
+[nodes:children]
+bootstrap
+masters
+workers
+
+[nodes:vars]
+openshift_install_config_path="${OCP_INSTALL_CONFIG_PATH}"
+
+[bootstrap]
+${OCP_CLUSTER_NAME}-bootstrap.${OCP_BASE_DOMAIN}
+
+[masters]
+${MASTERS_LIST}
+
+[workers]
+${WORKERS_LIST}