Trying to create a gcp instance with ansible following the steps from this github link.
playbook:
---
- hosts: localhost
connection: local
tasks:
- name: creating instance
gcp_compute_instance:
name: ansible instance
machine_type: e2-micro
disks:
- auto_delete: true
boot: true
initialize_params:
source_image: projects/debian-cloud/global/images/family/debian-11
network_interfaces:
- access_configs:
- name: External NAT
type: ONE_TO_ONE_NAT
metadata:
startup-script: |
#!/bin/bash
sudo yum install httpd -y
sudo echo "HELLO WORLD !!" > /var/www/html/index.html
sudo systemctl restart httpd
zone: us-central1-a
project: capstone-project-347806
auth_kind: serviceaccount
service_account_file: service.json
state: present
output:
PLAY [localhost] ****************************************************************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************************** ok: [localhost]
TASK [creating instance] ******************************************************************************************************************************************************************** fatal: [localhost]: FAILED! => {"changed": false, "msg": "GCP returned error: {u'error': {u'message': u"Invalid value for field 'instance': 'ansible instance'. Must be a match of regex 'a-z?|[1-9][0-9]{0,19}'", u'code': 400, u'errors': [{u'reason': u'invalid', u'message': u"Invalid value for field 'instance': 'ansible instance'. Must be a match of regex 'a-z?|[1-9][0-9]{0,19}'", u'domain': u'global'}]}}"}
PLAY RECAP ********************************************************************************************************************************************************************************** localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0