On Friday, 23 February 2018 21.42.00 CET Jonathan Umpleby wrote:
> So here's an example:
>
> enable
> *<password>*
> config terminal
> appliance-name "*proxy1*"
>
> interface 0:0 ;mode
> label "MGMT"
> ip-address *10.0.0.100* 255.255.255.0
> exit
>
> interface 1:0 ;mode
> label "unused"
> reject-inbound enable
> disable
> exit
>
> interface 1:1 ;mode
> label "VLAN TAG#"
> ip-address *10.0.0.10* 255.255.255.128
> native-vlan #
> exit
>
> interface 2:0 ;mode
> label "unused"
> reject-inbound enable
> disable
> exit
>
> interface 2:1 ;mode
> label "VLAN TAG#"
> ip-address *10.0.0.140* 255.255.255.128
> native-vlan #
> exit
>
> Now, obviously the items in bold are values that need to be customized in
> the ansible script. So I don't think I can put this into the response
> file, unless I can somehow pass values into a response file for example:
Just to make it easy to explain I assume that you only have one prompt, the only different when prompt is different is that you need to split the list in smaller ones.
The principal of expect is like this
- expect:
command: a-command
reponses:
prompt1/question:
- answer 1
- answer 2
...
so the prompt just take a list, this can be built before the expect command.
vars:
dynmatic_responds:
- <password>
- <proxy>
- 10.0.0.100
- 10.0.0.10
- 10.0.0.140
response:
- enable
- '{{ dynmatic_responds.0 }}'
- config terminal
- appliance-name "{{ dynmatic_responds.1 }}"
- interface 0:0 ;mode
- label "MGMT"
- ip-address {{ dynmatic_responds.2 }} 255.255.255.0
- exit
- interface 1:0 ;mode
- label "unused"
- reject-inbound enable
- disable
- exit
- interface 1:1 ;mode
- label "VLAN TAG#"
- ip-address {{ dynmatic_responds.3 }} 255.255.255.128
- native-vlan #
- exit
- interface 2:0 ;mode
- label "unused"
- reject-inbound enable
- disable
- exit
- interface 2:1 ;mode
- label "VLAN TAG#"
- ip-address {{ dynmatic_responds.4 }} 255.255.255.128
- native-vlan #
- exit
So the task would be
reponses:
prompt1/question: {{ response }}
This is just and example of how it could be done, I would find a way to make it even more dynamic.
But here you have the skeleton in responses and each device would have a uniq dynmatic_responds.
Hopefully this give you an idea of how this could be done.
--
Kai Stian Olstad