Change VLAN using interactive playbook with prompt

19 views
Skip to first unread message

Hossein Malakooti

unread,
Dec 1, 2022, 4:45:53 PM12/1/22
to Ansible Project
Hello Dear Fellows
I am a newbie to Ansible I searched for in existing discussions but I couldn't find a clear answer , I was hoping you could help me find a write Config

I am trying to write a playbook who prompt user for Interface ID and change the VLAN accordingly , My playbook works  without prompt but when I add prompt it throw a error
it looks like I am not supposed to put vars_promp after config but I tried in different lines and non of them worked

Here Is My Inventory Yaml File:
all:
   children:
      switches:
         children:
            ios:
             hosts:
              sw-1:
                 ansible_host: 10.10.10.20
             vars:
                ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
                ansible_become: yes
                ansible_connection: network_cli
                ansible_network_os: ios
                ansible_become_method: enable
                ansible_user: ncm
                ansible_password: ncm

And Here Is My Playbook
---
 - name: Config VLAN
   hosts: switches

   tasks:
      - name: Configure Access
        ios_l2_interfaces:
          config:
             vars_prompt:
                - name: "Interface"
                  prompt: "Enter Interface Name"
                  private: false

                  access:
                  vlan: 7
          state: merged


here is the original playbook which actually works but with an static value for interface ID
---
 - name: Config VLAN
   hosts: switches
   
   tasks:
      - name: Configure Access
        ios_l2_interfaces:
          config:
            - name: GigabitEthernet1/0/35
              access:
                vlan: 7
          state: merged


Thanks for you time in advance
Reply all
Reply to author
Forward
0 new messages