2020-02-02 13:54:28 +01:00
|
|
|
---
|
2018-10-24 12:51:45 +02:00
|
|
|
- name: Generate privatekey1 - standard
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey1'
|
2019-06-06 15:58:51 +10:00
|
|
|
register: privatekey1_result
|
2018-10-24 12:51:45 +02:00
|
|
|
|
2019-11-20 21:02:26 +01:00
|
|
|
- name: Generate privatekey1 - standard (idempotent)
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey1'
|
|
|
|
register: privatekey1_idem_result
|
|
|
|
|
2018-10-24 12:51:45 +02:00
|
|
|
- name: Generate privatekey2 - size 2048
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey2'
|
|
|
|
size: 2048
|
|
|
|
|
|
|
|
- name: Generate privatekey3 - type dsa
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey3'
|
|
|
|
type: dsa
|
|
|
|
|
|
|
|
- name: Generate privatekey4 - standard
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey4'
|
|
|
|
|
|
|
|
- name: Delete privatekey4 - standard
|
|
|
|
openssh_keypair:
|
|
|
|
state: absent
|
|
|
|
path: '{{ output_dir }}/privatekey4'
|
|
|
|
|
2019-03-05 18:07:43 +02:00
|
|
|
- name: Generate privatekey5 - standard
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey5'
|
|
|
|
register: publickey_gen
|
|
|
|
|
2019-06-24 21:45:49 +02:00
|
|
|
- name: Generate privatekey6
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey6'
|
|
|
|
type: rsa
|
|
|
|
|
|
|
|
- name: Regenerate privatekey6 via force
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey6'
|
|
|
|
type: rsa
|
|
|
|
force: yes
|
|
|
|
register: output_regenerated_via_force
|
|
|
|
|
|
|
|
- name: Create broken key
|
|
|
|
copy:
|
|
|
|
dest: '{{ item }}'
|
|
|
|
content: ''
|
|
|
|
mode: '0700'
|
|
|
|
loop:
|
|
|
|
- '{{ output_dir }}/privatekeybroken'
|
|
|
|
- '{{ output_dir }}/privatekeybroken.pub'
|
|
|
|
|
2020-02-02 13:54:28 +01:00
|
|
|
- name: Regenerate broken key - should fail
|
2019-06-24 21:45:49 +02:00
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekeybroken'
|
|
|
|
type: rsa
|
|
|
|
register: output_broken
|
2020-02-02 13:54:28 +01:00
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Regenerate broken key with force
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekeybroken'
|
|
|
|
type: rsa
|
|
|
|
force: yes
|
|
|
|
register: output_broken_force
|
2019-06-24 21:45:49 +02:00
|
|
|
|
|
|
|
- name: Generate read-only private key
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekeyreadonly'
|
|
|
|
type: rsa
|
|
|
|
mode: '0200'
|
|
|
|
|
|
|
|
- name: Regenerate read-only private key via force
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekeyreadonly'
|
|
|
|
type: rsa
|
|
|
|
force: yes
|
|
|
|
register: output_read_only
|
|
|
|
|
2019-08-11 01:57:35 +03:00
|
|
|
- name: Generate privatekey7 - standard with comment
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey7'
|
|
|
|
comment: 'test@privatekey7'
|
|
|
|
register: privatekey7_result
|
|
|
|
|
|
|
|
- name: Modify privatekey7 comment
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey7'
|
|
|
|
comment: 'test_modified@privatekey7'
|
|
|
|
register: privatekey7_modified_result
|
|
|
|
|
2019-12-02 09:12:38 +02:00
|
|
|
- name: Generate password protected key
|
|
|
|
command: 'ssh-keygen -f {{ output_dir }}/privatekey8 -N password'
|
|
|
|
|
2020-02-02 13:54:28 +01:00
|
|
|
- name: Try to modify the password protected key - should fail
|
2019-12-02 09:12:38 +02:00
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey8'
|
|
|
|
register: privatekey8_result
|
2020-02-02 13:54:28 +01:00
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Try to modify the password protected key with force=yes
|
|
|
|
openssh_keypair:
|
|
|
|
path: '{{ output_dir }}/privatekey8'
|
|
|
|
force: yes
|
|
|
|
register: privatekey8_result_force
|
2019-12-02 09:12:38 +02:00
|
|
|
|
2018-10-24 12:51:45 +02:00
|
|
|
- import_tasks: ../tests/validate.yml
|