<p>I am using ansible <code>version 2.5.1</code> with python <code>version 2.7.17</code> and I installed an open shift.</p>
<p>The playbook looks like this:</p>
<pre class="lang-yaml prettyprint-override"><code>---
- hosts: node 1 
  tasks:
  - name: Create a k8s namespace
    k8s:
      name: CC_Namespace
      api_version: v1
      kind: Namespace
      state: present
  # Deployment Frontend 
  - name: Create a Frontend Deployment Object
    k8s:
      apiVersion: v1
      kind: Deployment
      metadata:
        name: nginx-frontend-deployment
        labels:
          app: nginx
      spec:
        replicas: 4
        selector:
          matchLabels:
            app: nginx
        template:
          metadata:
            labels:
              app: nginx
          spec:
            containers:
            - name: nginx
              image: nginx:1.7.9 
              ports:
              - containerPort: 80
          livenessProbe:
            exec:
              command:
              - /ready
          readinessProbe:
            exec:
              command:
              - /ready
  # Deployment Backend 
  - name: Create a Backend Deployment Object
    k8s:
      apiVersion: v1
      kind: Deployment
      metadata:
        name: nginx-backend-deployment
        labels:
          app: nginx
      spec:
        replicas: 6
        selector:
          matchLabels:
            app: nginx
        template:
          metadata:
            labels:
              app: nginx
          spec:
            containers:
            - name: nginx
              image: nginx:1.7.9 # change to Dockerfile  
              ports:
              - containerPort: 80
          livenessProbe:
            exec:
              command:
              - /ready
          readinessProbe:
            exec:
              command:
              - /ready
  # Service Backend
  - name: Create a Backend Service Object
    k8s:
      apiVersion: v1
      kind: Service
      metadata:
        name: cc-backend-service
      spec:
        selector:
          app: CCApp
        ports:
          - protocol: TCP
            port: 80
        type: ClusterIP
  # Serive Frontend
  - name: Create a Frontend Service Object
    k8s:
      apiVersion: v1
      kind: Service
      metadata:
        name: cc-frontend-service
      spec:
        selector:
          app: CCApp
        ports:
          - protocol: TCP
            port: 80
        type: NodePort
</code></pre>
<p>and this is the error:</p>
<hr />
<blockquote>
<p>[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'</p>
</blockquote>
<blockquote>
<p>ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.</p>
</blockquote>
<blockquote>
<p>The error appears to have been in '/home/rocco/cc-webapp.yml': line 4, column 5, but may
be elsewhere in the file depending on the exact syntax problem.</p>
</blockquote>
<blockquote>
<p>The offending line appears to be:</p>
</blockquote>
<pre class="lang-yaml prettyprint-override"><code>tasks:
- name: Create a k8s namespace
  ^ here
</code></pre>
<hr />

<p>The minimum ansible version to have <code>k8s</code> module available is 2.6. (<a href="https://docs.ansible.com/ansible/latest/modules/k8s_module.html." rel="nofollow noreferrer">Reference</a>)</p>
<p>No choice, you have to upgrade.</p>
<p>Note: I tested your playbook syntax without any errors in ansible 2.9.2</p>
