Open SudarshanVK opened 1 year ago
This is related to the issue here.
https://github.com/F5Networks/f5-ansible/issues/2058
the proposed solution by @fairytaletrash actually works. Reposting the solution here for reference
Modifying the method read_current_from_device in the file f5_modules/plugins/modules/bigip_ssl_key_cert.py replace response[sourcePath] with response[fullPath] resolved my issue locally.
Hi @SudarshanVK,
I tested to import cert and key via the GUI and after I tried the following playbook without any issue:
- hosts: all
collections:
- f5networks.f5_modules
connection: local
vars:
provider:
server: "X.X.X.X"
user: "admin"
password: "mysecretpassword"
server_port: 443
validate_certs: no
no_f5_teem: yes
tasks:
- name: Import both key and cert
bigip_ssl_key_cert:
key_content: "{{ lookup('file', 'key-selfsigned.key') }}"
key_name: test1
cert_content: "{{ lookup('file', 'cert-selfsigned.crt') }}"
cert_name: test1
state: present
provider: "{{ provider }}"
delegate_to: localhost
The output:
PLAY [all] *********************************************************************
TASK [Gathering Facts] *********************************************************
ok: [X.X.X.X]
TASK [Import both key and cert] ************************************************
changed: [X.X.X.X -> localhost]
PLAY RECAP *********************************************************************
X.X.X.X : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Does below Task works for remove Key n cert file? Please share the details as we don't have testing environemts. Please help
- name: Import both key and cert
bigip_ssl_key_cert:
key_name: test1_remove
cert_name: test1_remove
state: absent
provider: "{{ provider }}"
delegate_to: localhost
Issue still present in 1.30.1 and easily repro-able.
[penghon@devops ansible]$ ansible-galaxy collection list | grep -ai f5 f5networks.f5_modules 1.30.1
Import cert/key via GUI, then make sure you specify a different cert and key when you upload via this module:
TASK [Upload cert and key to BIG-IP] **
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'sourcePath'
fatal: [
The issue goes away if you are uploading the cert and key with key_name and cert_name that are different from the existing cert/key pair.
COMPONENT NAME
[](module: bigip_ssl_key_cert)
Environment
ANSIBLE VERSION
BIGIP VERSION
CONFIGURATION
OS / ENVIRONMENT
MacOS and Ansible Tower = Ansible Automation Platform Controller 4.4.1
SUMMARY
module bigip_ssl_key_cert has error trying to replace existing certificate. stack trace reports "KeyError: 'sourcePath'"
STEPS TO REPRODUCE
The issue occurs when you try to replace a cert/key which was manually imported via the UI in the first place.
Step 1: Import the Key and cert into the LB. Step 2: Try to import the key and cert into the LB using the bigip_ssl_key_cert module.
Note:- If the cert and key were originally imported via Ansible using the module, the error does not occur.
EXPECTED RESULTS
I would expect for Ansible to say Ok if the cert and key content has not changed. Or import the new cert and key if it has.
ACTUAL RESULTS