2018-12-23 09:23:31 +00:00
|
|
|
---
|
2017-07-25 11:18:18 +00:00
|
|
|
- name: Validate public key (test - privatekey modulus)
|
2017-12-12 12:35:22 +00:00
|
|
|
shell: 'openssl rsa -noout -modulus -in {{ output_dir }}/privatekey.pem'
|
2017-07-25 11:18:18 +00:00
|
|
|
register: privatekey_modulus
|
|
|
|
|
|
|
|
- name: Validate public key (test - publickey modulus)
|
2017-12-12 12:35:22 +00:00
|
|
|
shell: 'openssl rsa -pubin -noout -modulus < {{ output_dir }}/publickey.pub'
|
2017-07-25 11:18:18 +00:00
|
|
|
register: publickey_modulus
|
|
|
|
|
|
|
|
- name: Validate public key (assert)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- publickey_modulus.stdout == privatekey_modulus.stdout
|
2017-08-21 11:19:41 +00:00
|
|
|
|
|
|
|
- name: Validate public key - OpenSSH format (test - privatekey's publickey)
|
|
|
|
shell: 'ssh-keygen -y -f {{ output_dir }}/privatekey.pem'
|
|
|
|
register: privatekey_publickey
|
2017-11-27 22:58:08 +00:00
|
|
|
when: cryptography_version.stdout is version('1.4.0', '>=')
|
2017-08-21 11:19:41 +00:00
|
|
|
|
|
|
|
- name: Validate public key - OpenSSH format (test - publickey)
|
|
|
|
slurp:
|
|
|
|
src: '{{ output_dir }}/publickey-ssh.pub'
|
|
|
|
register: publickey
|
2017-11-27 22:58:08 +00:00
|
|
|
when: cryptography_version.stdout is version('1.4.0', '>=')
|
2017-08-21 11:19:41 +00:00
|
|
|
|
|
|
|
- name: Validate public key - OpenSSH format (assert)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- privatekey_publickey.stdout == '{{ publickey.content|b64decode }}'
|
2017-11-27 22:58:08 +00:00
|
|
|
when: cryptography_version.stdout is version('1.4.0', '>=')
|
2017-08-21 11:19:41 +00:00
|
|
|
|
2017-11-28 08:38:47 +00:00
|
|
|
- name: Validate public key - OpenSSH format - test idempotence (issue 33256)
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-28 18:26:45 +00:00
|
|
|
- publickey_ssh_idempotence is not changed
|
|
|
|
when: cryptography_version.stdout is version('1.4.0', '>=')
|
2017-11-28 08:38:47 +00:00
|
|
|
|
2017-08-21 11:19:41 +00:00
|
|
|
- name: Validate publickey2 (test - Ensure key has been removed)
|
|
|
|
stat:
|
|
|
|
path: '{{ output_dir }}/publickey2.pub'
|
|
|
|
register: publickey2
|
|
|
|
|
|
|
|
- name: Validate publickey2 (assert - Ensure key has been removed)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- publickey2.stat.exists == False
|
|
|
|
|
|
|
|
|
|
|
|
- name: Validate publickey3 (test - privatekey modulus)
|
2017-12-12 12:35:22 +00:00
|
|
|
shell: 'openssl rsa -noout -modulus -in {{ output_dir }}/privatekey3.pem -passin pass:ansible'
|
2017-08-21 11:19:41 +00:00
|
|
|
register: privatekey3_modulus
|
2017-11-27 22:58:08 +00:00
|
|
|
when: openssl_version.stdout is version('0.9.8zh', '>=')
|
2017-08-21 11:19:41 +00:00
|
|
|
|
|
|
|
- name: Validate publickey3 (test - publickey modulus)
|
2017-12-12 12:35:22 +00:00
|
|
|
shell: 'openssl rsa -pubin -noout -modulus < {{ output_dir }}/publickey3.pub'
|
2017-08-21 11:19:41 +00:00
|
|
|
register: publickey3_modulus
|
2017-11-27 22:58:08 +00:00
|
|
|
when: openssl_version.stdout is version('0.9.8zh', '>=')
|
2017-08-21 11:19:41 +00:00
|
|
|
|
|
|
|
- name: Validate publickey3 (assert)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- publickey3_modulus.stdout == privatekey3_modulus.stdout
|
2017-11-27 22:58:08 +00:00
|
|
|
when: openssl_version.stdout is version('0.9.8zh', '>=')
|
2017-08-21 11:19:41 +00:00
|
|
|
|
|
|
|
- name: Validate publickey3 idempotence (assert)
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- publickey3_idempotence is not changed
|
2017-11-25 03:29:07 +00:00
|
|
|
|
|
|
|
- name: Validate publickey4 (test - privatekey modulus)
|
2017-12-12 12:35:22 +00:00
|
|
|
shell: 'openssl rsa -noout -modulus -in {{ output_dir }}/privatekey.pem'
|
2017-11-25 03:29:07 +00:00
|
|
|
register: privatekey4_modulus
|
2017-11-27 22:58:08 +00:00
|
|
|
when: openssl_version.stdout is version('0.9.8zh', '>=')
|
2017-11-25 03:29:07 +00:00
|
|
|
|
|
|
|
- name: Validate publickey4 (test - publickey modulus)
|
2017-12-12 12:35:22 +00:00
|
|
|
shell: 'openssl rsa -pubin -noout -modulus < {{ output_dir }}/publickey4.pub'
|
2017-11-25 03:29:07 +00:00
|
|
|
register: publickey4_modulus
|
2017-11-27 22:58:08 +00:00
|
|
|
when: openssl_version.stdout is version('0.9.8zh', '>=')
|
2017-11-25 03:29:07 +00:00
|
|
|
|
|
|
|
- name: Validate publickey4 (assert)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- publickey4_modulus.stdout == privatekey4_modulus.stdout
|
2017-11-27 22:58:08 +00:00
|
|
|
when: openssl_version.stdout is version('0.9.8zh', '>=')
|
2018-12-23 09:23:31 +00:00
|
|
|
|
|
|
|
- name: Validate public key 5 (test - privatekey's pubkey)
|
|
|
|
command: 'openssl ec -in {{ output_dir }}/privatekey5.pem -pubout'
|
|
|
|
register: privatekey5_pubkey
|
|
|
|
|
|
|
|
- name: Validate public key 5 (test - publickey pubkey)
|
|
|
|
# Fancy way of writing "cat {{ output_dir }}/publickey5.pub"
|
|
|
|
command: 'openssl ec -pubin -in {{ output_dir }}/publickey5.pub -pubout'
|
|
|
|
register: publickey5_pubkey
|
|
|
|
|
|
|
|
- name: Validate public key 5 (assert)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- publickey5_pubkey.stdout == privatekey5_pubkey.stdout
|