diff --git a/build.py b/build.py
index bead766..b4aaddf 100644
--- a/build.py
+++ b/build.py
@@ -28,7 +28,7 @@
# define project level attributes:
name = 'clc-ansible-module'
-version = '1.1.5'
+version = '1.1.6'
summary = "Centurylink Cloud Ansible Modules"
description = "Ansible extension modules which allow users to interact with Centurylink Cloud to define and manage cloud components."
authors = [Author ("CenturyLink Cloud", "WFAAS-LLFT@centurylink.com")]
diff --git a/pom.xml b/pom.xml
index fb426c7..c75089f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
4.0.0
com.ctlts
clc-ansible-module
- 1.1.5
+ 1.1.6
clc-ansible-module
UTF-8
diff --git a/src/main/python/clc_ansible_module/clc_aa_policy.py b/src/main/python/clc_ansible_module/clc_aa_policy.py
index 00b3557..4833ffb 100644
--- a/src/main/python/clc_ansible_module/clc_aa_policy.py
+++ b/src/main/python/clc_ansible_module/clc_aa_policy.py
@@ -56,6 +56,7 @@
- python = 2.7
- requests >= 2.5.0
- clc-sdk
+author: "CLC Runner (@clc-runner)"
notes:
- To use this module, it is required to set the below environment variables which enables access to the
Centurylink Cloud
diff --git a/src/main/python/clc_ansible_module/clc_alert_policy.py b/src/main/python/clc_ansible_module/clc_alert_policy.py
index 7578877..641aa34 100644
--- a/src/main/python/clc_ansible_module/clc_alert_policy.py
+++ b/src/main/python/clc_ansible_module/clc_alert_policy.py
@@ -82,6 +82,7 @@
- python = 2.7
- requests >= 2.5.0
- clc-sdk
+author: "CLC Runner (@clc-runner)"
notes:
- To use this module, it is required to set the below environment variables which enables access to the
Centurylink Cloud
diff --git a/src/main/python/clc_ansible_module/clc_blueprint_package.py b/src/main/python/clc_ansible_module/clc_blueprint_package.py
index 064c6bd..0fa9c23 100644
--- a/src/main/python/clc_ansible_module/clc_blueprint_package.py
+++ b/src/main/python/clc_ansible_module/clc_blueprint_package.py
@@ -62,6 +62,7 @@
- python = 2.7
- requests >= 2.5.0
- clc-sdk
+author: "CLC Runner (@clc-runner)"
notes:
- To use this module, it is required to set the below environment variables which enables access to the
Centurylink Cloud
diff --git a/src/main/python/clc_ansible_module/clc_firewall_policy.py b/src/main/python/clc_ansible_module/clc_firewall_policy.py
index b52380b..e875bb9 100644
--- a/src/main/python/clc_ansible_module/clc_firewall_policy.py
+++ b/src/main/python/clc_ansible_module/clc_firewall_policy.py
@@ -93,6 +93,7 @@
- python = 2.7
- requests >= 2.5.0
- clc-sdk
+author: "CLC Runner (@clc-runner)"
notes:
- To use this module, it is required to set the below environment variables which enables access to the
Centurylink Cloud
diff --git a/src/main/python/clc_ansible_module/clc_group.py b/src/main/python/clc_ansible_module/clc_group.py
index 969c6d1..50e4deb 100644
--- a/src/main/python/clc_ansible_module/clc_group.py
+++ b/src/main/python/clc_ansible_module/clc_group.py
@@ -65,6 +65,7 @@
- python = 2.7
- requests >= 2.5.0
- clc-sdk
+author: "CLC Runner (@clc-runner)"
notes:
- To use this module, it is required to set the below environment variables which enables access to the
Centurylink Cloud
diff --git a/src/main/python/clc_ansible_module/clc_group_fact.py b/src/main/python/clc_ansible_module/clc_group_fact.py
index 1898843..0468b32 100644
--- a/src/main/python/clc_ansible_module/clc_group_fact.py
+++ b/src/main/python/clc_ansible_module/clc_group_fact.py
@@ -40,6 +40,7 @@
requirements:
- python = 2.7
- requests >= 2.5.0
+author: "CLC Runner (@clc-runner)"
notes:
- To use this module, it is required to set the below environment variables which enables access to the
Centurylink Cloud
@@ -58,7 +59,7 @@
- name: Retrieve Group Facts
clc_group_fact:
group_id: 31d13f501459411ba59304f3d47486eb
-
+
'''
RETURN = '''
@@ -191,8 +192,6 @@
__version__ = '${version}'
-from distutils.version import LooseVersion
-
try:
import requests
except ImportError:
@@ -200,6 +199,7 @@
else:
REQUESTS_FOUND = True
+
class ClcGroupFact:
def __init__(self, module):
@@ -219,19 +219,21 @@ def process_request(self):
"""
self._set_clc_credentials_from_env()
group_id = self.module.params.get('group_id')
-
+
r = requests.get(self._get_endpoint(group_id), headers={
- 'Authorization' : 'Bearer ' + self.v2_api_token
+ 'Authorization': 'Bearer ' + self.v2_api_token
})
if r.status_code not in [200]:
- self.module.fail_json(msg='Failed to retrieve group facts: %s' % group_id)
+ self.module.fail_json(
+ msg='Failed to retrieve group facts: %s' %
+ group_id)
r = r.json()
- servers = r['server'] = []
-
+ servers = r['servers'] = []
+
for l in r['links']:
- if 'servers' == l['rel']:
+ if 'server' == l['rel']:
servers.append(l['id'])
self.module.exit_json(changed=False, group=r)
@@ -258,31 +260,33 @@ def _set_clc_credentials_from_env(self):
v2_api_passwd = env.get('CLC_V2_API_PASSWD', False)
clc_alias = env.get('CLC_ACCT_ALIAS', False)
self.api_url = env.get('CLC_V2_API_URL', 'https://api.ctl.io')
-
+
if v2_api_token and clc_alias:
-
+
self.v2_api_token = v2_api_token
self.clc_alias = clc_alias
-
+
elif v2_api_username and v2_api_passwd:
-
+
r = requests.post(self.api_url + '/v2/authentication/login', json={
- 'username' : v2_api_username,
- 'password' : v2_api_passwd
+ 'username': v2_api_username,
+ 'password': v2_api_passwd
})
-
+
if r.status_code not in [200]:
- self.module.fail_json(msg='Failed to authenticate with clc V2 api.')
-
- r = r.json()
+ self.module.fail_json(
+ msg='Failed to authenticate with clc V2 api.')
+
+ r = r.json()
self.v2_api_token = r['bearerToken']
self.clc_alias = r['accountAlias']
-
+
else:
return self.module.fail_json(
msg="You must set the CLC_V2_API_USERNAME and CLC_V2_API_PASSWD "
"environment variables")
+
def main():
"""
The main function. Instantiates the module and calls process_request.
diff --git a/src/main/python/clc_ansible_module/clc_loadbalancer.py b/src/main/python/clc_ansible_module/clc_loadbalancer.py
index 50b8008..2c99735 100644
--- a/src/main/python/clc_ansible_module/clc_loadbalancer.py
+++ b/src/main/python/clc_ansible_module/clc_loadbalancer.py
@@ -85,6 +85,21 @@
required: False
default: present
choices: ['present', 'absent', 'port_absent', 'nodes_present', 'nodes_absent']
+requirements:
+ - python = 2.7
+ - requests >= 2.5.0
+ - clc-sdk
+author: "CLC Runner (@clc-runner)"
+notes:
+ - To use this module, it is required to set the below environment variables which enables access to the
+ Centurylink Cloud
+ - CLC_V2_API_USERNAME, the account login id for the centurylink cloud
+ - CLC_V2_API_PASSWORD, the account password for the centurylink cloud
+ - Alternatively, the module accepts the API token and account alias. The API token can be generated using the
+ CLC account login and password via the HTTP api call @ https://api.ctl.io/v2/authentication/login
+ - CLC_V2_API_TOKEN, the API token generated from https://api.ctl.io/v2/authentication/login
+ - CLC_ACCT_ALIAS, the account alias associated with the centurylink cloud
+ - Users can set CLC_V2_API_URL to specify an endpoint for pointing to a different CLC environment.
'''
EXAMPLES = '''
@@ -163,20 +178,6 @@
nodes:
- { 'ipAddress': '10.11.22.123', 'privatePort': 80 }
state: absent
-requirements:
- - python = 2.7
- - requests >= 2.5.0
- - clc-sdk
-notes:
- - To use this module, it is required to set the below environment variables which enables access to the
- Centurylink Cloud
- - CLC_V2_API_USERNAME, the account login id for the centurylink cloud
- - CLC_V2_API_PASSWORD, the account password for the centurylink cloud
- - Alternatively, the module accepts the API token and account alias. The API token can be generated using the
- CLC account login and password via the HTTP api call @ https://api.ctl.io/v2/authentication/login
- - CLC_V2_API_TOKEN, the API token generated from https://api.ctl.io/v2/authentication/login
- - CLC_ACCT_ALIAS, the account alias associated with the centurylink cloud
- - Users can set CLC_V2_API_URL to specify an endpoint for pointing to a different CLC environment.
'''
RETURN = '''
diff --git a/src/main/python/clc_ansible_module/clc_modify_server.py b/src/main/python/clc_ansible_module/clc_modify_server.py
index 3ec0282..a43339e 100644
--- a/src/main/python/clc_ansible_module/clc_modify_server.py
+++ b/src/main/python/clc_ansible_module/clc_modify_server.py
@@ -92,6 +92,7 @@
- python = 2.7
- requests >= 2.5.0
- clc-sdk
+author: "CLC Runner (@clc-runner)"
notes:
- To use this module, it is required to set the below environment variables which enables access to the
Centurylink Cloud
diff --git a/src/main/python/clc_ansible_module/clc_publicip.py b/src/main/python/clc_ansible_module/clc_publicip.py
index 1bc7e83..72b6957 100644
--- a/src/main/python/clc_ansible_module/clc_publicip.py
+++ b/src/main/python/clc_ansible_module/clc_publicip.py
@@ -71,6 +71,7 @@
- python = 2.7
- requests >= 2.5.0
- clc-sdk
+author: "CLC Runner (@clc-runner)"
notes:
- To use this module, it is required to set the below environment variables which enables access to the
Centurylink Cloud
diff --git a/src/main/python/clc_ansible_module/clc_server.py b/src/main/python/clc_ansible_module/clc_server.py
index 1ec6d12..0985b0b 100644
--- a/src/main/python/clc_ansible_module/clc_server.py
+++ b/src/main/python/clc_ansible_module/clc_server.py
@@ -247,6 +247,7 @@
- python = 2.7
- requests >= 2.5.0
- clc-sdk
+author: "CLC Runner (@clc-runner)"
notes:
- To use this module, it is required to set the below environment variables which enables access to the
Centurylink Cloud
diff --git a/src/main/python/clc_ansible_module/clc_server_fact.py b/src/main/python/clc_ansible_module/clc_server_fact.py
index a8f4934..0deac21 100644
--- a/src/main/python/clc_ansible_module/clc_server_fact.py
+++ b/src/main/python/clc_ansible_module/clc_server_fact.py
@@ -46,6 +46,7 @@
requirements:
- python = 2.7
- requests >= 2.5.0
+author: "CLC Runner (@clc-runner)"
notes:
- To use this module, it is required to set the below environment variables which enables access to the
Centurylink Cloud
@@ -64,12 +65,12 @@
- name: Retrieve Server Facts
clc_server_fact:
server_id: UC1WFADWRDPRS10
-
+
- name: Retrieve Server Facts With Credentials
clc_server_fact:
server_id: UC1WFADWRDPRS10
credentials: true
-
+
'''
RETURN = '''
@@ -236,8 +237,6 @@
__version__ = '${version}'
-from distutils.version import LooseVersion
-
try:
import requests
except ImportError:
@@ -245,6 +244,7 @@
else:
REQUESTS_FOUND = True
+
class ClcServerFact:
def __init__(self, module):
@@ -264,13 +264,15 @@ def process_request(self):
"""
self._set_clc_credentials_from_env()
server_id = self.module.params.get('server_id')
-
+
r = requests.get(self._get_endpoint(server_id), headers={
- 'Authorization' : 'Bearer ' + self.v2_api_token
+ 'Authorization': 'Bearer ' + self.v2_api_token
})
if r.status_code not in [200]:
- self.module.fail_json(msg='Failed to retrieve server facts: %s' % server_id)
+ self.module.fail_json(
+ msg='Failed to retrieve server facts: %s' %
+ server_id)
r = r.json()
@@ -290,16 +292,18 @@ def _define_module_argument_spec():
credentials=dict(default=False))
return {"argument_spec": argument_spec}
-
+
def _get_server_credentials(self, server_id):
-
+
r = requests.get(self._get_endpoint(server_id) + '/credentials', headers={
- 'Authorization' : 'Bearer ' + self.v2_api_token
+ 'Authorization': 'Bearer ' + self.v2_api_token
})
-
+
if r.status_code not in [200]:
- self.module.fail_json(msg='Failed to retrieve server credentials: %s' % server_id)
-
+ self.module.fail_json(
+ msg='Failed to retrieve server credentials: %s' %
+ server_id)
+
return r.json()
def _get_endpoint(self, server_id):
@@ -316,31 +320,33 @@ def _set_clc_credentials_from_env(self):
v2_api_passwd = env.get('CLC_V2_API_PASSWD', False)
clc_alias = env.get('CLC_ACCT_ALIAS', False)
self.api_url = env.get('CLC_V2_API_URL', 'https://api.ctl.io')
-
+
if v2_api_token and clc_alias:
-
+
self.v2_api_token = v2_api_token
self.clc_alias = clc_alias
-
+
elif v2_api_username and v2_api_passwd:
-
+
r = requests.post(self.api_url + '/v2/authentication/login', json={
- 'username' : v2_api_username,
- 'password' : v2_api_passwd
+ 'username': v2_api_username,
+ 'password': v2_api_passwd
})
-
+
if r.status_code not in [200]:
- self.module.fail_json(msg='Failed to authenticate with clc V2 api.')
-
- r = r.json()
+ self.module.fail_json(
+ msg='Failed to authenticate with clc V2 api.')
+
+ r = r.json()
self.v2_api_token = r['bearerToken']
self.clc_alias = r['accountAlias']
-
+
else:
return self.module.fail_json(
msg="You must set the CLC_V2_API_USERNAME and CLC_V2_API_PASSWD "
"environment variables")
+
def main():
"""
The main function. Instantiates the module and calls process_request.
diff --git a/src/main/python/clc_ansible_module/clc_server_snapshot.py b/src/main/python/clc_ansible_module/clc_server_snapshot.py
index d439706..ecb2e96 100644
--- a/src/main/python/clc_ansible_module/clc_server_snapshot.py
+++ b/src/main/python/clc_ansible_module/clc_server_snapshot.py
@@ -58,6 +58,7 @@
- python = 2.7
- requests >= 2.5.0
- clc-sdk
+author: "CLC Runner (@clc-runner)"
notes:
- To use this module, it is required to set the below environment variables which enables access to the
Centurylink Cloud