Ansible-Navigator Inventory

Ansible-Navigator Inventory


Ansible Navigator trenger en inventory fil på helt like måte som da vi brukt ansible core,.
når vi kjørte playbook med ansible-playbook.
Det er opprettet en ny repository på github som heter ansible-navigator som jeg kommer til å bruke.
Jeg kopiere over deler av inventory filen fra det forrige repoet som vi har brukt.

[IOS_switcher]
IOS_switch_1 ansible_host=10.170.0.231
IOS_switch_2 ansible_host=10.170.0.232

[IOS_XE_switcher]
IOS_XE_switch_3 ansible_host=10.170.0.233
IOS_XE_switch_4 ansible_host=10.170.0.234

[IOS_rutere] 
IOS_ruter_1 ansible_host=10.170.0.251

[IOS_XE_rutere] 
IOS_XE_ruter_2 ansible_host=10.170.0.252
IOS_XE_ruter_3 ansible_host=10.170.0.253

[switcher:children]
IOS_switcher
IOS_XE_switcher

[rutere:children]
IOS_rutere
IOS_XE_rutere
                

Med ansible-inventory kan vi hente ut informasjon om inventory filen.
ansible-inventory -i inventory --list
Det samme kan vi gjøre med ansible-navigator.
ansible-navigator inventory -i inventory
  Title                                   Description
0│Browse groups                           Explore each inventory group and group members members
1│Browse hosts                            Explore the inventory with a list of all hosts
                 

Vi kommer inn i TUI og kan bruke tall for å navigere.
Hvis vi ønsker å få ut informasjonen til stdout som vi gjorde med ansible-inventory kan vi gjøre det med følgende kommando.
ansible-navigator inventory -i inventory -m stdout --list
eller en graph
ansible-navigator inventory -i inventory -m stdout --graph
[autom8@localhost ansible_naviagtor]$ ansible-navigator inventory -i inventory  -m stdout --graph
@all:
  |--@ungrouped:
  |--@switcher:
  |  |--@IOS_switcher:
  |  |  |--IOS_switch_1
  |  |  |--IOS_switch_2
  |  |--@IOS_XE_switcher:
  |  |  |--IOS_XE_switch_3
  |  |  |--IOS_XE_switch_4
  |--@rutere:
  |  |--@IOS_rutere:
  |  |  |--IOS_ruter_1
  |  |--@IOS_XE_rutere:
  |  |  |--IOS_XE_ruter_2
  |  |  |--IOS_XE_ruter_3