Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
e54c45ee
Commit
e54c45ee
authored
Jan 16, 2015
by
Matt Martz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test_rax_keypair role
parent
abac45da
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
267 additions
and
1 deletions
+267
-1
test/integration/cleanup_rax.py
+13
-1
test/integration/rackspace.yml
+3
-0
test/integration/roles/prepare_rax_tests/defaults/main.yml
+3
-0
test/integration/roles/test_rax_keypair/meta/main.yml
+3
-0
test/integration/roles/test_rax_keypair/tasks/main.yml
+245
-0
No files found.
test/integration/cleanup_rax.py
View file @
e54c45ee
...
@@ -90,6 +90,18 @@ def delete_rax_clb(args):
...
@@ -90,6 +90,18 @@ def delete_rax_clb(args):
args
.
assumeyes
)
args
.
assumeyes
)
def
delete_rax_keypair
(
args
):
"""Function for deleting Rackspace Key pairs"""
print
(
"--- Cleaning Key Pairs matching '
%
s'"
%
args
.
match_re
)
for
region
in
pyrax
.
identity
.
services
.
compute
.
regions
:
cs
=
pyrax
.
connect_to_cloudservers
(
region
=
region
)
for
keypair
in
cs
.
keypairs
.
list
():
if
re
.
search
(
args
.
match_re
,
keypair
.
name
):
prompt_and_delete
(
keypair
,
'Delete matching
%
s? [y/n]: '
%
keypair
,
args
.
assumeyes
)
def
main
():
def
main
():
if
not
HAS_PYRAX
:
if
not
HAS_PYRAX
:
raise
SystemExit
(
'The pyrax python module is required for this script'
)
raise
SystemExit
(
'The pyrax python module is required for this script'
)
...
@@ -98,7 +110,7 @@ def main():
...
@@ -98,7 +110,7 @@ def main():
authenticate
()
authenticate
()
delete_rax
(
args
)
delete_rax
(
args
)
delete_rax_clb
(
args
)
delete_rax_clb
(
args
)
delete_rax_keypair
(
args
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
test/integration/rackspace.yml
View file @
e54c45ee
...
@@ -19,6 +19,9 @@
...
@@ -19,6 +19,9 @@
-
role
:
test_rax_meta
-
role
:
test_rax_meta
tags
:
test_rax_meta
tags
:
test_rax_meta
-
role
:
test_rax_keypair
tags
:
test_rax_keypair
-
role
:
test_rax_clb
-
role
:
test_rax_clb
tags
:
test_rax_clb
tags
:
test_rax_clb
...
...
test/integration/roles/prepare_rax_tests/defaults/main.yml
View file @
e54c45ee
...
@@ -4,4 +4,7 @@ rackspace_image_human_id: "ubuntu-1404-lts-trusty-tahr-pvhvm"
...
@@ -4,4 +4,7 @@ rackspace_image_human_id: "ubuntu-1404-lts-trusty-tahr-pvhvm"
rackspace_image_id
:
"
753a7703-4960-488b-aab4-a3cdd4b276dc"
rackspace_image_id
:
"
753a7703-4960-488b-aab4-a3cdd4b276dc"
rackspace_image_name
:
"
Ubuntu
14.04
LTS
(Trusty
Tahr)
(PVHVM)"
rackspace_image_name
:
"
Ubuntu
14.04
LTS
(Trusty
Tahr)
(PVHVM)"
rackspace_flavor
:
"
performance1-1"
rackspace_flavor
:
"
performance1-1"
rackspace_keypair_pub
:
"
ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABAQDymofzvt86DUA6XSSxc7eDHwUNvcOSmUWjB76jFvhYc6PbS5QmTzBtCka1ORdaW0Z2i3EjfFvzA8WvuY3qP/FpIVDL25ZqZHgxSfGN5pbJ2tAeXK165kNPXBuuISrMhmdLFbRZNn6PwKHEmtrtfEQ3w6ay9+MhqlEr0OX2r6bCXLj+f50QnQXamU6Fm4IpkTsb60osvHNi569Dd8cADEv92oLZpNMa8/MPGnlipjauhzNtEDTUeZwtrAQUXe6CzJ0QmIlyKDglDZLuAKU/VRumo1FRsn4AwJnVsbP2CHBPkbNoYt6LhQiQqXypEIWGmIln0dlO6gZTr3dYC4BVGREl"
resource_prefix
:
ansible-testing
resource_prefix
:
ansible-testing
test/integration/roles/test_rax_keypair/meta/main.yml
0 → 100644
View file @
e54c45ee
dependencies
:
-
prepare_tests
-
prepare_rax_tests
test/integration/roles/test_rax_keypair/tasks/main.yml
0 → 100644
View file @
e54c45ee
# ============================================================
-
name
:
Test rax_keypair with no args
rax_keypair
:
ignore_errors
:
true
register
:
rax_keypair
-
name
:
Validate results of rax_keypair with no args
assert
:
that
:
-
rax_keypair|failed
-
rax_keypair.msg == 'missing required arguments
:
name'
# ============================================================
# ============================================================
-
name
:
Test rax_keypair with name
rax_keypair
:
name
:
fail
ignore_errors
:
true
register
:
rax_keypair
-
name
:
Validate results of rax_keypair with no args
assert
:
that
:
-
rax_keypair|failed
-
rax_keypair.msg == 'No credentials supplied!'
# ============================================================
# ============================================================
-
name
:
Test rax_keypair with name and credentials
rax_keypair
:
username
:
"
{{
rackspace_username
}}"
api_key
:
"
{{
rackspace_api_key
}}"
name
:
fail
ignore_errors
:
true
register
:
rax_keypair
-
name
:
Validate results of rax_keypair with name and credentials
assert
:
that
:
-
rax_keypair|failed
-
rax_keypair.msg.startswith('None is not a valid region')
# ============================================================
# ============================================================
-
name
:
Create public key file for tests
copy
:
content
:
"
{{
rackspace_keypair_pub
}}"
dest
:
"
{{
output_dir|expanduser
}}/{{
resource_prefix
}}.pub"
-
name
:
Set variable for public key path
set_fact
:
rackspace_keypair_pub_path
:
"
{{
output_dir|expanduser
}}/{{
resource_prefix
}}.pub"
# ============================================================
# ============================================================
-
name
:
Test rax_keypair with creds, region, name and public_key string
rax_keypair
:
username
:
"
{{
rackspace_username
}}"
api_key
:
"
{{
rackspace_api_key
}}"
region
:
"
{{
rackspace_region
}}"
name
:
"
{{
resource_prefix
}}-1"
public_key
:
"
{{
rackspace_keypair_pub
}}"
register
:
rax_keypair
-
name
:
Validate rax_keypair creds, region, name and public_key string
assert
:
that
:
-
rax_keypair|success
-
rax_keypair|changed
-
rax_keypair.keypair.name == "{{ resource_prefix }}-1"
-
rax_keypair.keypair.public_key == "{{ rackspace_keypair_pub }}"
-
name
:
Delete integration 1
rax_keypair
:
username
:
"
{{
rackspace_username
}}"
api_key
:
"
{{
rackspace_api_key
}}"
region
:
"
{{
rackspace_region
}}"
name
:
"
{{
resource_prefix
}}-1"
public_key
:
"
{{
rackspace_keypair_pub
}}"
state
:
absent
register
:
rax_keypair
-
name
:
Validate delete integration 1
assert
:
that
:
-
rax_keypair|success
-
rax_keypair|changed
-
rax_keypair.keypair.name == "{{ resource_prefix }}-1"
# ============================================================
# ============================================================
-
name
:
Test rax_keypair with creds, region, name and public_key path
rax_keypair
:
username
:
"
{{
rackspace_username
}}"
api_key
:
"
{{
rackspace_api_key
}}"
region
:
"
{{
rackspace_region
}}"
name
:
"
{{
resource_prefix
}}-2"
public_key
:
"
{{
rackspace_keypair_pub_path
}}"
register
:
rax_keypair
-
name
:
Validate rax_keypair creds, region, name and public_key path
assert
:
that
:
-
rax_keypair|success
-
rax_keypair|changed
-
rax_keypair.keypair.name == "{{ resource_prefix }}-2"
-
rax_keypair.keypair.public_key == "{{ rackspace_keypair_pub }}"
-
name
:
Delete integration 2
rax_keypair
:
username
:
"
{{
rackspace_username
}}"
api_key
:
"
{{
rackspace_api_key
}}"
region
:
"
{{
rackspace_region
}}"
name
:
"
{{
resource_prefix
}}-2"
public_key
:
"
{{
rackspace_keypair_pub
}}"
state
:
absent
register
:
rax_keypair
-
name
:
Validate delete integration 2
assert
:
that
:
-
rax_keypair|success
-
rax_keypair|changed
-
rax_keypair.keypair.name == "{{ resource_prefix }}-2"
# ============================================================
# ============================================================
-
name
:
Test rax_keypair with idempotency 1
rax_keypair
:
username
:
"
{{
rackspace_username
}}"
api_key
:
"
{{
rackspace_api_key
}}"
region
:
"
{{
rackspace_region
}}"
name
:
"
{{
resource_prefix
}}-3"
public_key
:
"
{{
rackspace_keypair_pub
}}"
register
:
rax_keypair
-
name
:
Validate rax_keypair with idempotency 1
assert
:
that
:
-
rax_keypair|success
-
rax_keypair|changed
-
rax_keypair.keypair.name == "{{ resource_prefix }}-3"
-
rax_keypair.keypair.public_key == "{{ rackspace_keypair_pub }}"
-
name
:
Test rax_keypair with idempotency 2
rax_keypair
:
username
:
"
{{
rackspace_username
}}"
api_key
:
"
{{
rackspace_api_key
}}"
region
:
"
{{
rackspace_region
}}"
name
:
"
{{
resource_prefix
}}-3"
public_key
:
"
{{
rackspace_keypair_pub
}}"
register
:
rax_keypair
-
name
:
Validate rax_keypair with idempotency 1
assert
:
that
:
-
rax_keypair|success
-
not rax_keypair|changed
-
rax_keypair.keypair.name == "{{ resource_prefix }}-3"
-
rax_keypair.keypair.public_key == "{{ rackspace_keypair_pub }}"
-
name
:
Delete integration 3
rax_keypair
:
username
:
"
{{
rackspace_username
}}"
api_key
:
"
{{
rackspace_api_key
}}"
region
:
"
{{
rackspace_region
}}"
name
:
"
{{
resource_prefix
}}-3"
public_key
:
"
{{
rackspace_keypair_pub
}}"
state
:
absent
register
:
rax_keypair
-
name
:
Validate delete integration 3
assert
:
that
:
-
rax_keypair|success
-
rax_keypair|changed
-
rax_keypair.keypair.name == "{{ resource_prefix }}-3"
# ============================================================
# ============================================================
-
name
:
Test rax_keypair with creds, region and name
rax_keypair
:
username
:
"
{{
rackspace_username
}}"
api_key
:
"
{{
rackspace_api_key
}}"
region
:
"
{{
rackspace_region
}}"
name
:
"
{{
resource_prefix
}}-4"
register
:
rax_keypair
-
name
:
Validate rax_keypair creds, region and name
assert
:
that
:
-
rax_keypair|success
-
rax_keypair|changed
-
rax_keypair.keypair.name == "{{ resource_prefix }}-4"
-
rax_keypair.keypair.private_key is defined
-
rax_keypair.keypair.public_key is defined
-
name
:
Test rax_keypair with creds, region and name idempotency
rax_keypair
:
username
:
"
{{
rackspace_username
}}"
api_key
:
"
{{
rackspace_api_key
}}"
region
:
"
{{
rackspace_region
}}"
name
:
"
{{
resource_prefix
}}-4"
register
:
rax_keypair
-
name
:
Validate rax_keypair creds, region and name
assert
:
that
:
-
rax_keypair|success
-
not rax_keypair|changed
-
rax_keypair.keypair.name == "{{ resource_prefix }}-4"
-
rax_keypair.keypair.private_key is not defined
-
rax_keypair.keypair.public_key is defined
-
name
:
Delete integration 4
rax_keypair
:
username
:
"
{{
rackspace_username
}}"
api_key
:
"
{{
rackspace_api_key
}}"
region
:
"
{{
rackspace_region
}}"
name
:
"
{{
resource_prefix
}}-4"
public_key
:
"
{{
rackspace_keypair_pub
}}"
state
:
absent
register
:
rax_keypair
-
name
:
Validate delete integration 4
assert
:
that
:
-
rax_keypair|success
-
rax_keypair|changed
-
rax_keypair.keypair.name == "{{ resource_prefix }}-4"
# ============================================================
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment