Add test for os_server Ansible module
We haven't been able to test os_server because we haven't had a way to reliably determine the image name (which changes from time to time based on version) from the playbook. A stupidly clever hack is to just grep out the name from a shell call to the openstack client and pass that in to the playbook from the command line. The playbook is simple for now for the initial commit. I expect new tasks to be added to it later. Change-Id: I3caedfd4c805126c8da1fc8bab06ccda3fd96528
This commit is contained in:
parent
f236869b77
commit
34799e9f9e
@ -81,4 +81,14 @@ then
|
||||
tag_opt="--tags ${TAGS}"
|
||||
fi
|
||||
|
||||
ansible-playbook -vvv ./shade/tests/ansible/run.yml -e "cloud=${CLOUD}" ${tag_opt}
|
||||
# Until we have a module that lets us determine the image we want from
|
||||
# within a playbook, we have to find the image here and pass it in.
|
||||
# We use the openstack client instead of nova client since it can use clouds.yaml.
|
||||
IMAGE=`openstack --os-cloud=${CLOUD} image list -f value -c Name | grep -v -e ramdisk -e kernel`
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Failed to find Cirros image"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ansible-playbook -vvv ./shade/tests/ansible/run.yml -e "cloud=${CLOUD} image=${IMAGE}" ${tag_opt}
|
||||
|
46
shade/tests/ansible/roles/server/tasks/main.yml
Normal file
46
shade/tests/ansible/roles/server/tasks/main.yml
Normal file
@ -0,0 +1,46 @@
|
||||
---
|
||||
- name: Create server with meta as CSV
|
||||
os_server:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
name: "{{ server_name }}"
|
||||
image: "{{ image }}"
|
||||
flavor: "{{ flavor }}"
|
||||
network: "{{ server_network }}"
|
||||
auto_floating_ip: false
|
||||
meta: "key1=value1,key2=value2"
|
||||
wait: true
|
||||
register: server
|
||||
|
||||
- debug: var=server
|
||||
|
||||
- name: Delete server with meta as CSV
|
||||
os_server:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
name: "{{ server_name }}"
|
||||
wait: true
|
||||
|
||||
- name: Create server with meta as dict
|
||||
os_server:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
name: "{{ server_name }}"
|
||||
image: "{{ image }}"
|
||||
flavor: "{{ flavor }}"
|
||||
auto_floating_ip: false
|
||||
network: "{{ server_network }}"
|
||||
meta:
|
||||
key1: value1
|
||||
key2: value2
|
||||
wait: true
|
||||
register: server
|
||||
|
||||
- debug: var=server
|
||||
|
||||
- name: Delete server with meta as dict
|
||||
os_server:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
name: "{{ server_name }}"
|
||||
wait: true
|
3
shade/tests/ansible/roles/server/vars/main.yaml
Normal file
3
shade/tests/ansible/roles/server/vars/main.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
server_network: private
|
||||
server_name: ansible_server
|
||||
flavor: m1.tiny
|
@ -14,6 +14,7 @@
|
||||
- { role: port, tags: port }
|
||||
- { role: router, tags: router }
|
||||
- { role: security_group, tags: security_group }
|
||||
- { role: server, tags: server }
|
||||
- { role: subnet, tags: subnet }
|
||||
- { role: user, tags: user }
|
||||
- { role: user_group, tags: user_group }
|
||||
|
@ -4,6 +4,7 @@ coverage>=3.6
|
||||
discover
|
||||
fixtures>=0.3.14
|
||||
mock>=1.0
|
||||
python-openstackclient>=2.1.0
|
||||
python-subunit
|
||||
oslosphinx>=2.2.0 # Apache-2.0
|
||||
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
|
||||
|
Loading…
Reference in New Issue
Block a user