Add fs 'sync' after user-data script if failed

Change-Id: I964b4fb1328214133d9e4c60f0630dea781214d7
diff --git a/tcp_tests/templates/cookied-cicd-k8s-calico-sl/underlay--user-data-cfg01.yaml b/tcp_tests/templates/cookied-cicd-k8s-calico-sl/underlay--user-data-cfg01.yaml
index 4b134b7..4c43578 100644
--- a/tcp_tests/templates/cookied-cicd-k8s-calico-sl/underlay--user-data-cfg01.yaml
+++ b/tcp_tests/templates/cookied-cicd-k8s-calico-sl/underlay--user-data-cfg01.yaml
@@ -64,12 +64,11 @@
    - |
      set -x
      cd /root/config-drive
-     if /bin/bash -xe ./user-data > /var/log/cloud-init-user-data.log; then
+     if /bin/bash -xe ./user-data; then
          touch /is_cloud_init_finished
      else
          set +x
-         echo "bootstrap script /root/config-drive/user-data failed. tail -n 10 /var/log/cloud-init-user-data.log:\n" > /is_cloud_init_failed
-         tail -n 10 /var/log/cloud-init-user-data.log >> /is_cloud_init_failed
+         echo "bootstrap script /root/config-drive/user-data failed\n" > /is_cloud_init_failed
      fi
 
    # Enable root access (after reboot)
diff --git a/tcp_tests/templates/cookied-cicd-k8s-calico/underlay--user-data-cfg01.yaml b/tcp_tests/templates/cookied-cicd-k8s-calico/underlay--user-data-cfg01.yaml
index 4b134b7..4c43578 100644
--- a/tcp_tests/templates/cookied-cicd-k8s-calico/underlay--user-data-cfg01.yaml
+++ b/tcp_tests/templates/cookied-cicd-k8s-calico/underlay--user-data-cfg01.yaml
@@ -64,12 +64,11 @@
    - |
      set -x
      cd /root/config-drive
-     if /bin/bash -xe ./user-data > /var/log/cloud-init-user-data.log; then
+     if /bin/bash -xe ./user-data; then
          touch /is_cloud_init_finished
      else
          set +x
-         echo "bootstrap script /root/config-drive/user-data failed. tail -n 10 /var/log/cloud-init-user-data.log:\n" > /is_cloud_init_failed
-         tail -n 10 /var/log/cloud-init-user-data.log >> /is_cloud_init_failed
+         echo "bootstrap script /root/config-drive/user-data failed\n" > /is_cloud_init_failed
      fi
 
    # Enable root access (after reboot)
diff --git a/tcp_tests/templates/cookied-model-generator/salt_cookied-cicd-k8s-calico-sl.yaml b/tcp_tests/templates/cookied-model-generator/salt_cookied-cicd-k8s-calico-sl.yaml
index 4642e7c..f66287c 100644
--- a/tcp_tests/templates/cookied-model-generator/salt_cookied-cicd-k8s-calico-sl.yaml
+++ b/tcp_tests/templates/cookied-model-generator/salt_cookied-cicd-k8s-calico-sl.yaml
@@ -11,18 +11,13 @@
 {% import 'shared-salt.yaml' as SHARED with context %}
 
 {{ SHARED.MACRO_INSTALL_PACKAGES_ON_NODES(HOSTNAME_CFG01) }}
-- description: Re-install all the fromulas
-  cmd: |
-    set -e;
-    apt-get install -y salt-formula-*
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 1}
-  skip_fail: false
 
 {{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL() }}
 
 {{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }}
 
+{{ SHARED.MACRO_INSTALL_FORMULAS('\*') }}
+
 - description: "Workaround for combined roles: remove unnecessary classes"
   cmd: |
     set -e;
diff --git a/tcp_tests/templates/cookied-model-generator/salt_cookied-cicd-k8s-calico.yaml b/tcp_tests/templates/cookied-model-generator/salt_cookied-cicd-k8s-calico.yaml
index ceace31..eee1edd 100644
--- a/tcp_tests/templates/cookied-model-generator/salt_cookied-cicd-k8s-calico.yaml
+++ b/tcp_tests/templates/cookied-model-generator/salt_cookied-cicd-k8s-calico.yaml
@@ -11,18 +11,13 @@
 {% import 'shared-salt.yaml' as SHARED with context %}
 
 {{ SHARED.MACRO_INSTALL_PACKAGES_ON_NODES(HOSTNAME_CFG01) }}
-- description: Re-install all the fromulas
-  cmd: |
-    set -e;
-    apt-get install -y salt-formula-*
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 1}
-  skip_fail: false
 
 {{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL() }}
 
 {{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }}
 
+{{ SHARED.MACRO_INSTALL_FORMULAS('\*') }}
+
 - description: "Workaround for combined roles: remove unnecessary classes"
   cmd: |
     set -e;
diff --git a/tcp_tests/templates/cookied-model-generator/underlay.yaml b/tcp_tests/templates/cookied-model-generator/underlay.yaml
index 4783bd8..ef444e7 100644
--- a/tcp_tests/templates/cookied-model-generator/underlay.yaml
+++ b/tcp_tests/templates/cookied-model-generator/underlay.yaml
@@ -68,6 +68,11 @@
             forward:
               mode: route
 
+        group_volumes:
+         - name: cfg01_day01_image               # Pre-configured day01 image
+           source_image: {{ os_env('IMAGE_PATH_CFG01_DAY01') }} # http://images.mirantis.com/cfg01-day01.qcow2
+           format: qcow2
+
         nodes:
           - name: {{ HOSTNAME_CFG01 }}
             role: salt_master
@@ -81,7 +86,7 @@
               volumes:
                 - name: system
                   capacity: {{ os_env('CFG_NODE_VOLUME_SIZE', 150) }}
-                  shared_backing_store_name: {{ os_env('CFG01_DAY01_VOLUME_NAME') }}
+                  backing_store: cfg01_day01_image
                   format: qcow2
                 - name: iso  # Volume with name 'iso' will be used
                              # for store image with cloud-init metadata.
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index 3e26277..260636f 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -539,7 +539,7 @@
     declare -a formula_services=({{ FORMULA_SERVICES }});
     echo -e "\nInstalling all required salt formulas\n";
     apt-get install -y "${formula_services[@]/#/salt-formula-}";
-    for formula_service in "${formula_services[@]}"; do
+    for formula_service in $(ls -1 ${FORMULA_PATH}/reclass/service); do
       echo -e "\nLink service metadata for formula ${formula_service} ...\n";
       [ ! -L "/srv/salt/reclass/classes/service/${formula_service}" ] && ln -s ${FORMULA_PATH}/reclass/service/${formula_service} /srv/salt/reclass/classes/service/${formula_service};
     done;
@@ -651,7 +651,7 @@
 
 {%- macro MACRO_INSTALL_FORMULAS(FORMULA_SERVICES='') %}
 {#######################################################}
-- description: Configure reclass
+- description: Install salt formulas
   cmd: |
     set -e;
     FORMULA_PATH=${FORMULA_PATH:-/usr/share/salt-formulas};
@@ -664,25 +664,13 @@
     declare -a formula_services=({{ FORMULA_SERVICES }});
     echo -e "\nInstalling all required salt formulas\n";
     eatmydata apt-get install -y "${formula_services[@]/#/salt-formula-}";
-    for formula_service in "${formula_services[@]}"; do
+    for formula_service in $(ls -1 ${FORMULA_PATH}/reclass/service); do
       echo -e "\nLink service metadata for formula ${formula_service} ...\n";
       [ ! -L "/srv/salt/reclass/classes/service/${formula_service}" ] && ln -s ${FORMULA_PATH}/reclass/service/${formula_service} /srv/salt/reclass/classes/service/${formula_service};
     done;
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 1}
   skip_fail: false
-
-- description: Show reclass-salt --top for cfg01 node
-  cmd: reclass-salt --top
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 5}
-  skip_fail: false
-
-- description: Restart salt-master service
-  cmd: systemctl restart salt-master;
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 5}
-  skip_fail: false
 {%- endmacro %}
 
 {%- macro MACRO_CONFIG_DAY01_SALT_MINION() %}