08-29-2023 12:59 AM
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
08-29-2023 01:17 AM
Can you post the contents of your inventory file + playbook?
08-29-2023 01:55 AM
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"
~ ~
08-29-2023 06:26 AM - edited 08-29-2023 06:27 AM
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
08-29-2023 07:13 AM
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.
08-29-2023 08:19 AM
Agree, overlooked this one (tought its a 401 and some user/password issue) - but you're right, might be overload situation.
09-12-2023 04:09 AM
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"
09-12-2023 04:23 AM - edited 09-12-2023 04:24 AM
Found it, the default param for use_ssl was removed in version 2.7.0
https://github.com/CiscoDevNet/ansible-aci/blob/v2.6.0/plugins/module_utils/aci.py#L126
https://github.com/CiscoDevNet/ansible-aci/blob/v2.7.0/plugins/module_utils/aci.py#L134
An issue/PR is already open: https://github.com/CiscoDevNet/ansible-aci/issues/466
08-29-2023 07:26 AM
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.
08-29-2023 08:20 AM
Most propably you don't need it.
08-29-2023 07:45 AM
Have you installed the collection for ACI?
ansible-galaxy collection install cisco.aci
?
q.
08-29-2023 07:50 AM
No I didnt install it. i will do it now.
08-29-2023 08:42 AM
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
08-29-2023 09:51 AM
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.
08-29-2023 11:06 PM - edited 08-29-2023 11:08 PM
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/).
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide