cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1627
Views
2
Helpful
15
Replies

cisco aci automation using ansible

vijays19
Level 1
Level 1

Hi All,

Am new to cisco aci automation using ansible. i am using windows 11 and installed WSL (ubuntu). then, then installed python and ansible. I got an error when i execute the below command . Please help on how to fix this issue. how can we access sandbox from virtual VM machine.

 

home@IBM-PF35CWE8:~/aci_ansible_learning_labs_code_samples/intro_module$ ansible-playbook -i inventory 01_aci_tenant_pb.yml
What would you like to name your Tenant?: vs_1008

PLAY [ENSURE APPLICATION CONFIGURATION EXISTS] *************************************************************************

TASK [ENSURE APPLICATIONS TENANT EXISTS] *******************************************************************************
fatal: [sandboxapicdc.cisco.com]: FAILED! => {"changed": false, "error": {"code": "400", "text": "Failed to parse login request"}, "msg": "Authentication failed: 400 Failed to parse login request"}

PLAY RECAP *************************************************************************************************************
sandboxapicdc.cisco.com    : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

 

15 Replies 15

Marcel Zehnder
Spotlight
Spotlight

Can you post the contents of your inventory file + playbook?

vijays19
Level 1
Level 1

inventory

[apic:vars]
username=admin
password=!v3G@!4@Y
ansible_python_interpreter="/usr/bin/python3"

[apic]
sandboxapicdc.cisco.com

Tenant config

name: ENSURE APPLICATION CONFIGURATION EXISTS
hosts: apic
connection: local
gather_facts: False
vars_prompt:
- name: "tenant"
prompt: "What would you like to name your Tenant?"
private: no

tasks:
- name: ENSURE APPLICATIONS TENANT EXISTS
aci_tenant:
host: "{{ ansible_host }}"
username: "{{ username }}"
password: "{{ password }}"
state: "present"
validate_certs: False
tenant: "{{ tenant }}"
description: "Tenant Created Using Ansible"
~ ~

Can you test again, your files work for me.

inventory

 

[apic:vars]
username=admin
password=!v3G@!4@Y

[apic]
sandboxapicdc.cisco.com

 

test.yml

 

- name: ENSURE APPLICATION CONFIGURATION EXISTS
  hosts: apic
  connection: local
  gather_facts: False
  vars_prompt:
   - name: "tenant"
     prompt: "What would you like to name your Tenant?"
     private: no

  tasks:
    - name: ENSURE APPLICATIONS TENANT EXISTS
      aci_tenant:
        host: "{{ ansible_host }}"
        username: "{{ username }}"
        password: "{{ password }}"
        state: "present"
        validate_certs: False
        tenant: "{{ tenant }}"
        description: "Tenant Created Using Ansible"

 

ouput

 

(default) maercu@CHLT303344:~/dev/ciscocomtest$ ansible-playbook -i inventory test.yml
What would you like to name your Tenant?: blablabla

PLAY [ENSURE APPLICATION CONFIGURATION EXISTS] *************************************************************************

TASK [ENSURE APPLICATIONS TENANT EXISTS] *******************************************************************************
changed: [sandboxapicdc.cisco.com]

PLAY RECAP *************************************************************************************************************
sandboxapicdc.cisco.com    : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

 



 

Playbook all looks good, i think the 400 is red flag and the sandbox/API was busy - it was taking an age for the UI to load this morning. This sandbox gets a lot of use daily.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Agree, overlooked this one (tought its a 401 and some user/password issue) - but you're right, might be overload situation.

Hi @vijays19 

I noticed some change in the collection version 2.7, try to explicit set the use_ssl param (will check the code of the collection to understand what's happening):

- name: ENSURE APPLICATION CONFIGURATION EXISTS
  hosts: apic
  connection: local
  gather_facts: False
  vars_prompt:
   - name: "tenant"
     prompt: "What would you like to name your Tenant?"
     private: no

  tasks:
    - name: ENSURE APPLICATIONS TENANT EXISTS
      aci_tenant:
        host: "{{ ansible_host }}"
        username: "{{ username }}"
        password: "{{ password }}"
        state: "present"
        validate_certs: False
        use_ssl: true
        tenant: "{{ tenant }}"
        description: "Tenant Created Using Ansible"

 

vijays19
Level 1
Level 1

Hi Marcel,

Thanks for your response.

Do i need to remove ansible_python_interpreter="/usr/bin/python3" from inventory. from your output its not there.

 

Most propably you don't need it.

qsnyder
Cisco Employee
Cisco Employee

Have you installed the collection for ACI?

ansible-galaxy collection install cisco.aci

?

q.

vijays19
Level 1
Level 1

No I didnt install it. i will do it now.

Marcel Zehnder
Spotlight
Spotlight

Looks like you installed the "batteries included" version of ansible with the aci collection already included - the galaxy install is only needed, if you install only the ansible-core version. But anyway, Quinn's input is valid - upgrading the collection won't hurt:

ansible-galaxy collection install cisco.aci --upgrade

As of Ansible 2.10 (which was released about 5 years ago) -- Ansible no longer includes external modules.

If the OP installed a fresh version of Ansible without statically setting the version in the installation or requirements file -- then he needs to install the collection.

Marcel Zehnder
Spotlight
Spotlight

Yeah I know that, Quinn. Sorry I should have been more precise: I was refering the ansible version installed via pip (pip install ansible vs. pip install ansible-core). The "normal" python package (aka the ansible community package - which is installed via pip install ansible) still includes the most common collections including ACI (https://pypi.org/project/ansible/).