Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hosts with IP range

Tags:

ansible

I have hosts without stable hostnames, but with predefined IP ranges.
How can I set the IP range for Ansible inventory file?

I'm trying to setup something like this:

test.ini:

[database]
db ansible_ssh_host=1.1.1.[20:25] ansible_ssh_port=22
[lemp]
lemp ansible_ssh_host=1.1.1.[10:15] ansible_ssh_port=22

And now I get this error after running ansible-playbook -i test.ini:

fatal: [db] => SSH Error: ssh: Could not resolve hostname 1.1.1.[20:25]: Name or service not known

like image 543
kivagant Avatar asked Sep 06 '25 03:09

kivagant


1 Answers

I found this working solution for my problem:

test.ini:

# I removed hostname section and ansible_ssh_host=
10.0.3.[20:25] ansible_ssh_port=22
like image 59
kivagant Avatar answered Sep 08 '25 09:09

kivagant