Infra: AWS bootstrap integration 31/31931/5
authorTomas Alexy <tomas.alexy@pantheon.tech>
Thu, 8 Apr 2021 13:50:24 +0000 (15:50 +0200)
committerPeter Mikus <pmikus@cisco.com>
Mon, 12 Apr 2021 05:49:55 +0000 (05:49 +0000)
Signed-off-by: Tomas Alexy <tomas.alexy@pantheon.tech>
Change-Id: I254c79201a198ee054851c934167a24e9e8803cb

fdio.infra.ansible/roles/topology/tasks/main.yaml
fdio.infra.ansible/roles/topology/templates/hosts.j2 [new file with mode: 0644]
resources/libraries/bash/function/ansible.sh
resources/libraries/bash/function/common.sh

index cf3eb53..a701074 100644 (file)
@@ -1,9 +1,23 @@
 ---
 # file: roles/topology/tasks/main.yaml
 
-- name: Create topology file
+- name: Create Topology File
   template:
     src: "templates/topology_{{ cloud_topology }}.j2"
-    dest: "../../../../topologies/available/{{ cloud_topology }}_{{ testbed_name }}.yaml"
+    dest: "../topologies/available/{{ cloud_topology }}_{{ testbed_name }}.yaml"
   tags:
     - create-topology-file
+
+- name: Create Inventory Folder
+  file:
+    path: "./inventories/cloud_inventory/"
+    state: directory
+  tags:
+    - create-inventory-folder-cloud
+
+- name: Create Hosts File
+  template:
+    src: "templates/hosts.j2"
+    dest: "./inventories/cloud_inventory/hosts"
+  tags:
+    - create-hosts-file-cloud
diff --git a/fdio.infra.ansible/roles/topology/templates/hosts.j2 b/fdio.infra.ansible/roles/topology/templates/hosts.j2
new file mode 100644 (file)
index 0000000..12a992d
--- /dev/null
@@ -0,0 +1,9 @@
+all:
+  children:
+    tg:
+      hosts:
+        {{ tg_public_ip }}
+    sut:
+      hosts:
+        {{ dut1_public_ip }}
+        {{ dut2_public_ip | default() }}
index 3beca3f..64508bd 100644 (file)
@@ -23,9 +23,19 @@ function ansible_adhoc () {
     # Variable read:
     # - ${WORKING_TOPOLOGY} - Reserved working topology.
     # - ${CSIT_DIR} - CSIT main directory, where ansible playbooks are located.
+    # - ${FLAVOR} - Node flavor string, see common.sh
 
     set -exuo pipefail
 
+    case "$FLAVOR" in
+        "aws")
+            INVENTORY_PATH="cloud_inventory"
+            ;;
+        *)
+            INVENTORY_PATH="lf_inventory"
+            ;;
+    esac
+
     if ! installed sshpass; then
         die "Please install sshpass!"
     fi
@@ -40,7 +50,7 @@ function ansible_adhoc () {
     ansible-playbook \
         --vault-password-file=vault_pass \
         --extra-vars '@vault.yml' \
-        --inventory inventories/lf_inventory/hosts site.yaml \
+        --inventory inventories/$INVENTORY_PATH/hosts site.yaml \
         --limit "$(echo ${hosts[@]//\"})" \
         --module-name shell \
         --args \"$(echo $@)\" || die "Failed to run ansible on host!"
@@ -55,9 +65,19 @@ function ansible_playbook () {
     # Variable read:
     # - ${WORKING_TOPOLOGY} - Reserved working topology.
     # - ${CSIT_DIR} - CSIT main directory, where ansible playbooks are located.
+    # - ${FLAVOR} - Node flavor string, see common.sh
 
     set -exuo pipefail
 
+    case "$FLAVOR" in
+        "aws")
+            INVENTORY_PATH="cloud_inventory"
+            ;;
+        *)
+            INVENTORY_PATH="lf_inventory"
+            ;;
+    esac
+
     if ! installed sshpass; then
         die "Please install sshpass!"
     fi
@@ -72,7 +92,7 @@ function ansible_playbook () {
     ansible-playbook \
         --vault-password-file=vault_pass \
         --extra-vars '@vault.yml' \
-        --inventory inventories/lf_inventory/hosts site.yaml \
+        --inventory inventories/$INVENTORY_PATH/hosts site.yaml \
         --limit "$(echo ${hosts[@]//\"})" \
         --tags "$(echo $@)" || die "Failed to run ansible on host!"
     popd || die "Popd failed!"
index a387801..f5f8606 100644 (file)
@@ -441,6 +441,14 @@ function get_test_code () {
             NODENESS="1n"
             FLAVOR="tx2"
             ;;
+        *"2n-aws"*)
+            NODENESS="2n"
+            FLAVOR="aws"
+            ;;
+        *"3n-aws"*)
+            NODENESS="3n"
+            FLAVOR="aws"
+            ;;
         *"2n-skx"*)
             NODENESS="2n"
             FLAVOR="skx"
@@ -641,7 +649,7 @@ function reserve_and_cleanup_testbed () {
                     }
                     die "Trap attempt failed, unreserve succeeded. Aborting."
                 }
-                # Cleanup + calibration checks.
+                # Cleanup + calibration checks
                 set +e
                 ansible_playbook "cleanup, calibration"
                 result="$?"
@@ -803,6 +811,9 @@ function select_tags () {
         *"3n-hsw"* | *"2n-tx2"* | *"mrr-daily-master")
             default_nic="nic_intel-xl710"
             ;;
+        *"2n-aws"* | *"3n-aws"*)
+            default_nic="nic_amazon-nitro-50g"
+            ;;
         *)
             default_nic="nic_intel-x710"
             ;;
@@ -930,6 +941,9 @@ function select_tags () {
             # which we do not want to even run.
             test_tag_array+=("!ipsechwNOTnic_intel-xl710")
             ;;
+        *"2n-aws"* | *"3n-aws"*)
+            test_tag_array+=("!ipsechw")
+            ;;
         *)
             # Default to 3n-hsw due to compatibility.
             test_tag_array+=("!drv_avf")
@@ -1043,6 +1057,14 @@ function select_topology () {
             TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*2n_tx2*.yaml )
             TOPOLOGIES_TAGS="2_node_single_link_topo"
             ;;
+        "2n_aws")
+            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*2n_aws*.yaml )
+            TOPOLOGIES_TAGS="2_node_*_link_topo"
+            ;;
+        "3n_aws")
+            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*3n_aws*.yaml )
+            TOPOLOGIES_TAGS="2_node_*_link_topo"
+            ;;
         *)
             # No falling back to 3n_hsw default, that should have been done
             # by the function which has set NODENESS and FLAVOR.