Ansible vars_prompt value in menu

49 views
Skip to first unread message

vsslava one

unread,
Sep 15, 2017, 2:22:47 AM9/15/17
to Ansible Project

I have playbook

- hosts: "{{ host }}"
  connection: paramiko
  gather_facts: no
  serial: 1
  user: administrator
  vars_prompt:
    - name: host
      prompt: "select the router to change default route?\n1- Test01\n2- Test02\n"
      default: 1
      private: no

  tasks:
    - debug: msg="{{ host }}"

Inventory:

[1]
192.168.10.100

[2]
192.168.10.102

but I need inventory:

[Test01]
192.168.10.100

[Test02]
192.168.10.102

If you enter eg 1, the host variable contains 1, and I need to get Test01

Soniya panwar

unread,
Sep 15, 2017, 3:43:52 AM9/15/17
to Ansible Project
Hello,

you can use python script to map these host variables else you can directly ask user to give input as Test01.

Thanks
Soniya

Brian Coca

unread,
Sep 15, 2017, 3:30:48 PM9/15/17
to Ansible Project
or juts do :

hosts: "Test0{{ host }}"

--
----------
Brian Coca

vsslava one

unread,
Sep 15, 2017, 5:38:52 PM9/15/17
to Ansible Project
but host names can be nvkz01 or prv02, then how to be?

пятница, 15 сентября 2017 г., 22:30:48 UTC+3 пользователь Brian Coca написал:
Reply all
Reply to author
Forward
0 new messages