cloudscale-ch / ansible-collection-cloudscale

cloudscale.ch Ansible Collection
https://galaxy.ansible.com/cloudscale_ch/cloud
GNU General Public License v3.0
7 stars 3 forks source link

Add custom images module #61

Closed ctx closed 3 years ago

href commented 3 years ago

I found two issues that need some attention:

  1. When I specify the following resource on an otherwise empty account, I get an HTTP 405: Method Not Allowed Error. I can image this happens because I don't pass a URL, but I would expect a more descriptive error:
- name: Upload custom alpine image
  cloudscale_ch.cloud.custom_image:
    name: Custom Alpine Image
    slug: alpine
    source_format: raw
    user_data_handling: extend-cloud-config
    zones:
      - lpg1
      - rma1
  1. When I import the image, the return value is different in structure, than if I query the image. I can imagine why this is the case, but as a user I find this surprising. For example, according to the docs, the return value should include a slug. However, this is not the case when I run the following playbook. Only when running it again does it work (in which case the image has already been imported):
#!/usr/bin/env ansible-playbook

- name: Start Alpine Server
  hosts: localhost
  tasks:

    - name: Upload custom alpine image
      cloudscale_ch.cloud.custom_image:
        name: Custom Alpine Image 2
        url: https://at-images.objects.lpg.cloudscale.ch/alpine
        slug: alpine
        source_format: raw
        user_data_handling: extend-cloud-config
        zones:
          - lpg1
          - rma1
      register: custom_image

    - name: Wait until import succeeded
      cloudscale_ch.cloud.custom_image:
        uuid: '{{ custom_image.uuid }}'
        import_status: true
      retries: 15
      delay: 5
      register: import_status
      until: import_status.status == 'success'

    - name: Launch a server with a custom image
      cloudscale_ch.cloud.server:
        name: alpine-test
        image: 'custom:{{ custom_image.slug }}'
        flavor: flex-2
        zone: lpg1