semaphoreui / semaphore

Modern UI for Ansible, Terraform, OpenTofu, Bash, Pulumi.
https://semaphoreui.com
MIT License
9.69k stars 1k forks source link

Dynamic inventory ansible playbook cannot get hosts value #2144

Open seaurching opened 1 week ago

seaurching commented 1 week ago

Issue

Hellow,owner: my playbook field hosts is an variables with {{ exec_group }}. The file is

- name: "test hosts ping"
  hosts: "{{ exec_group }}"
  roles: ["ping"]

The webui configured the list_enviromnent with emulate values, like this: image

then the task is faied with error: image

I used an dynamic inventory,the hosts directory files is :

72410211c0bd:/home/ansible-playbook$ ls hosts/
evad_idcp_kcde_test_master  pre_tjv1_evad_kcde_master   tj5_cloudml_worker_init     tjv1_kcde_master
evad_idcp_kcde_test_worker  pre_tjv1_evad_kcde_worker   tjv1_cloudml_master         tjv1_kcde_worker
group_vars                  tj5_cloudml_master          tjv1_cloudml_worker         tjv1_kcde_worker_init
host_vars                   tj5_cloudml_worker          tjv1_cloudml_worker_init    zhosts

Impact

Ansible (task execution)

Installation method

Docker

Database

BoltDB

Browser

Microsoft Edge

Semaphore Version

v2.10.7

Ansible Version

No response

Logs & errors

No response

Manual installation - system information

No response

Configuration

No response

Additional information

No response

ramiuslr commented 1 week ago

I guess this is because you need to define a default value to your hosts variable using Jinja2 syntax. Mine is:

hosts: "{{ custom_host | default('invalid') }}"

Then in the webui: image

seaurching commented 5 days ago

I guess this is because you need to define a default value to your hosts variable using Jinja2 syntax. Mine is:

hosts: "{{ custom_host | default('invalid') }}"

Then in the webui: image

still same error