Community

Creating servers using Ansible

I am trying to create some servers on one of my datacenters using ansible (2.0) with a modified sample yml playbook, but I am getting an error I can not figure out.

pb_create_servers.yml:

- profitbricks:
  subscription_user: my-email-username
  subscription_passsword: my-password
  datacenter: Ansible Moodle
  name: web%02d.myserver.com
  cores: 2
  ram: 2048
  volume_size: 10
  image: a3eae284-a2fe-11e4-b187-5f1f641608c8
  location: de/fra
  count: 2
  assign_public_ip: true

And the error I am getting:

ERROR! 'profitbricks' is not a valid attribute for a Play

Please help

 
  • **bold**
  • _italics_
  • `code`
  • ```code block```
  • # Heading 1
  • ## Heading 2
  • > Quote
 

Give this one a try:

---
- hosts: localhost
  connection: local
  gather_facts: False

  tasks:
    - name: Provision a set of instances
      profitbricks:
         subscription_user: api@spc.com
         subscription_password: ******
         datacenter: Tardis Who
         name: web%02d.stackpointcloud.com
         cores: 4
         ram: 2048
         volume_size: 50
         image: a3eae284-a2fe-11e4-b187-5f1f641608c8
         location: us/lasdev
         count: 3
         assign_public_ip: true
         wait_timeout: 500
      register: profitbricks
    - debug: msg="{{profitbricks}}"
  • Looks like working.

    Due to the latest changes of the profitbricks image system with ssh keys (https://devops.profitbricks.com/api/cloud/v2/) there is an issue as the key attribute is not available in the current ansible module yet.

    At least I get the error: fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: sshKeys"}

    Or fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "failed to create the new volume: (422, u'[(root).properties.image] Passwords/SSH Keys are mandatory for public ProfitBricks Images.')"}

    without.

Hi,

Unfortunately it doesn't work with the provided examples. When I try to use my role created for , I'm getting the "profitbricks required for this module" error message. If I try to use the example from @baldwin or from the official module documentation, getting this error: "module_name": "profitbricks"}, "msg": "failed to set instance state: unsupported operand type(s) for +: 'int' and 'str'" ... Any hints on that ?

Thanks!

Thank you for your reply. Now, I am getting the following error:

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "profitbricks required for this module"}

  • You will need to ensure you have the ProfitBricks Python SDK:

    pip install profitbricks

    -matt

Great. solved that issue.

Now I am getting the following: fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "failed to create the new volume: (422, u\"[(root).properties.image] Resource referenced by 'a3eae284-a2fe-11e4-b187-5f1f641608c8' does not exist\")"}

Where do I get the GUIDs for all the standard images I see on an empty storage device?

Ok. found it :-) I used "pb_datacenter_inventory.py" (more info: https://devops.profitbricks.com/tutorials/use-the-profitbricks-rest-api-with-python-part-1/ ) to get the list of image IDs. I choose one that is available on my location (de/fra). And everything works perfectly! Thank you.

we tried the provided answer, unfortunately without results. AFAIK 'pip install profitbricks' installs only the python module for profitbtricks, but not the ansible module. The ansible module should come with ansible.

Ansible is installed correctly, but still we get the message 'fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "profitbricks required for this module"}''

The error "unsupported operand type(s) for +: 'int' and 'str'" seems to be related to this issue: https://devops.profitbricks.com/community/unable-to-create-servers-with-ansible-2110/