Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error - argument 'receive_state' is of type <class 'str'> #15

Open
hsabale opened this issue Oct 27, 2022 · 1 comment
Open

Error - argument 'receive_state' is of type <class 'str'> #15

hsabale opened this issue Oct 27, 2022 · 1 comment

Comments

@hsabale
Copy link

hsabale commented Oct 27, 2022

(venv) simba@XXX:~/datacenter.aci-model$ ansible-playbook -i myinventory.yml myplaybook.yml -v
Using /home/simba/datacenter.aci-model/ansible.cfg as config file

PLAY [Deploy topology using ACI model] ***********************************************************************************************************************

TASK [datacenter.aci-model : include_tasks] ******************************************************************************************************************
included: /home/simba/datacenter.aci-model/tasks/my-test-yaml.yml for apic1

TASK [datacenter.aci-model : Create LLDP interface policies] *************************************************************************************************
failed: [apic1 -> localhost] (item={'access_policy_interface_policy_lldp_name': 'LLDP-ENABLE', 'access_policy_interface_policy_lldp_state': 'present', 'access_policy_interface_policy_lldp_receive_state': 'enabled', 'access_policy_interface_policy_lldp_transmit_state': 'enabled'}) => {"ansible_loop_var": "item", "changed": false, "item": {"access_policy_interface_policy_lldp_name": "LLDP-ENABLE", "access_policy_interface_policy_lldp_receive_state": "enabled", "access_policy_interface_policy_lldp_state": "present", "access_policy_interface_policy_lldp_transmit_state": "enabled"}, "msg": "argument 'receive_state' is of type <class 'str'> and we were unable to convert to bool: The value 'enabled' is not a valid boolean. Valid booleans include: 'off', 'y', 1, 0, 'on', 'f', '1', 't', 'yes', 'no', 'false', '0', 'true', 'n'"}
ok: [apic1 -> localhost] => (item={'access_policy_interface_policy_lldp_name': 'LLDP-DISABLE', 'access_policy_interface_policy_lldp_state': 'present', 'access_policy_interface_policy_lldp_receive_state': False, 'access_policy_interface_policy_lldp_transmit_state': False}) => {"ansible_loop_var": "item", "changed": false, "current": [{"lldpIfPol": {"attributes": {"adminRxSt": "disabled", "adminTxSt": "disabled", "annotation": "orchestrator:ansible", "descr": "", "dn": "uni/infra/lldpIfP-LLDP-DISABLE", "name": "LLDP-DISABLE", "nameAlias": "", "ownerKey": "", "ownerTag": "", "userdom": ":all:"}}}], "item": {"access_policy_interface_policy_lldp_name": "LLDP-DISABLE", "access_policy_interface_policy_lldp_receive_state": false, "access_policy_interface_policy_lldp_state": "present", "access_policy_interface_policy_lldp_transmit_state": false}, "mo": {"lldpIfPol": {"attributes": {"adminRxSt": "disabled", "adminTxSt": "disabled", "annotation": "orchestrator:ansible", "dn": "uni/infra/lldpIfP-LLDP-DISABLE", "name": "LLDP-DISABLE"}}}}

PLAY RECAP ***************************************************************************************************************************************************
apic1 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

Need to update inventory file

      - interface_policy_lldp:
        - name: LLDP-ENABLE
          state: present		
          receive_state: **on**
          transmit_state: **on**
        - name: LLDP-DISABLE
          state: present		
          receive_state: **off**
          transmit_state: **off**

After updating ...its work fine
(venv) simba@XXX:~/datacenter.aci-model$ ansible-playbook -i myinventory.yml myplaybook.yml -v
Using /home/simba/datacenter.aci-model/ansible.cfg as config file

PLAY [Deploy topology using ACI model] ***********************************************************************************************************************

TASK [datacenter.aci-model : include_tasks] ******************************************************************************************************************
included: /home/simba/datacenter.aci-model/tasks/my-test-yaml.yml for apic1

TASK [datacenter.aci-model : Create LLDP interface policies] *************************************************************************************************
ok: [apic1 -> localhost] => (item={'access_policy_interface_policy_lldp_name': 'LLDP-ENABLE', 'access_policy_interface_policy_lldp_state': 'present', 'access_policy_interface_policy_lldp_receive_state': True, 'access_policy_interface_policy_lldp_transmit_state': True}) => {"ansible_loop_var": "item", "changed": false, "current": [{"lldpIfPol": {"attributes": {"adminRxSt": "enabled", "adminTxSt": "enabled", "annotation": "orchestrator:ansible", "descr": "", "dn": "uni/infra/lldpIfP-LLDP-ENABLE", "name": "LLDP-ENABLE", "nameAlias": "", "ownerKey": "", "ownerTag": "", "userdom": ":all:"}}}], "item": {"access_policy_interface_policy_lldp_name": "LLDP-ENABLE", "access_policy_interface_policy_lldp_receive_state": true, "access_policy_interface_policy_lldp_state": "present", "access_policy_interface_policy_lldp_transmit_state": true}, "mo": {"lldpIfPol": {"attributes": {"adminRxSt": "enabled", "adminTxSt": "enabled", "annotation": "orchestrator:ansible", "dn": "uni/infra/lldpIfP-LLDP-ENABLE", "name": "LLDP-ENABLE"}}}}
ok: [apic1 -> localhost] => (item={'access_policy_interface_policy_lldp_name': 'LLDP-DISABLE', 'access_policy_interface_policy_lldp_state': 'present', 'access_policy_interface_policy_lldp_receive_state': False, 'access_policy_interface_policy_lldp_transmit_state': False}) => {"ansible_loop_var": "item", "changed": false, "current": [{"lldpIfPol": {"attributes": {"adminRxSt": "disabled", "adminTxSt": "disabled", "annotation": "orchestrator:ansible", "descr": "", "dn": "uni/infra/lldpIfP-LLDP-DISABLE", "name": "LLDP-DISABLE", "nameAlias": "", "ownerKey": "", "ownerTag": "", "userdom": ":all:"}}}], "item": {"access_policy_interface_policy_lldp_name": "LLDP-DISABLE", "access_policy_interface_policy_lldp_receive_state": false, "access_policy_interface_policy_lldp_state": "present", "access_policy_interface_policy_lldp_transmit_state": false}, "mo": {"lldpIfPol": {"attributes": {"adminRxSt": "disabled", "adminTxSt": "disabled", "annotation": "orchestrator:ansible", "dn": "uni/infra/lldpIfP-LLDP-DISABLE", "name": "LLDP-DISABLE"}}}}

PLAY RECAP ***************************************************************************************************************************************************
apic1 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

@hsabale
Copy link
Author

hsabale commented Oct 27, 2022


my-test-yaml.yml playbook

  • name: Push aci_model

    vars:
    aci_login: &aci_login
    hostname: '{{ apic_host }}'
    username: '{{ apic_username }}'
    password: '{{ apic_password }}'
    use_proxy: '{{ apic_use_proxy }}'
    validate_certs: '{{ apic_validate_certs }}'

    delegate_to: localhost

    block:

    • name: Create LLDP interface policies
      aci_intf_policy_lldp:
      <<: *aci_login
      lldp_policy: '{{ item.access_policy_interface_policy_lldp_name }}'
      receive_state: '{{ item.access_policy_interface_policy_lldp_receive_state }}'
      transmit_state: '{{ item.access_policy_interface_policy_lldp_transmit_state }}'
      with_items: '{{ aci_model_data|aci_listify("access_policy","interface_policy_lldp") }}'

myinventory.yml

fabric01:
hosts:
apic1:
apic_host: sandboxapicdc.cisco.com
apic_username: admin
apic_password: '!v3G@!4@Y'

vars:
apic_use_proxy: no
apic_validate_certs: no

aci_topology:
  access_policy:

--SNIP-------------
- interface_policy_lldp:
- name: LLDP-ENABLE
state: present
receive_state: on
transmit_state: on
- name: LLDP-DISABLE
state: present
receive_state: off
transmit_state: off
- interface_policy_port_channel:
--SNIP-------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant