Skip to content

TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType #67

@vchatela

Description

@vchatela

PROBLEM SUMMARY
Using the same example as described in ansible galaxy, I get error on undocumented parameter.

STEPS TO REPRODUCE
When using the following code:

---
# Enroll Platform certificate using OAuth authentication (for modern Venafi TPP)
- name: venafi_certificate_tpp_oauth
  hosts: localhost
  gather_facts: no
  connection: local
  vars_files:
    - group_vars/all/vault.yml
    - group_vars/all/vars.yml
  vars:
    client_id: "miam-capabilities"
    scope: "certificate:discover,manage,revoke"
  tasks:
     - name: Request certificate using OAuth token
        venafi.machine_identity.venafi_certificate:
          url: '{{ venafi_url }}'
          access_token: '{{ oauth_response.json.access_token }}'
          zone: '{{ venafi_zone }}'
          privatekey_path: "./artefacts/server.key"
          common_name: "demo-val-nocsr-ansible.airfrance.fr"
          alt_name: "DNS:www.demo-val-nocsr-ansible.airfrance.fr"
          csr_origin: service
          cert_path: '/tmp'
          before_expired_hours: 0  # Accept even short-lived test certificates (1 hour)
          force: false  # Don't force renewal if certificate is still valid
        register: cert_result

I get:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

While the documentation doesn't mention any path.

EXPECTED RESULTS
When using CSR I don't get any issues:

---
# Enroll Platform certificate using OAuth authentication (for modern Venafi TPP)
- name: venafi_certificate_tpp_oauth
  hosts: localhost
  gather_facts: no
  connection: local
  vars_files:
    - group_vars/all/vault.yml
    - group_vars/all/vars.yml
  vars:
    client_id: "miam-capabilities"
    scope: "certificate:discover,manage,revoke"
  tasks:
    - name: Request certificate using OAuth token
          venafi.machine_identity.venafi_certificate:
            url: '{{ venafi_url }}'
            access_token: '{{ oauth_response.json.access_token }}'
            zone: '{{ venafi_zone }}'
            common_name: 'demo-val-ansible.airfrance.fr'
            csr_origin: provided
            csr_path: "./artefacts/server.csr"
            cert_path: "./artefacts/server.crt"
            chain_path: "./artefacts/server-chain.crt"
            before_expired_hours: 0  # Accept even short-lived test certificates (1 hour)
            force: false  # Don't force renewal if certificate is still valid
          register: cert_result

ENVIRONMENT DETAILS
I am using

$ ansible --version
ansible [core 2.16.3]
  config file = None
  configured module search path = ['/home/valentinc/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/valentinc/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
$ ansible-galaxy collection list | grep venafi
venafi.machine_identity                  1.1.1
$ pip3 show vcert
Name: vcert
Version: 0.18.1
Summary: Python client library for Venafi Trust Protection Platform and Venafi Cloud.  
Home-page: https://github.com/Venafi/vcert-python
Author: Venafi, Inc.
Author-email: [email protected]
License: ASL
Location: /home/valentinc/.local/lib/python3.12/site-packages
Requires: cryptography, pynacl, python-dateutil, requests, ruamel.yaml, six
Required-by:

Thanks for support !

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions