Clear salt-keys in baremetal cicd deployments

When a BM lab is re-deployed, cfg01 is bootstrapped first.
But all BM and VCP nodes from previous deployment are still active,
and register their salt-minions once the new salt-master is up.

To prevent deployment errors, before re-deploying MAAS nodes:

- clear all the salt keys and re-register the cfg01 node

Minor fix to VCP nodes:
- add ens2 'role: single_dhcp' to get the node accessible
  from salt-master after reboot

Change-Id: I4f511c32ad40a3c27235abc7cb8330bcc7cb6a50
diff --git a/tcp_tests/templates/cookied-cicd-bm-os-contrail40-maas/salt-context-environment.yaml b/tcp_tests/templates/cookied-cicd-bm-os-contrail40-maas/salt-context-environment.yaml
index 3c38fc6..5db9637 100644
--- a/tcp_tests/templates/cookied-cicd-bm-os-contrail40-maas/salt-context-environment.yaml
+++ b/tcp_tests/templates/cookied-cicd-bm-os-contrail40-maas/salt-context-environment.yaml
@@ -6,6 +6,8 @@
       - cicd_control_leader

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -15,6 +17,8 @@
       - cicd_control_manager

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -24,19 +28,23 @@
       - cicd_control_manager

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl
 

-    ctl01.cookied-bm-mcp-ocata-contrail.local:
-      reclass_storage_name: openstack_control_node01
-      roles:
-      - openstack_control_leader
-      - linux_system_codename_xenial
+    ctl01.cookied-bm-mcp-ocata-contrail.local:

+      reclass_storage_name: openstack_control_node01

+      roles:

+      - openstack_control_leader

+      - linux_system_codename_xenial

       classes:
       - system.linux.system.repo.mcp.apt_mirantis.docker
-      interfaces:
-        ens3:
-          role: single_ctl
+      interfaces:

+        ens2:
+          role: single_dhcp
+        ens3:

+          role: single_ctl

 

     ctl02.cookied-bm-mcp-ocata-contrail.local:

       reclass_storage_name: openstack_control_node02

@@ -44,6 +52,8 @@
       - openstack_control

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -53,6 +63,8 @@
       - openstack_control

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -62,6 +74,8 @@
       - openstack_database_leader

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -71,6 +85,8 @@
       - openstack_database

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -80,6 +96,8 @@
       - openstack_database

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -88,7 +106,9 @@
       roles:

       - openstack_message_queue

       - linux_system_codename_xenial

-      interfaces:

+      interfaces:
+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -98,6 +118,8 @@
       - openstack_message_queue

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -107,6 +129,8 @@
       - openstack_message_queue

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -116,6 +140,8 @@
       - openstack_proxy

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -125,6 +151,8 @@
       - openstack_proxy

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -134,6 +162,8 @@
       - stacklightv2_server_leader

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -143,6 +173,8 @@
       - stacklightv2_server

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -152,6 +184,8 @@
       - stacklightv2_server

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -161,6 +195,8 @@
       - opencontrail_analytics

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -170,6 +206,8 @@
       - opencontrail_analytics

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -179,6 +217,8 @@
       - opencontrail_analytics

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -188,6 +228,8 @@
       - opencontrail_control

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -197,6 +239,8 @@
       - opencontrail_control

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -206,6 +250,8 @@
       - opencontrail_control

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -215,6 +261,8 @@
       - stacklight_telemetry

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -224,6 +272,8 @@
       - stacklight_telemetry

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -233,6 +283,8 @@
       - stacklight_telemetry

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -242,6 +294,8 @@
       - stacklight_log_leader_v2

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -251,6 +305,8 @@
       - stacklight_log

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 

@@ -260,6 +316,8 @@
       - stacklight_log

       - linux_system_codename_xenial

       interfaces:

+        ens2:
+          role: single_dhcp
         ens3:

           role: single_ctl

 
@@ -269,6 +327,8 @@
       - ceph_mon
       - linux_system_codename_xenial
       interfaces:
+        ens2:
+          role: single_dhcp
         ens3:
           role: single_ctl
 
@@ -278,6 +338,8 @@
       - ceph_mon
       - linux_system_codename_xenial
       interfaces:
+        ens2:
+          role: single_dhcp
         ens3:
           role: single_ctl
 
@@ -287,6 +349,8 @@
       - ceph_mon
       - linux_system_codename_xenial
       interfaces:
+        ens2:
+          role: single_dhcp
         ens3:
           role: single_ctl
 
@@ -296,6 +360,8 @@
       - ceph_rgw
       - linux_system_codename_xenial
       interfaces:
+        ens2:
+          role: single_dhcp
         ens3:
           role: single_ctl
 
@@ -305,6 +371,8 @@
       - ceph_rgw
       - linux_system_codename_xenial
       interfaces:
+        ens2:
+          role: single_dhcp
         ens3:
           role: single_ctl
 
@@ -314,6 +382,8 @@
       - ceph_rgw
       - linux_system_codename_xenial
       interfaces:
+        ens2:
+          role: single_dhcp
         ens3:
           role: single_ctl
 
diff --git a/tcp_tests/templates/cookied-cicd-bm-os-contrail40-maas/salt.yaml b/tcp_tests/templates/cookied-cicd-bm-os-contrail40-maas/salt.yaml
index 4ea0035..a7b3677 100644
--- a/tcp_tests/templates/cookied-cicd-bm-os-contrail40-maas/salt.yaml
+++ b/tcp_tests/templates/cookied-cicd-bm-os-contrail40-maas/salt.yaml
@@ -48,6 +48,17 @@
   retry: {count: 1, delay: 5}
   skip_fail: false
 
+- description: Remove all the salt-minions and re-register the cfg01 minion
+  cmd: |
+    salt-key -y -D;
+    salt-call test.ping
+    sleep 5
+    # Check that the cfg01 is registered
+    salt-key | grep cfg01
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 5}
+  skip_fail: false
+
 - description: provision the automatically commissioned physical nodes through MAAS
   cmd: |
     salt-call maas.deploy_machines;