@ -404,32 +404,8 @@ def _get_server_state(module, nova):
def main():
# Consume standard OpenStack environment variables.
# This is mainly only useful for ad-hoc command line operation as
# in playbooks one would assume variables would be used appropriately
OS_USERNAME=os.environ.get('OS_USERNAME', 'admin')
OS_PASSWORD=os.environ.get('OS_PASSWORD', None)
login_password_arg = dict()
if OS_PASSWORD:
login_password_arg['default'] = OS_PASSWORD
else:
login_password_arg['required'] = True
OS_TENANT_NAME=os.environ.get('OS_TENANT_NAME', None)
tenant_name_arg = dict()
if OS_TENANT_NAME:
tenant_name_arg['default'] = OS_TENANT_NAME
else:
tenant_name_arg['required'] = True
OS_REGION_NAME=os.environ.get('OS_REGION_NAME', None)
OS_AUTH_URL=os.environ.get('OS_AUTH_URL', 'http://127.0.0.1:35357/v2.0/')
module = AnsibleModule(
argument_spec = dict(
login_username = dict(default=OS_USERNAME),
login_password = login_password_arg,
login_tenant_name = tenant_name_arg,
auth_url = dict(default=OS_AUTH_URL),
region_name = dict(default=OS_REGION_NAME),
argument_spec = openstack_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
image_id = dict(default=None),
flavor_id = dict(default=1),
@ -442,9 +418,8 @@ def main():
state = dict(default='present', choices=['absent', 'present']),
user_data = dict(default=None),
floating_ip = dict(default=None),
availability_zone = dict(default=None),
),
)
))
module = AnsibleModule(argument_spec=argument_spec)
nova = nova_client.Client(module.params['login_username'],
module.params['login_password'],
@ -471,5 +446,6 @@ def main():
# this is magic, see lib/ansible/module.params['common.py
from ansible.module_utils.basic import *
from ansible.module_utils.openstack import *
main()