2018-01-21 22:54:12 +01:00
|
|
|
# Copyright (c) 2018, René Moser <mail@renemoser.net>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
---
|
|
|
|
- name: setup
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ vultr_ssh_key_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
- name: verify setup
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is success
|
|
|
|
|
|
|
|
- name: test fail if missing name
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
2018-01-21 22:54:12 +01:00
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
- name: verify test fail if missing name
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is failed
|
|
|
|
- 'result.msg == "missing required arguments: name"'
|
|
|
|
|
|
|
|
- name: test fail if missing params for state=present
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ vultr_ssh_key_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
- name: verify fail if missing params for state=present
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is failed
|
|
|
|
- 'result.msg == "state is present but all of the following are missing: ssh_key"'
|
|
|
|
|
|
|
|
- name: test create ssh key in check mode
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ vultr_ssh_key_name }}"
|
|
|
|
ssh_key: "{{ vultr_ssh_key }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
register: result
|
|
|
|
check_mode: yes
|
|
|
|
- name: verify test create ssh key in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
|
|
|
|
|
|
|
- name: test create ssh key
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ vultr_ssh_key_name }}"
|
|
|
|
ssh_key: "{{ vultr_ssh_key }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
register: result
|
|
|
|
- name: verify test create ssh key
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}'
|
|
|
|
- result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
|
|
|
|
- name: test create ssh key idempotence
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ vultr_ssh_key_name }}"
|
|
|
|
ssh_key: "{{ vultr_ssh_key }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
register: result
|
|
|
|
- name: verify test create ssh key idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}'
|
|
|
|
- result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
|
|
|
|
- name: test update ssh key in check mode
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ vultr_ssh_key_name }}"
|
|
|
|
ssh_key: "{{ vultr_ssh_key2 }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
register: result
|
|
|
|
check_mode: yes
|
|
|
|
- name: verify test update ssh key in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}'
|
|
|
|
- result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
|
|
|
|
- name: test update ssh key
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ vultr_ssh_key_name }}"
|
|
|
|
ssh_key: "{{ vultr_ssh_key2 }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
register: result
|
|
|
|
- name: verify test update ssh key
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}'
|
|
|
|
- result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key2 }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
|
|
|
|
- name: test update ssh key idempotence
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ vultr_ssh_key_name }}"
|
|
|
|
ssh_key: "{{ vultr_ssh_key2 }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
register: result
|
|
|
|
- name: verify test update ssh key idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}'
|
|
|
|
- result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key2 }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
|
|
|
|
- name: test absent ssh key in check mode
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ vultr_ssh_key_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
check_mode: yes
|
|
|
|
- name: verify test absent ssh key in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}'
|
|
|
|
- result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key2 }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
|
|
|
|
- name: test absent ssh key
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ vultr_ssh_key_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
- name: verify test absent ssh key
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_ssh_key.name == '{{ vultr_ssh_key_name }}'
|
|
|
|
- result.vultr_ssh_key.ssh_key == '{{ vultr_ssh_key2 }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
|
|
|
|
- name: test absent ssh key idempotence
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ vultr_ssh_key_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
- name: verify test absent ssh key idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|