Team,
Я не могу обойти эту проблему синтаксиса даже после поиска в Интернете. Любой намек?
мне нужно посчитать количество хостов во всех группах на данный момент два в файле инвентаризации.
задача
#Validate cluster nodes to inventory specification
- assert:
that:
- "groups['k8s_gpu_nodes'] | length >= 1"
- "groups['k8s_cpu_nodes'] | length >= 1"
msg: "Assure k8s_nodes are not empty"
#Count the hosts in groups in inventory
- name: Inventory validation
hosts: localhost
gather_facts: false
vars:
GPU_COUNT: "{{ groups['k8s_gpu_nodes'] | length }}"
CPU_COUNT: "{{ groups['k8s_cpu_nodes'] | length }}"
tasks:
- assert:
that:
- "GPU_COUNT | int <= 1"
- "CPU_COUNT | int <= 1"
ИЛИ
*Вывод 1011 *
одинаков для всех опций, указанных выше.
#Count the hosts in groups in inventory
- name: Inventory validation
^ here
ЗАДАЧА без имени:
#Count the hosts in groups in inventory
- hosts: localhost
gather_facts: false
vars:
GPU_COUNT: "{{ groups['k8s_gpu_nodes'] | length }}"
CPU_COUNT: "{{ groups['k8s_cpu_nodes'] | length }}"
tasks:
- assert:
that:
- "GPU_COUNT | int <= 1"
- "CPU_COUNT | int <= 1"
ERROR! unexpected parameter type in action: <type 'bool'>
The error appears to be in '/home/du/ansible/roles/3_validations_on_ssh/tasks/main.yaml': line 45, column 9, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
#Count the hosts in groups in inventory
- hosts: localhost
^ here
инвентарь
target1 ansible_host='{{ target1_hostip }}' ansible_ssh_pass='{{ target1_pass }}'
[k8s_gpu_nodes]
host1
host2
[k8s_cpu_nodes]
host3
host4