command: “netstat -an grep ':{{ hostvars[inventoryhostname].adminport }} ’ grep LISTEN”…
- User
command: “netstat -an | grep ':{{ hostvars[inventory_hostname].admin_port }} ’ | grep LISTEN” doesnt work why?
- Assistant
The command you've written appears to be mixing shell command syntax with Ansible template syntax, which might be causing the problem. If you are attempting to use this command inside an Ansible playbook or task, you should ensure that you are using the proper Ansible syntax to access host variables. Here is a breakdown of what might be going wrong:
{{ hostvars[inventory_hostname].admin_port }}is Ansible templating syntax accessing theadmin_portvariable of the current host () in the host variables ().