| --- |
| - name: Ensure key pair storage |
| become: yes |
| local_action: file path=/etc/maas/.ssh owner=root group=root mode="0755" state=directory |
| |
| - name: Validate existing key pair |
| become: yes |
| local_action: stat path=/etc/maas/.ssh/cord_rsa |
| register: key_pair |
| |
| - name: Generate key pair |
| become: yes |
| local_action: command ssh-keygen -b 2048 -t rsa -N "" -C cord@cord.lab -f /etc/maas/.ssh/cord_rsa |
| when: not key_pair.stat.exists |
| |
| - name: Ensure privacy of key pair |
| become: yes |
| local_action: file path="/etc/maas/.ssh/{{item.name}}" mode="{{item.mode}}" owner=root group=root |
| with_items: |
| - { "name": "cord_rsa", "mode": "0644" } |
| - { "name": "cord_rsa.pub", "mode": "0644" } |