mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
2
test/integration/targets/openssh_keypair/aliases
Normal file
2
test/integration/targets/openssh_keypair/aliases
Normal file
@@ -0,0 +1,2 @@
|
||||
shippable/posix/group1
|
||||
destructive
|
||||
2
test/integration/targets/openssh_keypair/meta/main.yml
Normal file
2
test/integration/targets/openssh_keypair/meta/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- setup_ssh_keygen
|
||||
25
test/integration/targets/openssh_keypair/tasks/main.yml
Normal file
25
test/integration/targets/openssh_keypair/tasks/main.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
- name: Generate privatekey1 - standard
|
||||
connection: local
|
||||
openssh_keypair:
|
||||
path: '{{ output_dir }}/privatekey1'
|
||||
|
||||
- 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'
|
||||
|
||||
- import_tasks: ../tests/validate.yml
|
||||
39
test/integration/targets/openssh_keypair/tests/validate.yml
Normal file
39
test/integration/targets/openssh_keypair/tests/validate.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
- name: Validate privatekey1 (test - RSA key with size 4096 bits)
|
||||
shell: "ssh-keygen -lf {{ output_dir }}/privatekey1 | grep -o -E '^[0-9]+'"
|
||||
register: privatekey1
|
||||
|
||||
- name: Validate privatekey1 (assert - RSA key with size 4096 bits)
|
||||
assert:
|
||||
that:
|
||||
- privatekey1.stdout == '4096'
|
||||
|
||||
|
||||
- name: Validate privatekey2 (test - RSA key with size 2048 bits)
|
||||
shell: "ssh-keygen -lf {{ output_dir }}/privatekey2 | grep -o -E '^[0-9]+'"
|
||||
register: privatekey2
|
||||
|
||||
- name: Validate privatekey2 (assert - RSA key with size 2048 bits)
|
||||
assert:
|
||||
that:
|
||||
- privatekey2.stdout == '2048'
|
||||
|
||||
|
||||
- name: Validate privatekey3 (test - DSA key with size 1024 bits)
|
||||
shell: "ssh-keygen -lf {{ output_dir }}/privatekey3 | grep -o -E '^[0-9]+'"
|
||||
register: privatekey3
|
||||
|
||||
- name: Validate privatekey3 (assert - DSA key with size 4096 bits)
|
||||
assert:
|
||||
that:
|
||||
- privatekey3.stdout == '1024'
|
||||
|
||||
|
||||
- name: Validate privatekey4 (test - Ensure key has been removed)
|
||||
stat:
|
||||
path: '{{ output_dir }}/privatekey4'
|
||||
register: privatekey4
|
||||
|
||||
- name: Validate privatekey4 (assert - Ensure key has been removed)
|
||||
assert:
|
||||
that:
|
||||
- privatekey4.stat.exists == False
|
||||
8
test/integration/targets/setup_ssh_keygen/tasks/main.yml
Normal file
8
test/integration/targets/setup_ssh_keygen/tasks/main.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
- name: Include OS-specific variables
|
||||
include_vars: '{{ ansible_os_family }}.yml'
|
||||
when: not ansible_os_family == "Darwin" and not ansible_os_family == "FreeBSD"
|
||||
|
||||
- name: Install ssh-keygen
|
||||
package:
|
||||
name: '{{ openssh_client_package_name }}'
|
||||
when: not ansible_os_family == "Darwin" and not ansible_os_family == "FreeBSD"
|
||||
@@ -0,0 +1 @@
|
||||
openssh_client_package_name: openssh-client
|
||||
@@ -0,0 +1 @@
|
||||
openssh_client_package_name: openssh-clients
|
||||
1
test/integration/targets/setup_ssh_keygen/vars/Suse.yml
Normal file
1
test/integration/targets/setup_ssh_keygen/vars/Suse.yml
Normal file
@@ -0,0 +1 @@
|
||||
openssh_client_package_name: openssh
|
||||
Reference in New Issue
Block a user