ANSIBLE: - 'NoneType' object has no attribute 'element_str'\n",

L1 Bithead

ANSIBLE: - 'NoneType' object has no attribute 'element_str'\n",

Hi there.
I have a licensed VM100 running.
I'm trying to use the module "", but for some reason is not working.

From the 20 modules that are available with the ansible default instalation, this is the only one not working.
I tried to use the dev version of the modules from the github repo (ansible-pan/library/ also, but it did not make any difference.
I tried to debug it on my own, but I could not find what is wrong.
I've been trying to fix it for four days (yeah, I'm not a Python dev... yet :P)

Could someone suggest me something?

Thanks in advance


show system info:

admin@fwpasbx01> show system info

hostname: fwpasbx01
ip-address: XXX.XXX.46.179
public-ip-address: unknown
default-gateway: XXX.XXX.46.1
ip-assignment: static
ipv6-address: unknown
ipv6-link-local-address: fe80::XXXX:XXXX:XXXX:XXXX/64
mac-address: XX:XX:XX:XX:c0:bb
time: Thu Apr 19 10:36:31 2018
uptime: 9 days, 1:17:20
family: vm
model: PA-VM
vm-mac-base: XX:XX:XX:XX:A0:00
vm-mac-count: 256
vm-license: VM-100
vm-mode: VMWare ESXi
cloud-mode: non-cloud
sw-version: 8.1.0
global-protect-client-package-version: 0.0.0
app-version: 769-4439
av-version: 0
threat-version: 0
wf-private-version: 0
wf-private-release-date: unknown
url-db: paloaltonetworks
wildfire-version: 0
url-filtering-version: 0000.00.00.000
global-protect-datafile-version: unknown
global-protect-datafile-release-date: unknown
global-protect-clientless-vpn-version: 0
logdb-version: 8.1.8
platform-family: vm
vpn-disable-mode: off
multi-vsys: off
operational-mode: normal

Testing matching policy from SSH:

admin@fwpasbx01> test security-policy-match protocol 6 source destination destination-port 8889

"DenyAll; index: 3" {
        from any;
        source any;
        source-region none;
        to any;
        destination any;
        destination-region none;
        user any;
        category any;
        application/service 0:any/any/any/any;
        action drop;
        icmp-unreachable: no
        terminal no;

My playbook:

# how to call this
# ansible-playbook panos_pbk_12_match_rule.yml --extra-vars "hosts_to_use='fwpa01'"  -vvvv

- name: check match rule test
  hosts: "{{ hosts_to_use }}"
  gather_facts: false
  connection: local

  - /home/XXXXXXXXX/ansible/vault.yml
#  - ../vault.yml


  - debug:  msg={{"Working on host"}}{{ ":" }}{{ " " }}{{ inventory_hostname}}{{"   IP"}}{{ ":" }}{{ " " }}{{ansible_host}}{{"   username"}}{{ ":" }}{{ " " }}{{vault_fwpa01_username}}{{"   password"}}{{ ":" }}{{ " " }}{{vault_fwpa01_password}}

  - name: check security rules for Google DNS
      ip_address: "{{ansible_host}}"
      username: "{{vault_fwpa01_username}}"
      password: '{{vault_fwpa01_password}}'
      rule_type: 'security'
      source_ip: ''
      destination_ip: ''
      destination_port: '8889'
      protocol: '6'
    register: result

  - debug: msg='{{result.stdout_lines}}'

The full error message I'm receiving:

[HIDDENUSERNAME@rh_vm_ansible-sbx_ip_dot6 plays_BUG]$ ansible-playbook panos_pbk_12_match_rule.yml --extra-vars "hosts_to_use='fwpa01'"  -vvvv
ansible-playbook 2.5.0
  config file = /home/HIDDENUSERNAME/.ansible.cfg
  configured module search path = [u'/home/HIDDENUSERNAME/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, May  3 2017, 07:55:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-14)]
Using /home/HIDDENUSERNAME/.ansible.cfg as config file
setting up inventory plugins
Parsed /home/HIDDENUSERNAME/ansible/hosts inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: panos_pbk_12_match_rule.yml ************************************************************************************************************************************
1 plays in panos_pbk_12_match_rule.yml
Trying secret FileVaultSecret(filename='/home/HIDDENUSERNAME/ansible/.vault_pass_file.txt') for vault_id=default
Read vars_file '/home/HIDDENUSERNAME/ansible/vault.yml'
Read vars_file '/home/HIDDENUSERNAME/ansible/vault.yml'

PLAY [check match rule test] *********************************************************************************************************************************************
META: ran handlers
Read vars_file '/home/HIDDENUSERNAME/ansible/vault.yml'

TASK [debug] *************************************************************************************************************************************************************
task path: /home/HIDDENUSERNAME/ansible/git_ansible-pan_modules_and_playbooks/playbooks/plays_BUG/panos_pbk_12_match_rule.yml:18
ok: [fwpa01] => {
    "msg": "Working on host: fwpa01   IP: XXX.XXX.46.179   username: testadmin   password: HIDDENPASSWORD"
Read vars_file '/home/HIDDENUSERNAME/ansible/vault.yml'

TASK [check security rules for Google DNS] *******************************************************************************************************************************
task path: /home/HIDDENUSERNAME/ansible/git_ansible-pan_modules_and_playbooks/playbooks/plays_BUG/panos_pbk_12_match_rule.yml:20
Using module file /usr/lib/python2.7/site-packages/ansible/modules/network/panos/
<XXX.XXX.46.179> EXEC /bin/sh -c 'echo ~ && sleep 0'
<XXX.XXX.46.179> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/HIDDENUSERNAME/.ansible/tmp/ansible-tmp-1524153472.65-57023960501559 `" && echo ansible-tmp-1524153472.65-57023960501559="` echo /home/HIDDENUSERNAME/.ansible/tmp/ansible-tmp-1524153472.65-57023960501559 `" ) && sleep 0'
<XXX.XXX.46.179> PUT /home/HIDDENUSERNAME/.ansible/tmp/ansible-local-1288640VldIv/tmpoAkT7S TO /home/HIDDENUSERNAME/.ansible/tmp/ansible-tmp-1524153472.65-57023960501559/
<XXX.XXX.46.179> EXEC /bin/sh -c 'chmod u+x /home/HIDDENUSERNAME/.ansible/tmp/ansible-tmp-1524153472.65-57023960501559/ /home/HIDDENUSERNAME/.ansible/tmp/ansible-tmp-1524153472.65-57023960501559/ && sleep 0'
<XXX.XXX.46.179> EXEC /bin/sh -c '/usr/bin/python /home/HIDDENUSERNAME/.ansible/tmp/ansible-tmp-1524153472.65-57023960501559/ && sleep 0'
<XXX.XXX.46.179> EXEC /bin/sh -c 'rm -f -r /home/HIDDENUSERNAME/.ansible/tmp/ansible-tmp-1524153472.65-57023960501559/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_s7iVn5/", line 379, in <module>
  File "/tmp/ansible_s7iVn5/", line 373, in main
    stdout_lines=json.dumps(xmltodict.parse(rule_match.element_str()), indent=2),
AttributeError: 'NoneType' object has no attribute 'element_str'

fatal: [fwpa01]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_s7iVn5/\", line 379, in <module>\n    main()\n  File \"/tmp/ansible_s7iVn5/\", line 373, in main\n    stdout_lines=json.dumps(xmltodict.parse(rule_match.element_str()), indent=2),\nAttributeError: 'NoneType' object has no attribute 'element_str'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE",
    "rc": 1

PLAY RECAP ***************************************************************************************************************************************************************
fwpa01                     : ok=1    changed=0    unreachable=0    failed=1

I really appreciate any kind of help you could give me.


Best regards.

L1 Bithead

Something I would like to add:
I did a bit more of debug.
The XML string that is generated with is correct:




Using manually that string on the API (the browser version of it), returned this address:




And finally, with that address, I did got on the browser the rule displayed:


This XML file does not appear to have any style information associated with it. The document tree is shown below.
<response cmd="status" status="success">
      <entry name="DenyAll">

So, in other words:
Everything is working on the XML string generation of the

I'll keep debugging... Wish me luck :)

L0 Member

Sad to see your effort elicits no response...  Seems a lame forum group.  Hardly worth the time to register.


Your's is the most technical I've seen on this group and I have one regarding ansible panos_import error but I doubt it would get any love in this desert...


Good luck, alejandro


L1 Bithead

Yeah, I werent able to fix it, so I moved to other stuff.
I didn't want to spend more time on this.

I will return to fixing this some day, but right now I need to start doing the real automation.

Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the Live Community as a whole!

The Live Community thanks you for your participation!