os_floating_ip – Add/Remove floating IP from an instance¶
- Add or Remove a floating IP to an instance.
- Returns the floating IP when attaching only if wait=true.
The below requirements are needed on the host that executes this module.
- openstacksdk >= 0.12.0
- python >= 2.7
- The standard OpenStack environment variables, such as
OS_USERNAMEmay be used instead of providing explicit values.
- Auth information is driven by openstacksdk, which means that values can come from a yaml config file in /etc/ansible/openstack.yaml, /etc/openstack/clouds.yaml or ~/.config/openstack/clouds.yaml, then from standard environment variables, then finally by explicit parameters in plays. More information can be found at https://docs.openstack.org/openstacksdk/
# Assign a floating IP to the fist interface of `cattle001` from an exiting # external network or nova pool. A new floating IP from the first available # external network is allocated to the project. - os_floating_ip: cloud: dguerri server: cattle001 # Assign a new floating IP to the instance fixed ip `192.0.2.3` of # `cattle001`. If a free floating IP is already allocated to the project, it is # reused; if not, a new one is created. - os_floating_ip: cloud: dguerri state: present reuse: yes server: cattle001 network: ext_net fixed_address: 192.0.2.3 wait: true timeout: 180 # Assign a new floating IP from the network `ext_net` to the instance fixed # ip in network `private_net` of `cattle001`. - os_floating_ip: cloud: dguerri state: present server: cattle001 network: ext_net nat_destination: private_net wait: true timeout: 180 # Detach a floating IP address from a server - os_floating_ip: cloud: dguerri state: absent floating_ip_address: 203.0.113.2 server: cattle001