Community

Unable to create servers with Ansible (2.1.1.0)

Hi all, I was trying to create servers using Ansible following the documentation, whitout any success.

Try #1:

Using a test.yml file with the following content:

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

  tasks:
    - name: Provision a set of instances
      profitbricks:
         subscription_user: “myuser"
         subscription_password: “mypass"
         datacenter: mydatacenter
         name: util-01.mydomain.com
         cores: 4
         ram: 4096
         volume_size: 50
         image: a3eae284-a2fe-11e4-b187-5f1f641608c8
         location: de/fra
         count: 1
         assign_public_ip: true
         wait_timeout: 300
      register: profitbricks
    - debug: msg="{{profitbricks}}"

Running with "ansible-playbook test.yml -vvv" getting the following error :

..."module_name": "profitbricks"}, "msg": "failed to set instance state: unsupported operand type(s) for +: 'int' and 'str'"}

Test #2: Created a role and using inventory file and group_vars with a "deploy-environment.yml" file with the following content:

    ---
- hosts: localhost
  become: yes
  connection: local
  gather_facts: False
  roles:
    - { role: profitbricks, tags: ["profitbricks_create"] }

And running with "ansible-playbook -i inventory/myenvironment deploy-environment.yml -vvv" getting the following error:

"msg": "profitbricks required for this module"

Some basic infos:

    ansible --version
ansible 2.1.1.0

    pip list |grep profitbricks
profitbricks (2.3.4)

 python -V
Python 2.7.10

Any hint would be appreciated.

Best regards,

 
  • Same for ansible 2.0 . Did anyone get this working ?

    Thanks!

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

I was contributing some updates (ssh_keys, cpu_family, etc.) to the ProfitBricks cloud module when I encountered the same error that you describe. It appears the parameter types must now be declared. What was once treated as an integer now seems to be treated as a string. In this case, the count parameter. I was able correct the issue by setting the variable type for the module parameter.

A bug fix (along with my other updates) have been committed to the profitbricks_new_features branch which can be found here:

https://github.com/profitbricks/ansible-modules-extras/tree/profitbricks_new_features

I am currently working to have my updates merged upstream, but you are welcome to pull down my branch and try it out. The only two files changed in the branch:

./cloud/profitbricks/profitbricks.py
./cloud/profitbricks/profitbricks_volume.py

You could easily swap them out on your local host. Please let me know if you have any questions or need further assistance.

I have the same issue. Is there any progress on this? How can I get the changes? I couldn't find any profitbricks.py on my localhost.

  • Hi Robert,

    Can you try out Ansible 2.2.0.0? It has the changes that are mentioned above already included.

    The files profitbricks.py and profitbricks_volume.py are located in /usr/local/lib/python2.7/dist-packages/ansible/modules/extras/cloud/profitbricks/ on a fresh Ubuntu 16.10 install after installing Ansible using pip. You should NOT need to swap them out if you use Ansible v2.2.0.0 or greater as the updated versions are already included.

    In order for this to work, you also need to have the ProfitBricks Python SDK installed. It can be installed by running sudo pip install profitbricks.

    I'm working on making some updates to the Ansible Cloud Extras Module documentation on this site to make this clearer and hopefully easier to get up and running.

    Due to changes in the Cloud API regarding volumes, you'll need to supply one or both of the parameters:

    image_password: "Random 8-50 character string"
    ssh_keys: "ssh-rsa AAAA...."
    

    when using the Profitbricks Ansible Cloud Extras module to provision Linux servers using one of the ProfitBricks supplied images. The image id's for those change periodically as updates are made. There is a tutorial about Using the Python SDK Part I that includes a link at the bottom to a pb_datacenter_inventory.py script that can help you get a list of the current image ids. There are other ways to get the image ids, but this is fairly convenient since you must have the Python SDK installed in order to use the Ansible Profitbricks Cloud Extras module.

    Eric

Many Thanks for the detailed answer. That is very helpful! I just updated Ansible to version 2.2.X and the module works now. But now I'm getting the error message that The requested resource could not be found.Template not found.. There can I find a list of valid images names I can use for provisioning? It seems that a3eae284-a2fe-11e4-b187-5f1f641608c8 is not valid.

Hello Robert,

The ProfitBricks image UUIDs change nearly every month due to routine updates. The image is replaced which will result in a new UUID, but the name typically stays the same. When I need a list of images, I use one of two methods. I either query the API directly with curl, a browser, or other HTTP client:

curl -u [username] https://api.profitbricks.com/cloudapi/v3/images?depth=2

Or I will use the the ProfitBricks CLI:

profitbricks image list

There was talk about ProfitBricks releasing a feature where the latest image revision can be retrieved regardless of the UUID, but I'm not sure when that API update will be released. The SDKs and tools would then need to be updated to support the feature.