mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #10916 from chrismeyersfsu/feature-integration_azure
add azure integration tests
This commit is contained in:
commit
93be064aa4
6 changed files with 95 additions and 1 deletions
|
@ -105,13 +105,16 @@ test_tags:
|
||||||
[ "$$(ansible-playbook --list-tasks --skip-tags tag test_tags.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) | fgrep Task_with | xargs)" = "Task_with_always_tag TAGS: [always] Task_without_tag TAGS: []" ]
|
[ "$$(ansible-playbook --list-tasks --skip-tags tag test_tags.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) | fgrep Task_with | xargs)" = "Task_with_always_tag TAGS: [always] Task_without_tag TAGS: []" ]
|
||||||
|
|
||||||
|
|
||||||
cloud: amazon rackspace
|
cloud: amazon rackspace azure
|
||||||
|
|
||||||
cloud_cleanup: amazon_cleanup rackspace_cleanup
|
cloud_cleanup: amazon_cleanup rackspace_cleanup
|
||||||
|
|
||||||
amazon_cleanup:
|
amazon_cleanup:
|
||||||
python cleanup_ec2.py -y --match="^$(CLOUD_RESOURCE_PREFIX)"
|
python cleanup_ec2.py -y --match="^$(CLOUD_RESOURCE_PREFIX)"
|
||||||
|
|
||||||
|
azure_cleanup:
|
||||||
|
python cleanup_azure.py -y --match="^$(CLOUD_RESOURCE_PREFIX)"
|
||||||
|
|
||||||
gce_setup:
|
gce_setup:
|
||||||
python setup_gce.py "$(CLOUD_RESOURCE_PREFIX)"
|
python setup_gce.py "$(CLOUD_RESOURCE_PREFIX)"
|
||||||
|
|
||||||
|
@ -131,6 +134,12 @@ amazon: $(CREDENTIALS_FILE)
|
||||||
CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make amazon_cleanup ; \
|
CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make amazon_cleanup ; \
|
||||||
exit $$RC;
|
exit $$RC;
|
||||||
|
|
||||||
|
azure: $(CREDENTIALS_FILE)
|
||||||
|
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook azure.yml -i $(INVENTORY) $(CREDENTIALS_ARG) -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) ; \
|
||||||
|
RC=$$? ; \
|
||||||
|
CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make azure_cleanup ; \
|
||||||
|
exit $$RC;
|
||||||
|
|
||||||
gce: $(CREDENTIALS_FILE)
|
gce: $(CREDENTIALS_FILE)
|
||||||
CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make gce_setup ; \
|
CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make gce_setup ; \
|
||||||
ansible-playbook gce.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) ; \
|
ansible-playbook gce.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) ; \
|
||||||
|
|
7
test/integration/azure.yml
Normal file
7
test/integration/azure.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
- hosts: localhost
|
||||||
|
connection: local
|
||||||
|
gather_facts: no
|
||||||
|
tags:
|
||||||
|
- test_azure
|
||||||
|
roles:
|
||||||
|
- { role: test_azure }
|
1
test/integration/cleanup_azure.py
Normal file
1
test/integration/cleanup_azure.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -13,5 +13,9 @@ service_account_email:
|
||||||
pem_file:
|
pem_file:
|
||||||
project_id:
|
project_id:
|
||||||
|
|
||||||
|
# Azure Credentials
|
||||||
|
azure_subscription_id:
|
||||||
|
azure_cert_path:
|
||||||
|
|
||||||
# GITHUB SSH private key - a path to a SSH private key for use with github.com
|
# GITHUB SSH private key - a path to a SSH private key for use with github.com
|
||||||
github_ssh_private_key: "{{ lookup('env','HOME') }}/.ssh/id_rsa"
|
github_ssh_private_key: "{{ lookup('env','HOME') }}/.ssh/id_rsa"
|
||||||
|
|
10
test/integration/roles/test_azure/defaults/main.yml
Normal file
10
test/integration/roles/test_azure/defaults/main.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
# defaults file for test_azure
|
||||||
|
instance_name: "{{ resource_prefix|lower }}"
|
||||||
|
cert_path: "{{ azure_cert_path }}"
|
||||||
|
subscription_id: "{{ azure_subscription_id }}"
|
||||||
|
storage_account: "{{ azure_storage_account|default('ansibleeast') }}"
|
||||||
|
role_size: "{{ azure_role_size|default('Basic_A0') }}"
|
||||||
|
user: "{{ azure_user|default('ansible_user') }}"
|
||||||
|
location: "{{ azure_location|default('East US') }}"
|
||||||
|
password: "{{ azure_password|default('abc123Q%') }}"
|
63
test/integration/roles/test_azure/tasks/main.yml
Normal file
63
test/integration/roles/test_azure/tasks/main.yml
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
# TODO: Implement create storage account feature. Currently, storage_account must be manually created on azure account.
|
||||||
|
# TODO: When more granular azure operations are implemented (i.e. list disk, list cloud services, etc). Use the
|
||||||
|
# fine-grain listings to ensure higher level operations are performed.
|
||||||
|
# ============================================================
|
||||||
|
- name: test with no credentials
|
||||||
|
azure:
|
||||||
|
register: result
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: assert failure when called with no credentials
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- 'result.failed'
|
||||||
|
- 'result.msg == "No subscription_id provided. Please set ''AZURE_SUBSCRIPTION_ID'' or use the ''subscription_id'' parameter"'
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
- name: test credentials
|
||||||
|
azure:
|
||||||
|
subscription_id: "{{ subscription_id }}"
|
||||||
|
management_cert_path: "{{ cert_path }}"
|
||||||
|
register: result
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: assert failure when called with credentials and no parameters
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- 'result.failed'
|
||||||
|
- 'result.msg == "name parameter is required for new instance"'
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
- name: test status=Running (expected changed=true)
|
||||||
|
azure:
|
||||||
|
subscription_id: "{{ subscription_id }}"
|
||||||
|
management_cert_path: "{{ cert_path }}"
|
||||||
|
name: "{{ instance_name }}"
|
||||||
|
image: "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_4-LTS-amd64-server-20140514-en-us-30GB"
|
||||||
|
storage_account: "{{ storage_account }}"
|
||||||
|
user: "{{ user }}"
|
||||||
|
role_size: "{{ role_size }}"
|
||||||
|
password: "{{ password }}"
|
||||||
|
location: "{{ location }}"
|
||||||
|
wait: yes
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: assert state=Running (expected changed=true)
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- 'result.changed'
|
||||||
|
- 'result.deployment.name == "{{ instance_name }}"'
|
||||||
|
- 'result.deployment.status == "Running"'
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
- name: test state=absent (expected changed=true)
|
||||||
|
azure:
|
||||||
|
subscription_id: "{{ subscription_id }}"
|
||||||
|
management_cert_path: "{{ cert_path }}"
|
||||||
|
name: "{{ instance_name }}"
|
||||||
|
#storage_account: "{{ storage_account }}"
|
||||||
|
#location: "{{ location }}"
|
||||||
|
wait: yes
|
||||||
|
state: absent
|
||||||
|
register: result
|
Loading…
Reference in a new issue