add dynamic (nmap) inventory; remove static inventory

This commit is contained in:
Chris Hammer 2023-03-14 16:55:26 -04:00
parent 57539f60f6
commit 49e549b8af
4 changed files with 32 additions and 28 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
collections
facts.d
inventory_cache

View File

@ -1,7 +1,7 @@
[defaults]
inventory = hosts
inventory = inventory
roles_path = roles
collections_path = /etc/ansible/collections
collections_path = collections
remote_tmp = /tmp/.ansible-${USER}/tmp
gathering = smart
gather_timeout = 300
@ -25,3 +25,11 @@ strategy = free
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o PreferredAuthentications=publickey
#[inventory]
#cache = True
#cache_plugin = ansible.builtin.jsonfile
#cache_connection = inventory_cache
#cache_timeout = 300
#cache_prefix = ansible_nmap_inventory_

26
hosts
View File

@ -1,26 +0,0 @@
[dev]
lab-dev-1 ansible_host=10.10.42.235
lab-dev-2 ansible_host=10.10.42.203
lab-dev-3 ansible_host=10.10.42.218
lab-dev-4 ansible_host=10.10.42.240
lab-dev-5 ansible_host=10.10.42.208
lab-dev-6 ansible_host=10.10.42.213
lab-dev-7 ansible_host=10.10.42.202
lab-dev-8 ansible_host=10.10.42.220
lab-dev-9 ansible_host=10.10.42.239
lab-dev-10 ansible_host=10.10.42.246
lab-dev-11 ansible_host=10.10.42.244
lab-dev-12 ansible_host=10.10.42.145
lab-dev-13 ansible_host=10.10.42.147
lab-dev-14 ansible_host=10.10.42.157
lab-dev-15 ansible_host=10.10.42.177
lab-dev-16 ansible_host=10.10.42.133
lab-dev-17 ansible_host=10.10.42.179
lab-dev-18 ansible_host=10.10.42.165
lab-dev-19 ansible_host=10.10.42.188 ansible_user=broken
lab-dev-20 ansible_host=10.10.42.142
[dev:vars]
ansible_user=root

View File

@ -0,0 +1,21 @@
---
plugin: community.general.nmap
address: 10.10.42.0/24
strict: False
ipv4: yes
ports: no
cache: yes
cache_plugin: ansible.builtin.jsonfile
cache_connection: inventory_cache
cache_timeout: 300
cache_prefix: ansible_nmap_inventory_
groups:
dev_nodes: "'lab-dev' in name"
everything_else: "'lab-dev' not in name"
ip_only: "'10.10.42' in name"
...