Skip to content

Instantly share code, notes, and snippets.

@radimih
Created November 23, 2019 13:54
Show Gist options
  • Select an option

  • Save radimih/0c8509fd3919d1ea4e06a6cba6f6a334 to your computer and use it in GitHub Desktop.

Select an option

Save radimih/0c8509fd3919d1ea4e06a6cba6f6a334 to your computer and use it in GitHub Desktop.
Ansible: get address host from Ansible inventory from bash-script
# Получить адрес хоста по его имени в Ansible inventory
host_address=`ansible --inventory ansible/inventories/hosts.yml \
--module-name debug --args msg="{{ hostvars['host-name'].ansible_host }}" \
--one-line localhost | sed -E 's/.+"msg":\s"(.+)".+/\1/'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment