Make rke to use new group structure

Rke playbook/role is modified to take advantage of the new group structure.
Namely, all members of kubernetes group are treated as cluster members
independent of their role.
The role itself is selected in cluster.yml.j2 template
based on actual membership in either kubernetes-node
or kubernetes-control-plane group.

Change-Id: I9a5bbfd090aff17018a610a01d6f88d848fc26c4
Issue-ID: OOM-1778
Signed-off-by: Michal Zegan <m.zegan@samsung.com>
diff --git a/ansible/rke.yml b/ansible/rke.yml
index e0d6dcf..13e7bb5 100644
--- a/ansible/rke.yml
+++ b/ansible/rke.yml
@@ -9,10 +9,8 @@
       vars:
         mode: config
 
-- name: Prepare kubernetes nodes (RKE)
-  hosts:
-  - kubernetes
-  - kubernetes-control-plane
+- name: Prepare kubernetes hosts (RKE)
+  hosts: kubernetes
   roles:
     - role: rke
       vars:
diff --git a/ansible/roles/rke/molecule/default/molecule.yml b/ansible/roles/rke/molecule/default/molecule.yml
index e8e5ad7..444a751 100644
--- a/ansible/roles/rke/molecule/default/molecule.yml
+++ b/ansible/roles/rke/molecule/default/molecule.yml
@@ -20,6 +20,7 @@
     groups:
       - infrastructure
       - kubernetes-control-plane
+      - kubernetes
     networks:
       - name: rke
     purge_networks: true
@@ -37,6 +38,7 @@
       - /var/lib/docker
     groups:
       - kubernetes
+      - kubernetes-node
     networks:
       - name: rke
     purge_networks: true
@@ -54,6 +56,7 @@
       - /var/lib/docker
     groups:
       - kubernetes
+      - kubernetes-node
     networks:
       - name: rke
     purge_networks: true
diff --git a/ansible/roles/rke/molecule/default/playbook.yml b/ansible/roles/rke/molecule/default/playbook.yml
index 09dbfb8..fab7a0d 100644
--- a/ansible/roles/rke/molecule/default/playbook.yml
+++ b/ansible/roles/rke/molecule/default/playbook.yml
@@ -13,10 +13,8 @@
       vars:
         mode: config
 
-- name: Prepare kubernetes nodes (RKE)
-  hosts:
-    - kubernetes
-    - kubernetes-control-plane
+- name: Prepare kubernetes hosts (RKE)
+  hosts: kubernetes
   roles:
     - role: rke
       vars:
diff --git a/ansible/roles/rke/molecule/default/tests/test_kubernetes.py b/ansible/roles/rke/molecule/default/tests/test_nodes.py
similarity index 97%
rename from ansible/roles/rke/molecule/default/tests/test_kubernetes.py
rename to ansible/roles/rke/molecule/default/tests/test_nodes.py
index 887494f..fcc5e7e 100644
--- a/ansible/roles/rke/molecule/default/tests/test_kubernetes.py
+++ b/ansible/roles/rke/molecule/default/tests/test_nodes.py
@@ -4,7 +4,7 @@
 import testinfra.utils.ansible_runner
 
 testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
-    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('kubernetes')
+    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('kubernetes-node')
 
 
 @pytest.mark.parametrize('container_name', [
diff --git a/ansible/roles/rke/templates/cluster.yml.j2 b/ansible/roles/rke/templates/cluster.yml.j2
index 64508e6..f28cff8 100644
--- a/ansible/roles/rke/templates/cluster.yml.j2
+++ b/ansible/roles/rke/templates/cluster.yml.j2
@@ -1,7 +1,5 @@
 nodes:
-{# Note that we iterate through all nodes in relevant groups.
-We check which groups they belong to exactly later to determine roles. #}
-{% for node in groups['kubernetes'] | union(groups['kubernetes-control-plane']) %}
+{% for node in groups['kubernetes'] %}
 - address: "{{ hostvars[node].cluster_ip }}"
   port: "22"
   internal_address: "{{ hostvars[node].cluster_ip }}"
@@ -9,7 +7,7 @@
 {% if node in groups['kubernetes-control-plane'] %}
   - controlplane
 {% endif %}
-{% if node in groups['kubernetes'] %}
+{% if node in groups['kubernetes-node'] %}
   - worker
   - etcd
 {% endif %}