Skip to content

Commit

Permalink
[minor_change] Revert to first commit's solution which enables relati…
Browse files Browse the repository at this point in the history
…ve path for private key. Modify integration test for ansible-aci httpapi plugin.
  • Loading branch information
gmicol authored and lhercot committed Jun 13, 2024
1 parent a5f13bd commit 19673e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
14 changes: 1 addition & 13 deletions plugins/httpapi/aci.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def cert_auth(self, method, path, payload=""):
else:
sig_key = load_privatekey(FILETYPE_PEM, self.connection_parameters.get("private_key"))
except Exception:
private_key_file_path = self.create_abspath(self.params.get("working_directory"), self.connection_parameters.get("private_key"))
private_key_file_path = os.path.abspath(os.path.join(self.params.get("working_directory"), self.connection_parameters.get("private_key")))
if os.path.exists(private_key_file_path):
try:
permission = "r"
Expand Down Expand Up @@ -324,15 +324,3 @@ def cert_auth(self, method, path, payload=""):
+ "APIC-Request-Signature={0}".format(to_native(base64.b64encode(sig_signature)))
)
return headers

def create_abspath(self, working_dir, file):
"""
Works if variable 'file' is:
- a filename which is in the same working directory as the ansible playbook,
- a relative path of the file that is either in the same folder or an adjacent folder as the ansible playbook,
- an absolute path of the file.
Doesn't work for more complex folder structures.
"""
l = len(file.split("/"))
s = ("/").join(".." for i in range(l - 1))
return os.path.abspath(os.path.join(working_dir, s, file))
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,18 @@
state: present
register: op1_task_private_key_add_tenant

- name: Delete Tenant with password and private key relative path in the task (private_key takes precedence)
- name: Delete Tenant with password and private key absolute path in the task (private_key takes precedence)
cisco.aci.aci_tenant:
<<: *aci_info
private_key: '{{ role_path }}/pki/admin.key'
tenant: ansible_test
state: absent
register: op1_task_private_key_filename_delete_tenant

- name: Create Tenant with password and private key relative in the task (Check for execution on the provided aci_hostname with no attempts at re-connection)
- name: Create Tenant with password and private key relative path in the task (Check for execution on the provided aci_hostname with no attempts at re-connection)
cisco.aci.aci_tenant:
<<: *aci_info
private_key: '{{ role_path }}/pki/admin.key'
private_key: targets/aci_tenant/pki/admin.key
tenant: ansible_test
state: present
register: op1_task_private_key_filename_add_tenant
Expand Down

0 comments on commit 19673e4

Please sign in to comment.