Skip to content

Instantly share code, notes, and snippets.

@zeitounator
Created November 1, 2019 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeitounator/692abf1de75e44fa607fa052f09360e2 to your computer and use it in GitHub Desktop.
Save zeitounator/692abf1de75e44fa607fa052f09360e2 to your computer and use it in GitHub Desktop.
[k8s_gpu_nodes]
host1
host2
[k8s_cpu_nodes]
host3
host4
---
- name: Check everything is ok
vars:
gpu_count: "{{ groups['k8s_gpu_nodes'] | length }}"
cpu_count: "{{ groups['k8s_cpu_nodes'] | length }}"
assert:
that:
- gpu_count | int > 0
- cpu_count | int > 0
msg: "Assure k8s_nodes are not empty"
---
- name: Check nodes in groups
hosts: localhost
gather_facts: false
roles:
- role: test
$ ansible-playbook -i inventories/hosts.ini playbook.yml
PLAY [Check nodes in groups] ****************************************************************************************************************************************************************************
TASK [test : Check everything is ok] ********************************************************************************************************************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}
PLAY RECAP **********************************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
@ahmsb8884
Copy link

ahmsb8884 commented Nov 1, 2019

I checked out this and ran as is and getting error

ERROR! the role 'test' was not found in /home/dtlu/code/github/sb8884/692abf1de75e44fa607fa052f09360e2/roles:/home/dtlu/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/dtlu/code/github/sb8884/692abf1de75e44fa607fa052f09360e2

The error appears to be in '/home/dtlu/code/github/sb8884/692abf1de75e44fa607fa052f09360e2/2-playbook.yml': line 7, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  roles:
    - role: test
      ^ here

Then I created a directory as role_test/tasks and added main.yaml. now it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment