Cannot install certificate
Closed this issue · 1 comments
byxfdkbgpdzr commented
Playbook:
- name: Aruba switch config
hosts: aos
gather_facts: no
vars:
ansible_ssh_host_key_checking: False
tasks:
- name: Get content of local file
set_fact:
cert: "{{ lookup('file','/certs/switch_csr/' + inventory_hostname + '.cer') }}"
- name: Install cert
collections:
- arubanetworks.aos_switch
arubaoss_config:
commands:
- crypto pki install-signed-certificate
- "{{ cert }}"
- "show crypto pki local-certificate {{ inventory_hostname }}"
register: out_cert
- debug: var=cert
- debug: var=out_cert
Looking to install a certificate that was generated from a CSR, however it just times out.
fatal: [switch1.local.com]: FAILED! => {"changed": false, "command": "crypto pki install-signed-certificate", "msg": "command timeout triggered, timeout value is 120 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide.", "rc": -32603}
Is this supported and I'm approaching it wrong? Or is this not supported?
byxfdkbgpdzr commented
I was able to resolve this with a few changes:
---
- name: Aruba switch config
hosts: aos
gather_facts: no
vars:
ansible_ssh_host_key_checking: False
tasks:
- name: Convert files dos2unix
shell: |
cp /certs/switch_csr/{{ inventory_hostname }}.cer /certs/switch_csr/{{ inventory_hostname }}.cer.orig
dos2unix /certs/switch_csr/{{ inventory_hostname }}.cer
- name: Get content of local file
set_fact:
cert: "{{ lookup('file','/certs/switch_csr/' + inventory_hostname + '.cer') }}"
- name: Install cert
collections:
- arubanetworks.aos_switch
arubaoss_command:
commands:
- command: "conf t"
- command: "crypto pki install-signed-certificate"
prompt:
- '.*paste*'
answer:
- "{{ cert + '\n' }}"