ngine-io / ansible-collection-cloudstack

CloudStack Ansible Collections
https://galaxy.ansible.com/ngine_io/cloudstack
GNU General Public License v3.0
21 stars 28 forks source link

Network offering: set default network offering #5

Open fprojetto opened 4 years ago

fprojetto commented 4 years ago

Expected behaviour It should be possible to create a CloudStack network with a default network offering when a zone uses basic networking.

Current behaviour It fails with error: Network offering 'DefaultSharedNetworkOffering' not found

cs_network:
  name: "{{ guest_network_name }}"
  zone: "{{ zone_name }}"
  display_text: "{{ guest_network_name }}"
  network_offering: DefaultSharedNetworkOffering
  state: present

Possible solution

Modify the get_network_offering to get the default network offerings as well as the network offerings specific with the zone, merge the two sets, and final loop over the newly created set of network offerings.

Steps to reproduce

# zone
- name: Ensure the zone is created.
  cs_zone:
    name: "{{ zone_name }}"
    dns1: "{{ dns_external }}"
    internal_dns1: "{{ dns_internal }}"
    network_type: Basic
    state: present

# physical network
- name: Ensure the physical network is created.
  cs_physical_network:
    name: "{{ phy_network_name }}"
    zone: "{{ zone_name }}"
    nsps_enabled:
      - VirtualRouter
    state: present

- name: Ensure traffic type Guest is created.
  cs_traffic_type:
    physical_network: "{{ phy_network_name }}"
    zone: "{{ zone_name }}"
    traffic_type: Guest
    state: present

- name: Ensure traffic type Management is created.
  cs_traffic_type:
    physical_network: "{{ phy_network_name }}"
    zone: "{{ zone_name }}"
    traffic_type: Management
    state: present

- name: Ensure the physical network is enabled.
  cs_physical_network:
    name: "{{ phy_network_name }}"
    zone: "{{ zone_name }}"
    nsps_enabled:
      - VirtualRouter
    state: enabled

# guest network
- name: Ensure Guest Network is created.
  form3_cs_network:
    name: "{{ guest_network_name }}"
    zone: "{{ zone_name }}"
    display_text: "{{ guest_network_name }}"
    network_offering: DefaultSharedNetworkOffering
    state: present

Environment Running the version of the module provided with ansible 2.9.6. Running CloudStack 4.13.

resmo commented 4 years ago

Thanks for reporting this issue. Seems you already have a fix in place, may I ask you to make a PR with the fix?

fprojetto commented 4 years ago

Sure. I need to add an integration test for it and I will make a PR.

resmo commented 4 years ago

Hi @FilippoProjetto, if you want to get this in 2.10, the fix should be made before 18th of august.

resmo commented 3 years ago

@filippoprojetto anything I can help you with?