Hello,
I'm branching to a problem with gcp_compute_instance. The server should be
created inside a project that has a shared subnet in custom mode.
These are the individual steps to gather the informations for the network:
- name: "Gather network information for {{ vpc_project }}"
gcp_compute_network_info:
filters:
- name = "{{ vpc_network }}"
project: "{{ vpc_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
register: vpcnetwork
- name: Create dictionary VPCselfLink
set_fact:
VPCselfLink: "{{ VPCselfLink|default({}) | combine( {'selfLink':
vpcnetwork['items'][0].selfLink} ) }}"
- name: "Gather subnet information from project {{ vpc_project }} and
subnetwork {{ vpc_subnetwork }}"
gcp_compute_subnetwork_info:
region: region
project: myproject
filters:
- name = "{{ vpc_subnetwork }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/compute
register: vpcsubnetwork
- name: Create dictionary selfLink
set_fact:
selfLink: "{{ selfLink|default({}) | combine( {'selfLink':
vpcsubnetwork['items'][0].selfLink} ) }}"
- name: "Create IP address for server {{ instancename }}"
gcp_compute_address:
name: "ip-{{ instancename }}"
region: "{{ region }}"
project: "{{ gcp_project }}"
address_type: INTERNAL
subnetwork: "{{ selfLink }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/compute
state: present
register: ipaddress
When I make this call for the network:
network_interfaces:
- network: "{{ VPCselfLink }}"
- network_ip: "{{ ipaddress.address }}"
- subnetwork: "{{ selfLink }}"
I get this error:
Fatal: [localhost]: FAILED! => {"changed": false, "msg": "GCP returned
error: {'error': {'errors': [{'domain': 'global', 'reason': 'invalid',
'message': 'Invalid value for field \\'resource.networkInterfaces[0]\\':
\\'{ \"network\":
\"https://www.googleapis.com/compute/v1/projects/<project>/global/networks/<network>...\\'.
Subnetwork should be specified for custom subnetmode network'}], 'code':
400, 'message': 'Invalid value for field
\\'resource.networkInterfaces[0]\\': \\'{ \"network\":
\"https://www.googleapis.com/compute/v1/projects/sap-shared-vpn/global/networks/vpc-ott...\\'.
Subnetwork should be specified for custom subnetmode network'}}"}
When I make this call for the network:
network_interfaces:
- network_ip: "{{ ipaddress.address }}"
- subnetwork: "{{ selfLink }}"
I get this error:
fatal: [localhost]: FAILED! => {"changed": false, "msg": "GCP returned
error: {'error': {'errors': [{'domain': 'global', 'reason': 'invalid',
'message': \"Invalid value for field
'resource.networkInterfaces[0].network': ''. The referenced network
resource cannot be found.\"}], 'code': 400, 'message': \"Invalid value for
field 'resource.networkInterfaces[0].network': ''. The referenced network
resource cannot be found.\"}}"}
What am I doing wrong? I am grateful for any help.
Thomas from Germany
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/aab13466-d329-4134-9a55-c8ff228303eb%40googlegroups.com.