Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Added module for SoftLayer #1020

Merged
merged 1 commit into from
Mar 23, 2016
Merged

Added module for SoftLayer #1020

merged 1 commit into from
Mar 23, 2016

Conversation

mcltn
Copy link
Contributor

@mcltn mcltn commented Sep 23, 2015

This module allows the functionality of building and canceling SoftLayer virtual instances. This module requires the SoftLayer library to work. The parameters allow you to build a single instance as well as specify a quantity of instances to build in addition to the various options for the virtual instances themselves.

@robynbergeron
Copy link
Contributor

Hi @mcltn --

Thanks for submitting this new module to Ansible Extras! This module is now in community review, a process that is open to all Ansible users. In order for this module to be approved, it must gain the following votes:

“works_for_me”: If you have tested the module thoroughly, including testing of all of the module’s options, and if the module works for you, please add “works_for_me” in the comments.

“passes_guidelines”: If you have gone through the module guidelines and the module meets all of the requirements, please add “passes_guidelines” in the comments. Guidelines are available here: http://docs.ansible.com/developing_modules.html#module-checklist

“needs_revision”: If the module fails to work for you, or if it doesn’t meet guidelines, please add “needs_revision” in the comments with details about what needs to be fixed.

When a module has both “works_for_me” and “passes_guidelines” tags, we will promote the module for inclusion in Ansible Extras. At this point, you will be expected to maintain the module by fixing bugs and evaluating pull requests in a timely manner.

Thanks again for submitting your Ansible module!

@sp4ceb4r
Copy link

sp4ceb4r commented Nov 9, 2015

"passes_guidelines"

Side Note: While PEP8 is not required the use of spaces instead of tabs would make any potential Pull Requests easier as spaces seem to be the more default option.

@bcoca
Copy link
Member

bcoca commented Nov 9, 2015

while we don't force PEP8, tabs as indentation do create issues, so please convert those to spaces.

@mcltn
Copy link
Contributor Author

mcltn commented Nov 10, 2015

All of the tabs contained in the code have been converted to spaces.

@coreylane
Copy link

works_for_me

description:
- Creates or cancels SoftLayer instances. When created, optionally waits for it to be 'running'.
options:
hostname:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the docs need to be valid YAML, the indentation is off in many places

@mcltn
Copy link
Contributor Author

mcltn commented Nov 13, 2015

Issues with spacing within documentation yaml has been corrected.

'''

import time
from ansible.module_utils.facts import *
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why you have facts imported here

@bcoca
Copy link
Member

bcoca commented Nov 13, 2015

also we would appreciate it if you could flatten this into a single commit

@mcltn
Copy link
Contributor Author

mcltn commented Nov 19, 2015

Flattened to a single commit.

@kbroughton
Copy link

Looks good. My one nit would be that softlayer.py is the name of the dynamic inventory script as well.
Perhaps following the lead of the ec2 modules we could call the sl creation
sl.py, thus allowing sl_tag, sl_volume etc to come in the future. Names will become long if all modules have to be pre-pended by softlayer in full. ec2 modules for reference: http://docs.ansible.com/ansible/list_of_cloud_modules.html

@mcltn
Copy link
Contributor Author

mcltn commented Nov 19, 2015

yep, been thinking about that as well. Going to rename to your suggestion.

@kbroughton
Copy link

Testing now. I'm seeing something odd. Passing in an int for cpus works fine, but passing a variable that resolves to an int fails. Could you try passing in a var for cpus and see if you can reproduce?

failed: [localhost -> 127.0.0.1] => (item={'count': 3, 'datacenter': 'dal06', 'hostname': u'worker', 'disks': [25, 100], 'tags': ['mesos_slave', 'hdfs_datanode', 'consul_client'], 'disk_info': [{'device': 'xvda', 'size': 25}, {'device': 'xvdc', 'size': 100}, {'device': 'xvdd', 'size': 200}], 'cpus': 1, 'local_disk': False}) => {"failed": true, }}
msg: value of cpus must be one of: 1,2,4,8,16, got: 1

as you can see, item.cpus is resolving to an int (no quotes around the 1 in 'cpus': 1)
cpus: "{{item.cpus }}" - fails when item.cpus = 1
cpus: 1 - works fine

@mcltn
Copy link
Contributor Author

mcltn commented Nov 19, 2015

This throws the error due to the "choices" option in the parameter. Only certain cpu sizes are allowed and the array is of ints.

@kbroughton
Copy link

Docs don't specify if ssh_keys: var takes a keyname or id. Name doesn't work, I have to use the key id found by
slcli sshkey list
:........:.............................:.................................................:.......:
: id : label : fingerprint : notes :
:........:.............................:.................................................:.......:
: 10623 : dummy : a3*****:b3 : - :

It would be nice to do id lookup of ssh_key names but i wouldn't hold up this pr over it. Just clarify in the docs.

@mcltn
Copy link
Contributor Author

mcltn commented Nov 19, 2015

Specified in the docs that VLAN and SSH Keys are by Id.

@kbroughton
Copy link

@mcltn
Still trying to figure out why i can't pass variables to cpus: and memory:

Here is my debug using a jinja2 test to make sure it is a number

  • debug: msg="{{item.cpus }} {{item.cpus is number}}"
    with_items: sl_requested_hosts

where
sl_requested_hosts:
cpus: 1

returns
}
"msg": "1 True"
}

So it seems I am passing in an int and it is in the list of allowed values.
Other modules take variables no problem. Am i missing something?

@mcltn
Copy link
Contributor Author

mcltn commented Nov 19, 2015

looks like adding type='int' to the params fixes the issue. Adding to both cpus and memory.

@kbroughton
Copy link

for consistency with ec2 module, could you move the wait logic to its own top-level arg rather than putting it into state? I wasn't clear if state = wait would create, then wait, or just wait assuming it was already created.

ec2 docs:
parameter required default choices comments
wait no no yes, no wait for the instance to be 'running'
before returning. Does not wait for
SSH, see 'wait_for' example for details.
wait_timeout
no 300 how long before wait gives up, in
seconds

@mcltn
Copy link
Contributor Author

mcltn commented Nov 19, 2015

I'm hesitant to do it this way since some users, as well as myself, would want to potentially run provisioning in parallel, but I guess it could place an order in the first play, say for web heads, then when running a second play, say for a db, this step could have a wait flag. It would still require a tag or something to use to know what instances to wait for. Other thoughts?

@kbroughton
Copy link

@mcltn I'll have to check but I think the way "wait" works with ec2 is that all jobs are launched in parallel, but all jobs must complete before moving on to the next task. I see no use case to waiting for each to complete serially. You would use the "serial" keyword for that i guess.

- Quantity of virtual instances to provision
required: false
default: 0
increment:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bad pattern that crept into other modules, ansible already allows the use of sequences and loops to take care of this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making edits to remove this functionality within the module. Makes better sense to utilize it outside.

@gregdek
Copy link
Contributor

gregdek commented Mar 2, 2016

@mcltn A friendly reminder: this pull request has been marked as needing your action. If you still believe that this PR applies, and you intend to address the issues with this PR, just let us know in the PR itself and we will keep it open pending your changes.

@mcltn
Copy link
Contributor Author

mcltn commented Mar 2, 2016

Planning on making some adjustments, may need some time. Should have updates coming soon. Thanks!

@gregdek
Copy link
Contributor

gregdek commented Mar 3, 2016

@mcltn A friendly reminder: this pull request has been marked as needing your action. If you still believe that this PR applies, and you intend to address the issues with this PR, just let us know in the PR itself and we will keep it open pending your changes.

@kbroughton
Copy link

if @mcltn doesn't respond by end of week, i can try responding to the
action items on the ticket rather than closing it.

On Thu, Mar 3, 2016 at 9:14 AM, Greg DeKoenigsberg <notifications@github.com

wrote:

@mcltn https://github.com/mcltn A friendly reminder: this pull request
has been marked as needing your action. If you still believe that this PR
applies, and you intend to address the issues with this PR, just let us
know in the PR itself and we will keep it open pending your changes.


Reply to this email directly or view it on GitHub
#1020 (comment)
.

kesten broughton
devops @ cognitivescale

@gregdek
Copy link
Contributor

gregdek commented Mar 7, 2016

@mcltn A friendly reminder: this pull request has been marked as needing your action. If you still believe that this PR applies, and you intend to address the issues with this PR, just let us know in the PR itself and we will keep it open pending your changes.

@mcltn
Copy link
Contributor Author

mcltn commented Mar 7, 2016

Removed the ability to specify quantity. The example documentation shows how to perform multiple provisions using the loop feature with_items. I'd still like to see a better way to handle the wait flag, since now this would wait for each instance in serial as they build for ones that are flagged. This could cause quite a delay when building a large volume of servers.

@gregdek
Copy link
Contributor

gregdek commented Mar 9, 2016

Thanks @mcltn. Presuming that you still intend to handle diffs from @bcoca above? Leaving in needs_revision for now, but if you feel that it's ready, reply with ready_for_review and we'll put it back into community review.

@mcltn
Copy link
Contributor Author

mcltn commented Mar 10, 2016

ready_for_review

@JulienChampseix
Copy link

any update ? @bcoca @gregdek

@gregdek
Copy link
Contributor

gregdek commented Mar 21, 2016

Thanks @mcltn for this new module. When this module receives 'shipit' comments from two community members and any 'needs_revision' comments have been resolved, we will mark for inclusion.

@bcoca bcoca merged commit b228bfb into ansible:devel Mar 23, 2016
@darKoram
Copy link

@mcltn A little late, but shipit! Sorry, missed your initial request.

@rickji
Copy link

rickji commented Jul 13, 2016

Question: where do I put in the SoftLayer username and APIkey for authentication?

@Blake-
Copy link

Blake- commented Jul 13, 2016

Try putting it in ~/.softlayer
Takes the following form, but with real username & key. Also I think the endpoint may differ a bit depending on what you do?

[softlayer]
username = SL99999
api_key = 80924t2h4ti2h4t2jh4tk2j4thj2kht4j2kht
endpoint_url = https://api.softlayer.com/xmlrpc/v3.1/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.