Hi Janv,
Like mentioned earlier, IAP software version 8.5 and above have REST APIs and we have the sample playbooks for the same.
Link to REST API based Ansible Modules and Playbooks
Public Ansible Github Repo :- https://github.com/aruba/aruba-ansible-modules
IAP Sample Playbook :- https://github.com/aruba/aruba-ansible-modules/tree/master/example_playbooks/aruba_instant
In case, you would still like to take the CLI based approach, you could try using aruba_command ansible module and aruba_config ansible module from the ansible galaxy.
As this module is primarily made for aruba switches and aruba controllers, there might be some minor tweaks required. In order to execute commands with SSH, prompt of the device needs to match a pattern so the program understands that executed command is complete and ready for the next command. That might be one of the reason you get the timeout error.
For example, I have tried aruba_command ansible module to execute show commands in IAP with this change.
Change for IAP CLI terminal prompt
- Execute “ansible --version” command and obtain the "ansible python module location".
- Go to “/plugins/terminal” folder and edit the aruba.py file.
- replace the variable "terminal_stdout_re" with the following
terminal_stdout_re = [
re.compile(br"[\r
]?[\w]*\(.+\) ?#(?:\s*)$"),
re.compile(br"[\r
]?[\w]*\(.+\)\s*[\^\*]?(?:\[.+\])? ?#(?:\s*)$"),
re.compile(br"[pP]assword:$"),
re.compile(br"(?<=\s)[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\s*#\s*$"),
re.compile(br"[\r
]?[\w\+\-\.:\/\[\]]+(?:\([^\)]+\)){0,3}(?:[>#]) ?$"),
re.compile(br"^([\w\W]*)?#\s*$")
]
In case, you would like to try CLI for Aruba Controller, make this fix manually at your ansible installation. (Fix:- AOS8 controller based ansible bug and commit)
Sample Aruba_command IAP playbook (CLI based):
- name: Sample SSH based IAP playbook
hosts: iapmesh
connection: local
gather_facts: no
vars_files:
- variables.yml
tasks:
- name: run show aps command on Instant AP
aruba_command:
commands: show aps
interval: 300
provider: "{{ provider }}"
register: aps_output
ignore_errors: yes
Thanks,
Karthik