使用Ansible将引导磁盘(如果存在)连接到Gcloud实例
我正在使用Ansible在谷歌云中创建实例,但当我想将现有磁盘连接到新的计算引擎时,我无法将其连接或添加到实例使用Ansible将引导磁盘(如果存在)连接到Gcloud实例,ansible,gcloud,Ansible,Gcloud,我正在使用Ansible在谷歌云中创建实例,但当我想将现有磁盘连接到新的计算引擎时,我无法将其连接或添加到实例 - name: Launch instances gce: instance_names: mongo machine_type: "n1-standard-1" image: "debian-9" service_account_email: "xxxx@xxxx.iam.gserviceaccount.com" credentials_f
- name: Launch instances
gce:
instance_names: mongo
machine_type: "n1-standard-1"
image: "debian-9"
service_account_email: "xxxx@xxxx.iam.gserviceaccount.com"
credentials_file: "gcp-credentials.json"
project_id: "learning"
disk_size: 10
disk_auto_delete: false
preemptible: true
tags: "mongo-server"
register: gce
- name: Wait for SSH for instances
wait_for:
delay: 1
host: "{{ item.public_ip }}"
port: 22
state: started
timeout: 30
with_items: "{{ gce.instance_data }}"
我的错误是:
错误为:libcloud.common.google.resourceExistError:{'domain':'global','message':'The resource'projects/xxx xxx/zones/us-central1-a/disks/mongo'已存在','reason':'alreadyExists'}
是否有任何表单可以使用Ansible配置此选项?为此,我现在使用外部脚本。现有磁盘可以作为“磁盘”属性下的列表提供,第一个条目需要是Boot-dik
- gce:
instance_names: my-test-instance
zone: us-central1-a
machine_type: n1-standard-1
state: present
metadata: '{"db":"postgres", "group":"qa", "id":500}'
tags:
- http-server
- my-other-tag
disks:
- name: disk-2
mode: READ_WRITE
- name: disk-3
mode: READ_ONLY