0

I'm using ansible os_keypair module towards Openstack, through AWX, to create a new keypair:

- hosts: localhost
  tasks:

  - name: Create new keypair, ask for the name in survey 
    os_keypair:
      cloud: rhosp
      state: present
      name: "{{ survey_keypair_name }}"
    register: result

  - name: Show only private key to copy it in .pem
    debug: var=result.key.private_key

When creating a new keypair from Horizon I can download the private_key.pem. How can I retrieve that through ansible module?

Thanks to the register/debug modules I can see output in job execution and copy-paste it manually to a file, but it's a ugly one-line output and it would be nice to have it already in file format.

Any idea?

1 Answers1

0

Ok, sorry, the answer was somehow hidden here: Why is module os_keypair not returning private_key?

I removed the debug task and added the local_action: module: copy one.
The key will be downloaded inside awx_task docker container on AWX host, while I need it also locally on my desktop, I will get it somehow (out of the scope of the question).