Ansible gce模块:使用自定义磁盘大小创建实例

时间:2015-12-22 09:02:07

标签: python ansible google-compute-engine

我想用带有100 GB磁盘的ansible gce模块创建google计算实例。但是gce模块中没有用于在gce模块中设置实例的磁盘大小的配置。

我知道我们可以通过使用gce_pd模块创建磁盘然后附加到新实例来解决这个问题,但有没有正确的方法呢?

支持它非常简单,因为lib cloud lib已经支持这个参数。

1 个答案:

答案 0 :(得分:0)

It doesn't seem to be possible directly, but the gce module uses the first item in disks as the boot image (see code).

So you can create a customized boot disk as follows:

- name: Create custom boot disk
  gce_pd:
    name: "{{ instance_name }}"
    image: "{{ instance_image }}"
    size_gb: "{{ disk_size }}"
    zone: "{{ zone  }"

- name: Launch instance with custom boot disk
  gce:
    name: "{{ instance_name }}"
    image: "{{ instance_image }}"
    zone: "{{ zone }}"
    disks:
      - name: "{{ instance_name }}"
        mode: READ_WRITE