2015-05-03 14:06:30 +00:00
|
|
|
---
|
|
|
|
- name: setup cleanup
|
2017-05-09 03:32:11 +00:00
|
|
|
cs_sshkeypair: name=first-sshkey state=absent
|
|
|
|
|
|
|
|
- name: setup cleanup
|
|
|
|
cs_sshkeypair: name=second-sshkey state=absent
|
|
|
|
|
2015-05-03 14:06:30 +00:00
|
|
|
- name: test fail on missing name
|
|
|
|
action: cs_sshkeypair
|
|
|
|
ignore_errors: true
|
|
|
|
register: sshkey
|
|
|
|
- name: verify results of fail on missing name
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- sshkey is failed
|
2015-08-19 19:39:58 +00:00
|
|
|
- "sshkey.msg == 'missing required arguments: name'"
|
2015-05-03 14:06:30 +00:00
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test ssh key creation in check mode
|
|
|
|
cs_sshkeypair:
|
|
|
|
name: "first-sshkey"
|
|
|
|
register: sshkey
|
|
|
|
check_mode: true
|
|
|
|
- name: verify results of ssh key creation in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- sshkey is successful
|
|
|
|
- sshkey is changed
|
2017-05-26 10:19:47 +00:00
|
|
|
|
2015-05-03 14:06:30 +00:00
|
|
|
- name: test ssh key creation
|
2017-05-09 03:32:11 +00:00
|
|
|
cs_sshkeypair:
|
|
|
|
name: "first-sshkey"
|
2015-05-03 14:06:30 +00:00
|
|
|
register: sshkey
|
|
|
|
- name: verify results of ssh key creation
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- sshkey is successful
|
|
|
|
- sshkey is changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- sshkey.fingerprint is defined and sshkey.fingerprint != ""
|
|
|
|
- sshkey.private_key is defined and sshkey.private_key != ""
|
2017-05-09 03:32:11 +00:00
|
|
|
- sshkey.name == "first-sshkey"
|
2015-05-03 14:06:30 +00:00
|
|
|
|
|
|
|
- name: test ssh key creation idempotence
|
2017-05-09 03:32:11 +00:00
|
|
|
cs_sshkeypair:
|
|
|
|
name: "first-sshkey"
|
2015-05-03 14:06:30 +00:00
|
|
|
register: sshkey2
|
|
|
|
- name: verify results of ssh key creation idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- sshkey2 is successful
|
|
|
|
- sshkey2 is not changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- sshkey2.fingerprint is defined and sshkey2.fingerprint == sshkey.fingerprint
|
|
|
|
- sshkey2.private_key is not defined
|
2017-05-09 03:32:11 +00:00
|
|
|
- sshkey2.name == "first-sshkey"
|
2015-05-03 14:06:30 +00:00
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test replace ssh public key in check mode
|
|
|
|
cs_sshkeypair:
|
|
|
|
name: "first-sshkey"
|
|
|
|
public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDsTI7KJZ8tz/CwQIrSol41c6s3vzkGYCMI8o7P9Et48UG9eRoGaMaGYaTvBTj/VQrD7cfurI6Bn0HTT3FLK3OHOweyelm9rIiQ2hjkSl+2lIKWHu992GO58E5Gcy9yYW4sHGgGLNZkPBKrrj0w7lhmiHjPtVnf+2+7Ix1WOO2/HXPcAHhsX/AlyItDewIL4mr/BT83vq0202sPCiM2cFQJl+5WGwS1wYYK8d167cspsmdyX7OyAFCUB0vueuqjE8MFqJvyIJR9y8Lj9Ny71pSV5/QWrXUgELxMYOKSby3gHkxcIXgYBMFLl4DipRTO74OWQlRRaOlqXlOOQbikcY4T rene.moser@swisstxt.ch"
|
|
|
|
register: sshkey2
|
|
|
|
check_mode: true
|
|
|
|
- name: verify results of replace ssh public key in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- sshkey2 is successful
|
|
|
|
- sshkey2 is changed
|
2017-05-26 10:19:47 +00:00
|
|
|
- sshkey2.fingerprint is defined and sshkey2.fingerprint == sshkey.fingerprint
|
|
|
|
- sshkey2.private_key is not defined
|
|
|
|
- sshkey2.name == "first-sshkey"
|
|
|
|
|
2015-05-03 14:06:30 +00:00
|
|
|
- name: test replace ssh public key
|
2017-05-09 03:32:11 +00:00
|
|
|
cs_sshkeypair:
|
|
|
|
name: "first-sshkey"
|
|
|
|
public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDsTI7KJZ8tz/CwQIrSol41c6s3vzkGYCMI8o7P9Et48UG9eRoGaMaGYaTvBTj/VQrD7cfurI6Bn0HTT3FLK3OHOweyelm9rIiQ2hjkSl+2lIKWHu992GO58E5Gcy9yYW4sHGgGLNZkPBKrrj0w7lhmiHjPtVnf+2+7Ix1WOO2/HXPcAHhsX/AlyItDewIL4mr/BT83vq0202sPCiM2cFQJl+5WGwS1wYYK8d167cspsmdyX7OyAFCUB0vueuqjE8MFqJvyIJR9y8Lj9Ny71pSV5/QWrXUgELxMYOKSby3gHkxcIXgYBMFLl4DipRTO74OWQlRRaOlqXlOOQbikcY4T rene.moser@swisstxt.ch"
|
2015-05-03 14:06:30 +00:00
|
|
|
register: sshkey3
|
|
|
|
- name: verify results of replace ssh public key
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- sshkey3 is successful
|
|
|
|
- sshkey3 is changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- sshkey3.fingerprint is defined and sshkey3.fingerprint != sshkey2.fingerprint
|
|
|
|
- sshkey3.private_key is not defined
|
2017-05-09 03:32:11 +00:00
|
|
|
- sshkey3.name == "first-sshkey"
|
2015-05-03 14:06:30 +00:00
|
|
|
|
|
|
|
- name: test replace ssh public key idempotence
|
2017-05-09 03:32:11 +00:00
|
|
|
cs_sshkeypair:
|
|
|
|
name: "first-sshkey"
|
|
|
|
public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDsTI7KJZ8tz/CwQIrSol41c6s3vzkGYCMI8o7P9Et48UG9eRoGaMaGYaTvBTj/VQrD7cfurI6Bn0HTT3FLK3OHOweyelm9rIiQ2hjkSl+2lIKWHu992GO58E5Gcy9yYW4sHGgGLNZkPBKrrj0w7lhmiHjPtVnf+2+7Ix1WOO2/HXPcAHhsX/AlyItDewIL4mr/BT83vq0202sPCiM2cFQJl+5WGwS1wYYK8d167cspsmdyX7OyAFCUB0vueuqjE8MFqJvyIJR9y8Lj9Ny71pSV5/QWrXUgELxMYOKSby3gHkxcIXgYBMFLl4DipRTO74OWQlRRaOlqXlOOQbikcY4T rene.moser@swisstxt.ch"
|
2015-05-03 14:06:30 +00:00
|
|
|
register: sshkey4
|
|
|
|
- name: verify results of ssh public key idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- sshkey4 is successful
|
|
|
|
- sshkey4 is not changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- sshkey4.fingerprint is defined and sshkey4.fingerprint == sshkey3.fingerprint
|
|
|
|
- sshkey4.private_key is not defined
|
2017-05-09 03:32:11 +00:00
|
|
|
- sshkey4.name == "first-sshkey"
|
|
|
|
|
|
|
|
- name: setup ssh key with name "second-sshke"
|
|
|
|
cs_sshkeypair:
|
|
|
|
name: "second-sshkey"
|
|
|
|
|
|
|
|
- name: test different but exisitng name but same ssh public key as first-sshkey
|
|
|
|
cs_sshkeypair:
|
|
|
|
name: "second-sshkey"
|
|
|
|
public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDsTI7KJZ8tz/CwQIrSol41c6s3vzkGYCMI8o7P9Et48UG9eRoGaMaGYaTvBTj/VQrD7cfurI6Bn0HTT3FLK3OHOweyelm9rIiQ2hjkSl+2lIKWHu992GO58E5Gcy9yYW4sHGgGLNZkPBKrrj0w7lhmiHjPtVnf+2+7Ix1WOO2/HXPcAHhsX/AlyItDewIL4mr/BT83vq0202sPCiM2cFQJl+5WGwS1wYYK8d167cspsmdyX7OyAFCUB0vueuqjE8MFqJvyIJR9y8Lj9Ny71pSV5/QWrXUgELxMYOKSby3gHkxcIXgYBMFLl4DipRTO74OWQlRRaOlqXlOOQbikcY4T rene.moser@swisstxt.ch"
|
|
|
|
register: sshkey
|
|
|
|
- name: verify test different but exisitng name but same ssh public key as first-sshkey
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- sshkey is successful
|
|
|
|
- sshkey is changed
|
2017-05-09 03:32:11 +00:00
|
|
|
- sshkey.fingerprint is defined and sshkey.fingerprint == sshkey4.fingerprint
|
|
|
|
- sshkey.private_key is not defined
|
|
|
|
- sshkey.name == "second-sshkey"
|
2015-05-03 14:06:30 +00:00
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test ssh key absent in check mode
|
|
|
|
cs_sshkeypair: name=second-sshkey state=absent
|
|
|
|
register: sshkey5
|
|
|
|
check_mode: true
|
|
|
|
- name: verify result of key absent in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- sshkey5 is successful
|
|
|
|
- sshkey5 is changed
|
2017-05-26 10:19:47 +00:00
|
|
|
- sshkey5.fingerprint is defined and sshkey5.fingerprint == sshkey3.fingerprint
|
|
|
|
- sshkey5.private_key is not defined
|
|
|
|
- sshkey5.name == "second-sshkey"
|
|
|
|
|
2015-05-03 14:06:30 +00:00
|
|
|
- name: test ssh key absent
|
2017-05-09 03:32:11 +00:00
|
|
|
cs_sshkeypair: name=second-sshkey state=absent
|
2015-05-03 14:06:30 +00:00
|
|
|
register: sshkey5
|
|
|
|
- name: verify result of key absent
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- sshkey5 is successful
|
|
|
|
- sshkey5 is changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- sshkey5.fingerprint is defined and sshkey5.fingerprint == sshkey3.fingerprint
|
|
|
|
- sshkey5.private_key is not defined
|
2017-05-09 03:32:11 +00:00
|
|
|
- sshkey5.name == "second-sshkey"
|
2015-05-03 14:06:30 +00:00
|
|
|
|
|
|
|
- name: test ssh key absent idempotence
|
2017-05-09 03:32:11 +00:00
|
|
|
cs_sshkeypair: name=second-sshkey state=absent
|
2015-05-03 14:06:30 +00:00
|
|
|
register: sshkey6
|
|
|
|
- name: verify result of ssh key absent idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- sshkey6 is successful
|
|
|
|
- sshkey6 is not changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- sshkey6.fingerprint is not defined
|
|
|
|
- sshkey6.private_key is not defined
|
|
|
|
- sshkey6.name is not defined
|