3434 interface_ip:
3535 required: true
3636 description: The fixed IP to set to the interface
37- interface_network_id :
37+ interface_openstack_id :
3838 required: true
39- description: The network id to attache the interface to
39+ description:
40+ - The network's openstack id to attache the interface to
41+ - This is returned by a call to public_cloud_private_network_info.
4042'''
4143
4244EXAMPLES = r'''
4547 service_name: "{{ service_name }}"
4648 instance_id: "{{ instance_id }}"
4749 interface_ip: "{{ network_vrack.ip }}"
48- interface_network_id : "{{ network_vrack.network_id }}"
50+ interface_openstack_id : "{{ network_info.openstack_id }}"
4951 delegate_to: localhost
5052 register: interface_metadata
5153
@@ -63,7 +65,7 @@ def run_module():
6365 instance_id = dict (required = True ),
6466 state = dict (choices = ['present' , 'absent' ], default = 'present' ),
6567 interface_ip = dict (required = True ),
66- interface_network_id = dict (required = True )
68+ interface_openstack_id = dict (required = True )
6769 ))
6870
6971 module = AnsibleModule (
@@ -76,21 +78,21 @@ def run_module():
7678 instance_id = module .params ['instance_id' ]
7779 state = module .params ['state' ]
7880 interface_ip = module .params ['interface_ip' ]
79- interface_network_id = module .params ['interface_network_id ' ]
81+ interface_openstack_id = module .params ['interface_openstack_id ' ]
8082
8183 if module .check_mode :
8284 module .exit_json (msg = "Ensure interface {} on {} is {} on instance id {} - (dry run mode)"
83- .format (interface_ip , interface_network_id , state , instance_id ),
85+ .format (interface_ip , interface_openstack_id , state , instance_id ),
8486 changed = True )
8587
8688 if state == 'absent' :
8789 # Need to get the interface id (via /cloud/project/{serviceName}/instance/{instanceId}/interface).
8890 # How to manage multiple interfaces ?
8991 module .fail_json (msg = "Removing an interface is not yet implemented" )
9092 if state == 'present' :
91- result = client .wrap_call ("POST" , f"/cloud/project/{ service_name } /instance/{ isinstance } /interface" ,
93+ result = client .wrap_call ("POST" , f"/cloud/project/{ service_name } /instance/{ instance_id } /interface" ,
9294 ip = interface_ip ,
93- networkId = interface_network_id )
95+ networkId = interface_openstack_id )
9496 module .exit_json (
9597 changed = True ,
9698 msg = "Interface has been attached to instance id {}" .format (
0 commit comments