# \[os\_port\] Add allowed-address-pairs to an existing openstack server port

**URL:** <https://forum.ansible.com/t/os-port-add-allowed-address-pairs-to-an-existing-openstack-server-port/21018>\
**Category:** Ansible Project\
**Created:** [March 30, 2016, 10:29am UTC](https://forum.ansible.com/t/os-port-add-allowed-address-pairs-to-an-existing-openstack-server-port/21018 "2016-03-30T10:29:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jorge\_L](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@Jorge\_L](https://forum.ansible.com/u/Jorge_L)\
**Post date:** [March 30, 2016, 10:29am UTC](https://forum.ansible.com/t/os-port-add-allowed-address-pairs-to-an-existing-openstack-server-port/21018/1 "2016-03-30T10:29:47Z")

</div>

I want to set up nginx HA with keepalived and I’m preparing an ansible role for this purpose in an openstack environment (I’m using ansible 2). I would like to update the server port, that is already existing, to add allowed\_address\_pairs with a single pair (the virtual IP and the host mac address).  
I have two problems:

- How to get the port\_id (to update the port with os\_port). I cannot get this id in any facts.
- How to get the information of that port in order to update only the allowed\_address\_pairs.

I know how to implement it in shell but it would be nice to use only ansible commands. Any hint how to achieve it?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Martin\_Smithson](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Martin\_Smithson](https://forum.ansible.com/u/Martin_Smithson)\
**Post date:** [June 10, 2016, 9:57am UTC](https://forum.ansible.com/t/os-port-add-allowed-address-pairs-to-an-existing-openstack-server-port/21018/2 "2016-06-10T09:57:14Z")

</div>

If you are using Ansible 2.1 you should be able to use the os\_port\_facts module.

Once you have the id of the port, you can use the os\_port module to update the allowed\_address\_pairs, for example:

- name: Update the allowed\_address\_pairs for the original port

local\_action:

module: os\_port

name: “{{ original\_port\_id }}”

state: present

allowed\_address\_pairs:

- ip\_address: “{{ ansible\_default\_ipv4.address }}”

- ip\_address: “{{ load\_balancer\_port.port.fixed\_ips[0].ip\_address }}”
