For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Samir's avatar
Apr 10, 2024

Generate CSR via Ansible script

Hi All,

I am looking some guidance to generate CSR in LB device via ansible. tried many option but unable to proceed. Infact unable to use module ansible 'bigip_certificate_csr'. How you guys are doing this part. 

---
- name: Generate CSR on F5 BIG-IP
  hosts: f5_devices
  gather_facts: no
  connection: local

  tasks:
    - name: Generate CSR
      bigip_certificate_csr:
        name: "{{ csr_name }}"  # Name for the CSR
        common_name: "{{ common_name }}"  # Common Name (e.g., example.com)
        partition: "{{ partition }}"  # Partition where the certificate will be stored
        country: "{{ country }}"  # Country code (e.g., US)
        state: "{{ state }}"  # State or province name
        locality: "{{ locality }}"  # Locality or city name
        organization: "{{ organization }}"  # Organization name
        organization_unit: "{{ organization_unit }}"  # Organization unit name
        private_key_path: "/path/to/private_key.key"  # Path to private key file on F5
        overwrite: no  # Whether to overwrite existing CSR if one exists
      delegate_to: localhost

  vars:
    csr_name: "example_csr"  # Name for the CSR
    common_name: "example.com"  # Common Name (e.g., example.com)
    partition: "Common"  # Partition where the certificate will be stored
    country: "US"  # Country code (e.g., US)
    state: "California"  # State or province name
    locality: "San Francisco"  # Locality or city name
    organization: "Example Corp"  # Organization name
    organization_unit: "IT"  # Organization unit name

Thanks,

 

1 Reply

  • Hi,

    with latest Ansible version 9 you can use bigip_ssl_csr

    See documentaion below:

    imperative:

    https://clouddocs.f5.com/products/orchestration/ansible/devel/modules/bigip_ssl_csr_module.html#bigip-ssl-csr-module-3

    declarative:

    https://clouddocs.f5.com/products/orchestration/ansible/devel/f5_bigip/modules_2_0/bigip_ssl_csr_module.html#bigip-ssl-csr-module-2

     

    If not the latest version, what version are you using?