aruba / aruba-ansible-modules

Aruba Ansible Modules
Apache License 2.0
80 stars 36 forks source link

Session Cookie for IAP #106

Open mac0815 opened 4 years ago

mac0815 commented 4 years ago

Hi you show in your code for IAP´s a example

I guess the session column means that i can use the session token for the REST API ? But could you please explain a bit more how to use it?

just want to avoid to use user and password variable for every - name: etc.etc. in the playbooks Maybe that it could looks like this ?

or maybe other solutions to shorten a complete IAP Configuration playbook ? Bye Mac

JCTechSol commented 3 years ago

I agree, its not good to have plain text password info exposed nor is it helpful to have to reenter the login info over and over again. This is what I came up with to utilize the session method:

- name: Logging into IAP
  uri:
    url: https://{{ devs }}:4343/rest/login
    return_content: yes
    method: POST
    validate_certs: no
    body_format: json
    body: {
      "user": "{{ ansible_user }}",
      "passwd": "{{ ansible_ssh_pass }}" 
      }
  register: login
  no_log: True

Then I can use it like so:

- name: Show running-config
  arubainstant_config:
    session: {
      'host': "{{ devs }}",
      'session_token': "{{ login.json.sid }}"
      }
    method: GET
    iap_ip_addr: 0.0.0.0
    api_type: monitoring
    api_name: show running-config
  register: Config