Skip to content

Commit

Permalink
Tidying of webfaction modules
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinsf authored and mattclay committed Dec 8, 2016
1 parent 00e1466 commit 3f715dc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 30 deletions.
12 changes: 5 additions & 7 deletions lib/ansible/modules/extras/cloud/webfaction/webfaction_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
description:
- Add or remove applications on a Webfaction host. Further documentation at http://github.com/quentinsf/ansible-webfaction.
author: Quentin Stafford-Fraser
version_added: 1.99
version_added: 2.0
notes:
- "You can run playbooks that use this on a local machine, or on a Webfaction host, or elsewhere, since the scripts use the remote webfaction API - the location is not important. However, running them on multiple hosts I(simultaneously) is best avoided. If you don't specify I(localhost) as your host, you may want to add C(serial: 1) to the plays."
- See `the webfaction API <http://docs.webfaction.com/xmlrpc-api/>`_ for more info.
Expand All @@ -23,7 +23,6 @@
description:
- The name of the application
required: true
default: null
state:
description:
Expand Down Expand Up @@ -65,20 +64,19 @@
'''

import xmlrpclib
from ansible.module_utils.basic import *

webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')

def main():

module = AnsibleModule(
argument_spec = dict(
name = dict(required=True, default=None),
name = dict(required=True),
state = dict(required=False, default='present'),
type = dict(required=True),
autostart = dict(required=False, choices=BOOLEANS, default='false'),
autostart = dict(required=False, choices=BOOLEANS, default=False),
extra_info = dict(required=False, default=""),
port_open = dict(required=False, default="false"),
port_open = dict(required=False, choices=BOOLEANS, default=False),
login_name = dict(required=True),
login_password = dict(required=True),
),
Expand Down Expand Up @@ -148,6 +146,6 @@ def main():
result = result
)

# The conventional ending
from ansible.module_utils.basic import *
main()

10 changes: 4 additions & 6 deletions lib/ansible/modules/extras/cloud/webfaction/webfaction_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
description:
- Add or remove a database on a Webfaction host. Further documentation at http://github.com/quentinsf/ansible-webfaction.
author: Quentin Stafford-Fraser
version_added: 1.99
version_added: 2.0
notes:
- "You can run playbooks that use this on a local machine, or on a Webfaction host, or elsewhere, since the scripts use the remote webfaction API - the location is not important. However, running them on multiple hosts I(simultaneously) is best avoided. If you don't specify I(localhost) as your host, you may want to add C(serial: 1) to the plays."
- See `the webfaction API <http://docs.webfaction.com/xmlrpc-api/>`_ for more info.
Expand All @@ -20,7 +20,6 @@
description:
- The name of the database
required: true
default: null
state:
description:
Expand Down Expand Up @@ -61,18 +60,17 @@

import socket
import xmlrpclib
from ansible.module_utils.basic import *

webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')

def main():

module = AnsibleModule(
argument_spec = dict(
name = dict(required=True, default=None),
name = dict(required=True),
state = dict(required=False, default='present'),
# You can specify an IP address or hostname.
type = dict(required=True, default=None),
type = dict(required=True),
password = dict(required=False, default=None),
login_name = dict(required=True),
login_password = dict(required=True),
Expand Down Expand Up @@ -142,6 +140,6 @@ def main():
result = result
)

# The conventional ending
from ansible.module_utils.basic import *
main()

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
description:
- Add or remove domains or subdomains on a Webfaction host. Further documentation at http://github.com/quentinsf/ansible-webfaction.
author: Quentin Stafford-Fraser
version_added: 1.99
version_added: 2.0
notes:
- If you are I(deleting) domains by using C(state=absent), then note that if you specify subdomains, just those particular subdomains will be deleted. If you don't specify subdomains, the domain will be deleted.
- "You can run playbooks that use this on a local machine, or on a Webfaction host, or elsewhere, since the scripts use the remote webfaction API - the location is not important. However, running them on multiple hosts I(simultaneously) is best avoided. If you don't specify I(localhost) as your host, you may want to add C(serial: 1) to the plays."
Expand All @@ -22,7 +22,6 @@
description:
- The name of the domain
required: true
default: null
state:
description:
Expand Down Expand Up @@ -50,15 +49,14 @@

import socket
import xmlrpclib
from ansible.module_utils.basic import *

webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')

def main():

module = AnsibleModule(
argument_spec = dict(
name = dict(required=True, default=None),
name = dict(required=True),
state = dict(required=False, default='present'),
subdomains = dict(required=False, default=[]),
login_name = dict(required=True),
Expand Down Expand Up @@ -129,6 +127,6 @@ def main():
result = result
)

# The conventional ending
from ansible.module_utils.basic import *
main()

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
description:
- Add or remove mailboxes on a Webfaction account. Further documentation at http://github.com/quentinsf/ansible-webfaction.
author: Quentin Stafford-Fraser
version_added: 1.99
version_added: 2.0
notes:
- "You can run playbooks that use this on a local machine, or on a Webfaction host, or elsewhere, since the scripts use the remote webfaction API - the location is not important. However, running them on multiple hosts I(simultaneously) is best avoided. If you don't specify I(localhost) as your host, you may want to add C(serial: 1) to the plays."
- See `the webfaction API <http://docs.webfaction.com/xmlrpc-api/>`_ for more info.
Expand All @@ -20,7 +20,6 @@
description:
- The name of the mailbox
required: true
default: null
mailbox_password:
description:
Expand Down Expand Up @@ -48,15 +47,14 @@

import socket
import xmlrpclib
from ansible.module_utils.basic import *

webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')

def main():

module = AnsibleModule(
argument_spec=dict(
mailbox_name=dict(required=True, default=None),
mailbox_name=dict(required=True),
mailbox_password=dict(required=True),
state=dict(required=False, default='present'),
login_name=dict(required=True),
Expand Down Expand Up @@ -107,6 +105,7 @@ def main():

module.exit_json(changed=True, result=result)

# The conventional ending

from ansible.module_utils.basic import *
main()

14 changes: 7 additions & 7 deletions lib/ansible/modules/extras/cloud/webfaction/webfaction_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
description:
- Add or remove a website on a Webfaction host. Further documentation at http://github.com/quentinsf/ansible-webfaction.
author: Quentin Stafford-Fraser
version_added: 1.99
version_added: 2.0
notes:
- Sadly, you I(do) need to know your webfaction hostname for the C(host) parameter. But at least, unlike the API, you don't need to know the IP address - you can use a DNS name.
- If a site of the same name exists in the account but on a different host, the operation will exit.
Expand All @@ -23,7 +23,6 @@
description:
- The name of the website
required: true
default: null
state:
description:
Expand Down Expand Up @@ -83,19 +82,18 @@

import socket
import xmlrpclib
from ansible.module_utils.basic import *

webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')

def main():

module = AnsibleModule(
argument_spec = dict(
name = dict(required=True, default=None),
name = dict(required=True),
state = dict(required=False, default='present'),
# You can specify an IP address or hostname.
host = dict(required=True, default=None),
https = dict(required=False, choices=BOOLEANS, default='false'),
host = dict(required=True),
https = dict(required=False, choices=BOOLEANS, default=False),
subdomains = dict(required=False, default=[]),
site_apps = dict(required=False, default=[]),
login_name = dict(required=True),
Expand Down Expand Up @@ -184,6 +182,8 @@ def main():
result = result
)

# The conventional ending


from ansible.module_utils.basic import *
main()

0 comments on commit 3f715dc

Please sign in to comment.