Created
November 1, 2019 22:00
-
-
Save zeitounator/692abf1de75e44fa607fa052f09360e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[k8s_gpu_nodes] | |
host1 | |
host2 | |
[k8s_cpu_nodes] | |
host3 | |
host4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Check nodes in groups | |
hosts: localhost | |
gather_facts: false | |
roles: | |
- role: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I checked out this and ran as is and getting error
Then I created a directory as role_test/tasks and added main.yaml. now it works.