rax_scaling_group fails to create scaling group

Hi,

Following the example here http://docs.ansible.com/rax_scaling_group_module.html#examples fails with the message pasted at the end.

Versions:
ansible 1.8.2
pyrax-1.9.3

Playbook:

tasks:

  • name: Load Balancer create request
    rax_clb:
    credentials: ~/.rax.creds
    name: LB Test
    port: 80
    protocol: HTTP
    algorithm: LEAST_CONNECTIONS
    type: PUBLIC
    timeout: 30
    region: LON
    wait: yes
    state: present
    register: lb

  • name: provision the autoscaling group
    rax_scaling_group:
    credentials: ~/.rax.creds
    region: LON
    cooldown: 300
    flavor: general1-1
    image: “CentOS 6.5 (PVHVM)”
    min_entities: 2
    max_entities: 5
    name: ASG Test
    server_name: asgtest
    loadbalancers:

  • id: “{{ lb.balancer.id }}”
    port: “{{ lb.balancer.port }}”
    state: present
    register: asg

This has been recreated by Benno Joy from Ansible support, who said:
"it seems the issue with utf encoding, in the playbook the lb id and lb port are templated hence they are converted to uff , but it seem like the module or the api doesnt work well with the encoding. "
He provided a “fixed” version of the module, and running it from a library directory at the same level as the playbook, the fix works.

Is this something that needs to be fixed in the original module?

Thanks in advance,
David

failed: [localhost] => {“failed”: true}
msg: {u’args’: {u’loadBalancers’: [{u’port’: u’80’, u’loadBalancerId’: u’123005’}], u’server’: {u’name’: u’asgtest’, u’imageRef’: u’7e746552-2212-41d7-b216-a1024b83b0c4’, u’flavorRef’: u’general1-1’, u’metadata’: {}, u’networks’: [{u’uuid’: u’00000000-0000-0000-0000-000000000000’}, {u’uuid’: u’11111111-1111-1111-1111-111111111111’}], u’personality’: }}, u’type’: u’launch_server’} is not of type {‘type’: ‘object’, ‘description’: “‘Launch Server’ launch configuration options. This type of launch configuration will spin up a next-gen server directly with the provided arguments, and add the server to one or more load balancers (if load balancer arguments are specified.”, ‘properties’: {‘args’: {‘additionalProperties’: False, ‘properties’: {‘loadBalancers’: {‘description’: ‘One or more load balancers to add new servers to. All servers will be added to these load balancers with their ServiceNet addresses, and will be enabled, of primary type, and equally weighted. If new servers are not connected to the ServiceNet, they will not be added to any load balancers.’, ‘minItems’: 0, ‘items’: {‘type’: [{‘additionalProperties’: False, ‘type’: ‘object’, ‘description’: ‘One load balancer all new servers should be added to.’, ‘properties’: {‘type’: {‘oneOf’: [‘CloudLoadBalancer’], ‘required’: False, ‘type’: ‘string’, ‘description’: ‘What type of a load balancer is in use’}, ‘port’: {‘required’: True, ‘type’: ‘integer’, ‘description’: ‘The port number of the service (on the new servers) to load balance on for this particular load balancer.’}, ‘loadBalancerId’: {‘required’: True, ‘type’: ‘integer’, ‘description’: ‘The ID of the load balancer to which new servers will be added.’}}}, {‘additionalProperties’: False, ‘type’: ‘object’, ‘description’: ‘One load balancer all new servers should be added to.’, ‘properties’: {‘type’: {‘oneOf’: [‘RackConnectV3’], ‘required’: True, ‘type’: ‘string’, ‘description’: ‘What type of a load balancer is in use’}, ‘loadBalancerId’: {‘pattern’: ‘^\S+$’, ‘required’: True, ‘type’: ‘string’, ‘description’: ‘The ID of the load balancer to which new servers will be added.’}}}]}, ‘required’: False, ‘maxItems’: 5, ‘uniqueItems’: True, ‘type’: ‘array’}, ‘server’: {‘required’: True, ‘type’: [{‘type’: ‘object’, ‘properties’: {‘imageRef’: {‘type’: [‘string’, ‘null’], ‘maxLength’: 0}, ‘block_device_mapping’: {‘items’: {‘type’: ‘object’}, ‘required’: True, ‘type’: ‘array’}}}, {‘type’: ‘object’, ‘properties’: {‘imageRef’: {‘pattern’: ‘^\S+$’, ‘required’: True, ‘type’: ‘string’}}}], ‘description’: ‘Attributes to provide to nova create server: http://docs.rackspace.com/servers/api/v2/cs-devguide/content/CreateServers.html.Whatever attributes are passed here will apply to all new servers (including the name attribute).’, ‘properties’: {‘flavorRef’: {‘minLength’: 1, ‘required’: True, ‘type’: ‘string’, ‘pattern’: ‘^\S+$’}, ‘personality’: {‘items’: {‘type’: ‘object’, ‘properties’: {‘path’: {‘minLength’: 1, ‘required’: True, ‘type’: ‘string’, ‘maxLength’: 255}, ‘contents’: {‘required’: True, ‘type’: ‘string’}}}, ‘required’: False, ‘type’: ‘array’}, ‘metadata’: {‘required’: False, ‘type’: [{‘additionalProperties’: False, ‘patternProperties’: {‘[1]{1,255}$’: {‘type’: ‘string’, ‘maxLength’: 255}}, ‘type’: ‘object’}, ‘null’]}, ‘imageRef’: {}, ‘block_device_mapping’: {‘items’: {‘type’: ‘object’}, ‘type’: ‘array’}}}}}, ‘type’: {‘enum’: [‘launch_server’]}}}


  1. a-zA-Z0-9-_:. ↩︎

The issue is due to the values for the loadbalancer ID and loadbalancer port needing to be integer values. In your case, when referencing variables, they are being passed in as strings.

I’ve made an update to the module and created a pull request that I will merge soon: https://github.com/ansible/ansible-modules-core/pull/492

The above changes should resolve your issue.