Merge pull request #670 from quentinsf/devel
webfaction: Allow machine to be specified if account has more than one.
This commit is contained in:
commit
7717719ed4
2 changed files with 44 additions and 11 deletions
|
@ -7,7 +7,9 @@
|
||||||
#
|
#
|
||||||
# ------------------------------------------
|
# ------------------------------------------
|
||||||
#
|
#
|
||||||
# (c) Quentin Stafford-Fraser 2015
|
# (c) Quentin Stafford-Fraser 2015, with contributions gratefully acknowledged from:
|
||||||
|
# * Andy Baker
|
||||||
|
# * Federico Tarantini
|
||||||
#
|
#
|
||||||
# This file is part of Ansible
|
# This file is part of Ansible
|
||||||
#
|
#
|
||||||
|
@ -80,6 +82,12 @@ options:
|
||||||
description:
|
description:
|
||||||
- The webfaction password to use
|
- The webfaction password to use
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
machine:
|
||||||
|
description:
|
||||||
|
- The machine name to use (optional for accounts with only one machine)
|
||||||
|
required: false
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
@ -90,6 +98,7 @@ EXAMPLES = '''
|
||||||
type=mod_wsgi35-python27
|
type=mod_wsgi35-python27
|
||||||
login_name={{webfaction_user}}
|
login_name={{webfaction_user}}
|
||||||
login_password={{webfaction_passwd}}
|
login_password={{webfaction_passwd}}
|
||||||
|
machine={{webfaction_machine}}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
|
@ -108,6 +117,7 @@ def main():
|
||||||
port_open = dict(required=False, choices=BOOLEANS, default=False),
|
port_open = dict(required=False, choices=BOOLEANS, default=False),
|
||||||
login_name = dict(required=True),
|
login_name = dict(required=True),
|
||||||
login_password = dict(required=True),
|
login_password = dict(required=True),
|
||||||
|
machine = dict(required=False, default=False),
|
||||||
),
|
),
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
@ -115,6 +125,13 @@ def main():
|
||||||
app_type = module.params['type']
|
app_type = module.params['type']
|
||||||
app_state = module.params['state']
|
app_state = module.params['state']
|
||||||
|
|
||||||
|
if module.params['machine']:
|
||||||
|
session_id, account = webfaction.login(
|
||||||
|
module.params['login_name'],
|
||||||
|
module.params['login_password'],
|
||||||
|
module.params['machine']
|
||||||
|
)
|
||||||
|
else:
|
||||||
session_id, account = webfaction.login(
|
session_id, account = webfaction.login(
|
||||||
module.params['login_name'],
|
module.params['login_name'],
|
||||||
module.params['login_password']
|
module.params['login_password']
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
#
|
#
|
||||||
# ------------------------------------------
|
# ------------------------------------------
|
||||||
#
|
#
|
||||||
# (c) Quentin Stafford-Fraser and Andy Baker 2015
|
# (c) Quentin Stafford-Fraser 2015, with contributions gratefully acknowledged from:
|
||||||
|
# * Andy Baker
|
||||||
|
# * Federico Tarantini
|
||||||
#
|
#
|
||||||
# This file is part of Ansible
|
# This file is part of Ansible
|
||||||
#
|
#
|
||||||
|
@ -68,6 +70,11 @@ options:
|
||||||
description:
|
description:
|
||||||
- The webfaction password to use
|
- The webfaction password to use
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
machine:
|
||||||
|
description:
|
||||||
|
- The machine name to use (optional for accounts with only one machine)
|
||||||
|
required: false
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
@ -81,6 +88,7 @@ EXAMPLES = '''
|
||||||
type: mysql
|
type: mysql
|
||||||
login_name: "{{webfaction_user}}"
|
login_name: "{{webfaction_user}}"
|
||||||
login_password: "{{webfaction_passwd}}"
|
login_password: "{{webfaction_passwd}}"
|
||||||
|
machine: "{{webfaction_machine}}"
|
||||||
|
|
||||||
# Note that, for symmetry's sake, deleting a database using
|
# Note that, for symmetry's sake, deleting a database using
|
||||||
# 'state: absent' will also delete the matching user.
|
# 'state: absent' will also delete the matching user.
|
||||||
|
@ -103,6 +111,7 @@ def main():
|
||||||
password = dict(required=False, default=None),
|
password = dict(required=False, default=None),
|
||||||
login_name = dict(required=True),
|
login_name = dict(required=True),
|
||||||
login_password = dict(required=True),
|
login_password = dict(required=True),
|
||||||
|
machine = dict(required=False, default=False),
|
||||||
),
|
),
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
@ -111,6 +120,13 @@ def main():
|
||||||
db_type = module.params['type']
|
db_type = module.params['type']
|
||||||
db_passwd = module.params['password']
|
db_passwd = module.params['password']
|
||||||
|
|
||||||
|
if module.params['machine']:
|
||||||
|
session_id, account = webfaction.login(
|
||||||
|
module.params['login_name'],
|
||||||
|
module.params['login_password'],
|
||||||
|
module.params['machine']
|
||||||
|
)
|
||||||
|
else:
|
||||||
session_id, account = webfaction.login(
|
session_id, account = webfaction.login(
|
||||||
module.params['login_name'],
|
module.params['login_name'],
|
||||||
module.params['login_password']
|
module.params['login_password']
|
||||||
|
@ -130,7 +146,7 @@ def main():
|
||||||
|
|
||||||
if db_state == 'present':
|
if db_state == 'present':
|
||||||
|
|
||||||
# Does an database with this name already exist?
|
# Does a database with this name already exist?
|
||||||
if existing_db:
|
if existing_db:
|
||||||
# Yes, but of a different type - fail
|
# Yes, but of a different type - fail
|
||||||
if existing_db['db_type'] != db_type:
|
if existing_db['db_type'] != db_type:
|
||||||
|
|
Loading…
Reference in a new issue