Documentation

os_port - Add/Update/Delete ports from an OpenStack cloud.

New in version 2.0.

Synopsis

  • Add, Update or Remove ports from an OpenStack cloud. A state of ‘present’ will ensure the port is created or updated if required.

Options

parameter required default choices comments
admin_state_up
no None
Sets admin state.
allowed_address_pairs
no None
Allowed address pairs list. Allowed address pairs are supported with dictionary structure. e.g. allowed_address_pairs: - ip_address: 10.1.0.12 mac_address: ab:cd:ef:12:34:56 - ip_address: ...
api_timeout
no None
How long should the socket layer wait before timing out for API calls. If this is omitted, nothing will be passed to the requests library.
auth
no
Dictionary containing auth information as needed by the cloud's auth plugin strategy. For the default password plugin, this would contain auth_url, username, password, project_name and any information about domains if the cloud supports them. For other plugins, this param will need to contain whatever parameters that auth plugin requires. This parameter is not needed if a named cloud is provided or OpenStack OS_* environment variables are present.
auth_type
no password
Name of the auth plugin to use. If the cloud uses something other than password authentication, the name of the plugin should be indicated here and the contents of the auth parameter should be updated accordingly.
availability_zone
no
Ignored. Present for backwards compatability
cacert
no None
A path to a CA Cert bundle that can be used as part of verifying SSL API requests.
cert
no None
A path to a client certificate to use as part of the SSL transaction.
cloud
no
Named cloud to operate against. Provides default values for auth and auth_type. This parameter is not needed if auth is provided or if OpenStack OS_* environment variables are present.
device_id
no None
Device ID of device using this port.
device_owner
no None
The ID of the entity that uses this port.
endpoint_type
no public
  • public
  • internal
  • admin
Endpoint URL type to fetch from the service catalog.
extra_dhcp_opts
no None
Extra dhcp options to be assigned to this port. Extra options are supported with dictionary structure. e.g. extra_dhcp_opts: - opt_name: opt name1 opt_value: value1 - opt_name: ...
fixed_ips
no None
Desired IP and/or subnet for this port. Subnet is referenced by subnet_id and IP is referenced by ip_address.
key
no None
A path to a client key to use as part of the SSL transaction.
mac_address
no None
MAC address of this port.
name
no None
Name that has to be given to the port.
network
yes
Network ID or name this port belongs to.
no_security_groups
no
Do not associate a security group with this port.
region_name
no
Name of the region.
security_groups
no None
Security group(s) ID(s) or name(s) associated with the port (comma separated string or YAML list)
state
no present
  • present
  • absent
Should the resource be present or absent.
timeout
no 180
How long should ansible wait for the requested resource.
validate_certs
no
Whether or not SSL API requests should be verified. Before 2.3 this defaulted to True.

aliases: verify
wait
no yes
  • yes
  • no
Should ansible wait until the requested resource is complete.

Examples

# Create a port
- os_port:
    state: present
    auth:
      auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/
      username: admin
      password: admin
      project_name: admin
    name: port1
    network: foo

# Create a port with a static IP
- os_port:
    state: present
    auth:
      auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/
      username: admin
      password: admin
      project_name: admin
    name: port1
    network: foo
    fixed_ips:
      - ip_address: 10.1.0.21

# Create a port with No security groups
- os_port:
    state: present
    auth:
      auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/
      username: admin
      password: admin
      project_name: admin
    name: port1
    network: foo
    no_security_groups: True

# Update the existing 'port1' port with multiple security groups (version 1)
- os_port:
    state: present
    auth:
      auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/d
      username: admin
      password: admin
      project_name: admin
    name: port1
    security_groups: 1496e8c7-4918-482a-9172-f4f00fc4a3a5,057d4bdf-6d4d-472...

# Update the existing 'port1' port with multiple security groups (version 2)
- os_port:
    state: present
    auth:
      auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/d
      username: admin
      password: admin
      project_name: admin
    name: port1
    security_groups:
      - 1496e8c7-4918-482a-9172-f4f00fc4a3a5
      - 057d4bdf-6d4d-472...

Return Values

Common return values are documented here Return Values, the following are the fields unique to this module:

name description returned type sample
status Port's status. success string
name Name given to the port. success string
allowed_address_pairs Allowed address pairs with this port. success list of dicts
admin_state_up Admin state up flag for this port. success bool
network_id Network ID this port belongs in. success string
tenant_id Tenant id associated with this port. success string
fixed_ips Fixed ip(s) associated with this port. success list of dicts
id Unique UUID. success string
security_groups Security group(s) associated with this port. success list of strings


Notes

Note

  • The standard OpenStack environment variables, such as OS_USERNAME may be used instead of providing explicit values.
  • Auth information is driven by os-client-config, 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 http://docs.openstack.org/developer/os-client-config

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Support

This module is community maintained without core committer oversight.

For more information on what this means please read Module Support

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.