From 776790448fcccecf187c4a23c0ef8abc64a7dde2 Mon Sep 17 00:00:00 2001 From: Youjung Kim <126618609+ykim-1@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:46:08 -0700 Subject: [PATCH 1/9] test: refactor all integration tests for consistency (#490) * refactor all integration tests for consistency and fix some intermittent failures * missed couple * update gitsubmodule --- .../account_availability_info/tasks/main.yaml | 5 +- .../account_availability_list/tasks/main.yaml | 6 +- .../targets/api_request_basic/tasks/main.yaml | 29 ++++--- .../targets/api_request_extra/tasks/main.yaml | 8 +- .../database_engine_list/tasks/main.yaml | 10 ++- .../targets/domain_basic/tasks/main.yaml | 19 +++-- .../targets/domain_list/tasks/main.yaml | 18 +++-- .../targets/domain_record/tasks/main.yaml | 80 +++++++++++-------- .../targets/domain_zone_file/tasks/main.yaml | 12 +-- .../targets/event_list/tasks/main.yaml | 10 ++- .../targets/firewall_basic/tasks/main.yaml | 28 +++---- .../targets/firewall_device/tasks/main.yaml | 15 ++-- .../targets/firewall_icmp/tasks/main.yaml | 8 +- .../targets/firewall_list/tasks/main.yaml | 10 ++- .../targets/firewall_update/tasks/main.yaml | 1 + .../targets/image_basic/tasks/main.yaml | 25 +++--- .../targets/image_list/tasks/main.yaml | 16 ++-- .../targets/image_upload/tasks/main.yaml | 9 ++- .../instance_config_disk/tasks/main.yaml | 15 ++-- .../tasks/main.yaml | 15 ++-- .../instance_config_vlan/tasks/main.yaml | 8 +- .../instance_disk_stackscript/tasks/main.yaml | 15 ++-- .../instance_interfaces_vpc/tasks/main.yaml | 3 +- .../playbooks/test_inventory_filter.yml | 3 +- .../test_inventory_templatetoken.yml | 3 +- .../targets/instance_list/tasks/main.yaml | 8 +- .../instance_region_migration/tasks/main.yaml | 18 +++-- .../targets/instance_timeout/tasks/main.yaml | 3 +- .../instance_type_change/tasks/main.yaml | 23 ++++-- .../instance_type_list/tasks/main.yaml | 8 +- .../targets/ip_assign/tasks/main.yml | 6 +- .../targets/ip_info/tasks/main.yaml | 8 +- .../targets/ip_rdns/tasks/main.yaml | 6 +- .../targets/ip_share/tasks/main.yaml | 12 +-- .../targets/ipv6_range_info/tasks/main.yaml | 11 ++- .../targets/lke_cluster_basic/tasks/main.yaml | 19 +++-- .../lke_cluster_info_ro/tasks/main.yaml | 12 ++- .../lke_node_pool_basic/tasks/main.yaml | 9 ++- .../targets/lke_version_list/tasks/main.yaml | 5 +- .../targets/mysql_basic/tasks/main.yaml | 22 +++-- .../targets/mysql_complex/tasks/main.yaml | 9 ++- .../nodebalancer_basic/tasks/main.yaml | 9 ++- .../targets/nodebalancer_list/tasks/main.yaml | 6 +- .../targets/nodebalancer_node/tasks/main.yaml | 33 +++++--- .../targets/postgresql_basic/tasks/main.yaml | 15 ++-- .../postgresql_complex/tasks/main.yaml | 9 ++- .../targets/profile_info/tasks/main.yaml | 5 +- .../targets/region_list/tasks/main.yaml | 9 ++- .../targets/ssh_key/tasks/main.yaml | 6 +- .../targets/ssh_key_info/tasks/main.yaml | 12 +-- .../targets/ssh_key_list/tasks/main.yaml | 17 ++-- .../targets/stackscript_basic/tasks/main.yaml | 9 ++- .../targets/stackscript_info/tasks/main.yaml | 9 ++- .../targets/stackscript_list/tasks/main.yaml | 6 +- .../targets/token_info/tasks/main.yaml | 3 +- .../targets/token_list/tasks/main.yaml | 6 +- .../targets/type_info/tasks/main.yaml | 3 +- .../targets/type_list/tasks/main.yaml | 3 +- .../targets/user_grants/tasks/main.yaml | 6 +- .../targets/user_list/tasks/main.yaml | 3 +- .../targets/vlan_list/tasks/main.yaml | 3 +- .../targets/volume_list/tasks/main.yaml | 8 +- tod_scripts | 2 +- 63 files changed, 461 insertions(+), 271 deletions(-) diff --git a/tests/integration/targets/account_availability_info/tasks/main.yaml b/tests/integration/targets/account_availability_info/tasks/main.yaml index 1ba63e8d..e7e39dc0 100644 --- a/tests/integration/targets/account_availability_info/tasks/main.yaml +++ b/tests/integration/targets/account_availability_info/tasks/main.yaml @@ -1,11 +1,12 @@ - name: account_availability_info block: - - name: Get info about the current account availability + - name: GET account_availability_info request linode.cloud.account_availability_info: region: us-east register: account_availability - - assert: + - name: Assert GET account_availability_info response + assert: that: - account_availability.account_availability.region == "us-east" diff --git a/tests/integration/targets/account_availability_list/tasks/main.yaml b/tests/integration/targets/account_availability_list/tasks/main.yaml index 77f7bcd5..8bb9ee6c 100644 --- a/tests/integration/targets/account_availability_list/tasks/main.yaml +++ b/tests/integration/targets/account_availability_list/tasks/main.yaml @@ -1,10 +1,12 @@ - name: account_availability_list block: - - linode.cloud.account_availability_list: + - name: GET account_availability_list request w no filter + linode.cloud.account_availability_list: count: 5 register: no_filter - - assert: + - name: Assert GET account_availability_list response w no filter + assert: that: - no_filter.account_availabilities | length == 5 diff --git a/tests/integration/targets/api_request_basic/tasks/main.yaml b/tests/integration/targets/api_request_basic/tasks/main.yaml index a22be934..fdb1a067 100644 --- a/tests/integration/targets/api_request_basic/tasks/main.yaml +++ b/tests/integration/targets/api_request_basic/tasks/main.yaml @@ -1,20 +1,23 @@ -- name: api_request_baisc +- name: api_request_basic block: - set_fact: r: "{{ 1000000000 | random }}" - - linode.cloud.api_request: + - name: GET api_request request + linode.cloud.api_request: # Arbitrary authorized endpoint path: lke/versions method: GET register: response_get - - assert: + - name: Assert GET api_request response + assert: that: - response_get.status == 200 - response_get.changed == False - - linode.cloud.api_request: + - name: POST api_request request + linode.cloud.api_request: path: domains method: POST body: @@ -23,25 +26,29 @@ soa_email: ansible@example.com register: response_post - - assert: + - name: Assert POST api_request response + assert: that: - response_post.status == 200 - response_post.changed == True - - linode.cloud.api_request: + - name: PUT api_request request + linode.cloud.api_request: path: 'domains/{{ response_post.body.id }}' method: PUT body: description: cool register: response_put - - assert: + - name: Assert PUT api_request response + assert: that: - response_put.status == 200 - response_put.changed == True - response_put.body.description == 'cool' - - linode.cloud.api_request: + - name: PUT api_request request (negative case) + linode.cloud.api_request: path: 'reallycoolfakepath' method: PUT register: response_failed @@ -49,12 +56,14 @@ always: - ignore_errors: yes block: - - linode.cloud.api_request: + - name: DELETE api_request request + linode.cloud.api_request: path: 'domains/{{ response_post.body.id }}' method: DELETE register: response_delete - - assert: + - name: Assert DELETE api_request response + assert: that: - response_delete.status == 200 - response_delete.changed == True diff --git a/tests/integration/targets/api_request_extra/tasks/main.yaml b/tests/integration/targets/api_request_extra/tasks/main.yaml index 10bff047..af260e0d 100644 --- a/tests/integration/targets/api_request_extra/tasks/main.yaml +++ b/tests/integration/targets/api_request_extra/tasks/main.yaml @@ -5,11 +5,11 @@ - set_fact: r: "{{ 1000000000 | random }}" - - name: List all available Linode regions + - name: GET region_list request linode.cloud.region_list: register: regions - - name: Create a volume by the api_request module + - name: POST volume request linode.cloud.api_request: path: "/volumes" method: POST @@ -29,7 +29,7 @@ always: - ignore_errors: true block: - - name: Delete the volume + - name: DELETE volume request linode.cloud.volume: label: '{{ response.body.label }}' state: absent @@ -38,7 +38,7 @@ retries: 5 delay: 10 - - name: Assert the volume was deleted + - name: Assert volume deleted assert: that: - delete_volume.changed diff --git a/tests/integration/targets/database_engine_list/tasks/main.yaml b/tests/integration/targets/database_engine_list/tasks/main.yaml index 54fd61a8..52af67bf 100644 --- a/tests/integration/targets/database_engine_list/tasks/main.yaml +++ b/tests/integration/targets/database_engine_list/tasks/main.yaml @@ -1,21 +1,23 @@ - name: database_engine_list block: - - name: List database engines with no filter + - name: List database_engine_list with no filter linode.cloud.database_engine_list: register: no_filter - - assert: + - name: Assert database_engine_list with no filter + assert: that: - no_filter.database_engines | length >= 1 - - name: List database engines with filter on engine + - name: List database_engine_list with filter on engine linode.cloud.database_engine_list: filters: - name: engine values: mysql register: filter - - assert: + - name: Assert List database_engine_list with filter on engine + assert: that: - filter.database_engines | length >= 1 - filter.database_engines[0].engine == 'mysql' diff --git a/tests/integration/targets/domain_basic/tasks/main.yaml b/tests/integration/targets/domain_basic/tasks/main.yaml index 692cba4b..2ca5951b 100644 --- a/tests/integration/targets/domain_basic/tasks/main.yaml +++ b/tests/integration/targets/domain_basic/tasks/main.yaml @@ -3,7 +3,7 @@ - set_fact: r: "{{ 1000000000 | random }}" - - name: Create a domain + - name: Create domain linode.cloud.domain: description: 'really cool domain' domain: 'ansible-test-domain-{{ r }}.com' @@ -19,7 +19,8 @@ state: present register: create - - assert: + - name: Assert domain is created + assert: that: - create.domain.description == 'really cool domain' - create.domain.expire_sec == 300 @@ -31,7 +32,7 @@ - create.domain.ttl_sec == 14400 - create.domain.type == 'master' - - name: Update a domain + - name: Update domain label linode.cloud.domain: description: 'really cool' domain: '{{ create.domain.domain }}' @@ -47,7 +48,8 @@ state: present register: update - - assert: + - name: Assert domain is updated + assert: that: - update.domain.description == 'really cool' - update.domain.expire_sec == 14400 @@ -59,12 +61,13 @@ - update.domain.ttl_sec == 604800 - update.domain.type == 'slave' - - name: Get domain info + - name: Get domain_info linode.cloud.domain_info: domain: '{{ create.domain.domain }}' register: info - - assert: + - name: Assert domain_info response + assert: that: - info.domain.description == 'really cool' - info.domain.expire_sec == 14400 @@ -79,13 +82,13 @@ always: - ignore_errors: yes block: - - name: Delete the domain + - name: Delete domain linode.cloud.domain: domain: '{{ create.domain.domain }}' state: absent register: delete - - name: Assert domain delete succeeded + - name: Assert domain is deleted assert: that: - delete.changed diff --git a/tests/integration/targets/domain_list/tasks/main.yaml b/tests/integration/targets/domain_list/tasks/main.yaml index 27b6f571..b579c0ff 100644 --- a/tests/integration/targets/domain_list/tasks/main.yaml +++ b/tests/integration/targets/domain_list/tasks/main.yaml @@ -3,7 +3,7 @@ - set_fact: r: "{{ 1000000000 | random }}" - - name: Create a domain + - name: Create domain linode.cloud.domain: description: 'really cool domain' domain: 'ansible-test-domain-{{ r }}.com' @@ -19,7 +19,7 @@ state: present register: create - - name: Assert domain created + - name: Assert domain is created assert: that: - create.domain.description == 'really cool domain' @@ -32,15 +32,16 @@ - create.domain.ttl_sec == 14400 - create.domain.type == 'master' - - name: List domains with no filter + - name: List domain_list with no filter linode.cloud.domain_list: register: no_filter - - assert: + - name: Assert domain_list with no filter + assert: that: - no_filter.domains | length >= 1 - - name: List domains with filter on domain + - name: List domain_list with filter on domain linode.cloud.domain_list: order_by: created order: desc @@ -49,20 +50,21 @@ values: ansible-test-domain-{{ r }}.com register: filter - - assert: + - name: Assert domain_list with filter on domain + assert: that: - filter.domains | length >= 1 - filter.domains[0].domain == 'ansible-test-domain-{{ r }}.com' always: - ignore_errors: yes block: - - name: Delete the domain + - name: Delete domain linode.cloud.domain: domain: '{{ create.domain.domain }}' state: absent register: delete - - name: Assert domain delete succeeded + - name: Assert domain is deleted assert: that: - delete.changed diff --git a/tests/integration/targets/domain_record/tasks/main.yaml b/tests/integration/targets/domain_record/tasks/main.yaml index b02b0b73..fee9f8be 100644 --- a/tests/integration/targets/domain_record/tasks/main.yaml +++ b/tests/integration/targets/domain_record/tasks/main.yaml @@ -3,7 +3,7 @@ - set_fact: r: "{{ 1000000000 | random }}" - - name: Create a domain + - name: Create domain linode.cloud.domain: domain: 'ansible-test-domain-{{ r }}.com' soa_email: 'realemail@example.com' @@ -11,13 +11,14 @@ state: present register: domain_create - - assert: + - name: Assert domain is created + assert: that: - domain_create.domain.soa_email == 'realemail@example.com' - domain_create.domain.status == 'active' - domain_create.domain.type == 'master' - - name: Create a domain record + - name: Create domain_record linode.cloud.domain_record: domain: '{{ domain_create.domain.domain }}' name: 'sub' @@ -28,7 +29,8 @@ state: present register: record_create - - assert: + - name: Assert domain_record is created + assert: that: - record_create.record.name == 'sub' - record_create.record.type == 'A' @@ -36,7 +38,7 @@ - record_create.record.ttl_sec == 3600 - record_create.record.weight == 55 - - name: Update the domain record + - name: Update domain_record linode.cloud.domain_record: domain: '{{ domain_create.domain.domain }}' record_id: '{{ record_create.record.id }}' @@ -45,7 +47,8 @@ state: present register: record_update - - assert: + - name: Assert domain_record is updated + assert: that: - record_update.record.id == record_create.record.id - record_update.record.name == 'sub' @@ -54,13 +57,14 @@ - record_update.record.ttl_sec == 14400 - record_update.record.weight == 62 - - name: Get info about the record + - name: Get domain_record_info linode.cloud.domain_record_info: domain: '{{ domain_create.domain.domain }}' name: '{{ record_create.record.name }}' register: record_info - - assert: + - name: Assert get domain_record_info + assert: that: - record_info.record[0].name == 'sub' - record_info.record[0].type == 'A' @@ -68,13 +72,14 @@ - record_info.record[0].ttl_sec == 14400 - record_info.record[0].weight == 62 - - name: Get info about the record by id + - name: Get domain_record_info by id linode.cloud.domain_record_info: domain: '{{ domain_create.domain.domain }}' id: '{{ record_create.record.id }}' register: record_info_id - - assert: + - name: Assert get domain_record_info by id + assert: that: - record_info_id.record[0].name == 'sub' - record_info_id.record[0].type == 'A' @@ -82,7 +87,7 @@ - record_info_id.record[0].ttl_sec == 14400 - record_info_id.record[0].weight == 62 - - name: Create a domain record by domain id + - name: Create domain_record with domain id linode.cloud.domain_record: domain_id: '{{ domain_create.domain.id }}' name: 'cool' @@ -93,7 +98,8 @@ state: present register: record2_create - - assert: + - name: Assert domain_record is created with domain id + assert: that: - record2_create.record.name == 'cool' - record2_create.record.type == 'TXT' @@ -101,7 +107,7 @@ - record2_create.record.ttl_sec == 7200 - record2_create.record.weight == 32 - - name: Create a duplicate record with a different target + - name: Create duplicate domain_record with different target linode.cloud.domain_record: domain: '{{ domain_create.domain.domain }}' name: 'sub' @@ -112,7 +118,8 @@ state: present register: record_dupe_create - - assert: + - name: Assert duplicate domain_record is created with different target + assert: that: - record_dupe_create.record.name == 'sub' - record_dupe_create.record.type == 'A' @@ -120,7 +127,7 @@ - record_dupe_create.record.ttl_sec == 3600 - record_dupe_create.record.weight == 55 - - name: Update the record by id + - name: Update domain_record by id linode.cloud.domain_record: domain: '{{ domain_create.domain.domain }}' record_id: '{{ record_dupe_create.record.id }}' @@ -129,7 +136,8 @@ state: present register: record_dupe_update - - assert: + - name: Assert domain_record is updated by id + assert: that: - record_dupe_update.changed == true - record_dupe_update.record.name == 'sub' @@ -138,16 +146,17 @@ - record_dupe_update.record.ttl_sec == 300 - record_dupe_update.record.weight == 55 - - name: Get all domain records + - name: Get domain_info linode.cloud.domain_info: domain: '{{ domain_create.domain.domain }}' register: domain_info - - assert: + - name: Assert domain_info response + assert: that: - domain_info.records|length == 3 - - name: Create a record containing FQDN + - name: Create domain_record containing FQDN linode.cloud.domain_record: domain: '{{ domain_create.domain.domain }}' name: 'fqdn.{{ domain_create.domain.domain }}' @@ -156,12 +165,13 @@ state: present register: record_fqdn_create - - assert: + - name: Assert domain_record is created containing FQDN + assert: that: - record_fqdn_create.record.name == 'fqdn' - record_fqdn_create.changed - - name: Create a record containing FQDN + - name: Create second domain_record containing FQDN linode.cloud.domain_record: domain: '{{ domain_create.domain.domain }}' name: 'fqdn.{{ domain_create.domain.domain }}' @@ -170,12 +180,13 @@ state: present register: record_fqdn_nochange - - assert: + - name: Assert second domain_record is created containing FQDN + assert: that: - record_fqdn_nochange.record.name == 'fqdn' - record_fqdn_nochange.changed == False - - name: Delete a record containing FQDN + - name: Delete domain_record containing FQDN linode.cloud.domain_record: domain: '{{ domain_create.domain.domain }}' name: 'fqdn.{{ domain_create.domain.domain }}' @@ -184,7 +195,8 @@ state: absent register: record_fqdn_delete - - assert: + - name: Assert domain_record containing FQDN is deleted + assert: that: - record_fqdn_delete.record.name == 'fqdn' - record_fqdn_delete.changed @@ -192,19 +204,20 @@ always: - ignore_errors: yes block: - - name: Delete the record + - name: Delete domain_record linode.cloud.domain_record: domain: '{{ domain_create.domain.domain }}' record_id: '{{ record_create.record.id }}' state: absent register: record_delete - - assert: + - name: Assert domain_record is deleted + assert: that: - record_delete.changed - record_delete.record.id == record_create.record.id - - name: Delete the second record + - name: Delete second domain_record linode.cloud.domain_record: domain: '{{ domain_create.domain.domain }}' name: '{{ record2_create.record.name }}' @@ -213,30 +226,33 @@ state: absent register: record2_delete - - assert: + - name: Assert second domain_record is deleted + assert: that: - record2_delete.changed - record2_delete.record.id == record2_create.record.id - - name: Delete the duplicated record + - name: Delete duplicated domain_record linode.cloud.domain_record: domain: '{{ domain_create.domain.domain }}' record_id: '{{ record_dupe_create.record.id }}' state: absent register: record_dupe_delete - - assert: + - name: Assert duplicated domain_record is deleted + assert: that: - record_dupe_delete.changed - record_dupe_delete.record.id == record_dupe_delete.record.id - - name: Delete the domain + - name: Delete domain linode.cloud.domain: domain: '{{ domain_create.domain.domain }}' state: absent register: domain_delete - - assert: + - name: Assert domain is deleted + assert: that: - domain_delete.changed - domain_delete.domain.id == domain_create.domain.id diff --git a/tests/integration/targets/domain_zone_file/tasks/main.yaml b/tests/integration/targets/domain_zone_file/tasks/main.yaml index e3bec700..59ad9cb6 100644 --- a/tests/integration/targets/domain_zone_file/tasks/main.yaml +++ b/tests/integration/targets/domain_zone_file/tasks/main.yaml @@ -3,7 +3,7 @@ - set_fact: r: "{{ 1000000000 | random }}" - - name: Create a domain + - name: Create domain linode.cloud.domain: description: 'really cool domain' domain: 'ansible-test-domain-{{ r }}.com' @@ -22,7 +22,8 @@ retries: 5 delay: 10 - - assert: + - name: Assert domain is created + assert: that: - create.domain.description == 'really cool domain' - create.domain.expire_sec == 300 @@ -34,7 +35,7 @@ - create.domain.ttl_sec == 14400 - create.domain.type == 'master' - - name: Get domain info + - name: Get domain_info linode.cloud.domain_info: domain: '{{ create.domain.domain }}' register: info @@ -45,13 +46,14 @@ always: - ignore_errors: yes block: - - name: Delete the domain + - name: Delete domain linode.cloud.domain: domain: '{{ create.domain.domain }}' state: absent register: delete - - assert: + - name: Assert domain_info response + assert: that: - delete.changed - delete.domain.id == create.domain.id diff --git a/tests/integration/targets/event_list/tasks/main.yaml b/tests/integration/targets/event_list/tasks/main.yaml index 4304a650..182790f3 100644 --- a/tests/integration/targets/event_list/tasks/main.yaml +++ b/tests/integration/targets/event_list/tasks/main.yaml @@ -13,17 +13,18 @@ state: present register: create_stackscript - - name: List the events for the current Linode Account + - name: List event_list for current Linode Account linode.cloud.event_list: count: 5 register: no_filter - - assert: + - name: Assert event_list length for current Account + assert: that: # We can't ensure that the testing account will have 5 events - no_filter.events | length <= 5 - - name: Resolve the StackScript event + - name: Get StackScript event in event_list linode.cloud.event_list: count: 1 order_by: created @@ -33,7 +34,8 @@ values: stackscript_create register: filter - - assert: + - name: Assert StackScript event in event_list + assert: that: - filter.events | length == 1 - filter.events[0].entity.id == create_stackscript.stackscript.id diff --git a/tests/integration/targets/firewall_basic/tasks/main.yaml b/tests/integration/targets/firewall_basic/tasks/main.yaml index a00d7c66..9269e6cc 100644 --- a/tests/integration/targets/firewall_basic/tasks/main.yaml +++ b/tests/integration/targets/firewall_basic/tasks/main.yaml @@ -2,7 +2,7 @@ block: - set_fact: r: "{{ 1000000000 | random }}" - - name: Create a Linode Instance + - name: Create a Linode instance linode.cloud.instance: label: 'ansible-test-{{ r }}' region: us-ord @@ -11,7 +11,7 @@ state: present register: create_instance - - name: Create another Linode Instance + - name: Create another instance linode.cloud.instance: label: 'ansible-test-{{ r }}-2' region: us-ord @@ -20,7 +20,7 @@ state: present register: create_instance_2 - - name: Create a Linode Firewall + - name: Create Linode firewall linode.cloud.firewall: api_version: v4beta label: 'ansible-test-{{ r }}' @@ -33,12 +33,12 @@ state: present register: create - - name: Assert firewall created + - name: Assert firewall is created assert: that: - create.changed - - name: Update a Linode Firewall + - name: Update Linode firewall linode.cloud.firewall: api_version: v4beta label: '{{ create.firewall.label }}' @@ -52,7 +52,7 @@ state: present register: update - - name: Assert firewall updated + - name: Assert firewall is updated assert: that: - update.changed @@ -74,7 +74,7 @@ state: present register: update_devices - - name: Assert firewall devices updated + - name: Assert firewall devices are updated assert: that: - update_devices.changed @@ -98,7 +98,7 @@ state: present register: update_devices - - name: Assert firewall devices updated + - name: Assert firewall devices are updated assert: that: - update_devices.changed @@ -122,7 +122,7 @@ state: present register: update_devices_unchanged - - name: Assert firewall devices unchanged + - name: Assert firewall devices are unchanged assert: that: - update_devices_unchanged.changed == false @@ -156,7 +156,7 @@ state: present register: updaterules - - name: Assert firewall rules updated + - name: Assert firewall rules are updated assert: that: - updaterules.changed @@ -206,7 +206,7 @@ state: present register: updaterules_unchanged - - name: Assert firewall rules updated + - name: Assert firewall rules are updated assert: that: - updaterules_unchanged.changed == false @@ -248,7 +248,7 @@ state: absent register: delete - - name: Assert Firewall delete succeeded + - name: Assert Firewall is deleted assert: that: - delete.changed @@ -260,7 +260,7 @@ state: absent register: delete_instance - - name: Assert instance delete succeeded + - name: Assert instance is deleted assert: that: - delete_instance.changed @@ -272,7 +272,7 @@ state: absent register: delete_instance_2 - - name: Assert instance delete succeeded + - name: Assert instance is deleted assert: that: - delete_instance_2.changed diff --git a/tests/integration/targets/firewall_device/tasks/main.yaml b/tests/integration/targets/firewall_device/tasks/main.yaml index ce40f187..706d3fb9 100644 --- a/tests/integration/targets/firewall_device/tasks/main.yaml +++ b/tests/integration/targets/firewall_device/tasks/main.yaml @@ -77,23 +77,28 @@ always: - ignore_errors: yes block: - - linode.cloud.firewall_device: + - name: Delete firewall device in linode + linode.cloud.firewall_device: firewall_id: '{{ fw.firewall.id }}' entity_id: '{{ inst.instance.id }}' entity_type: 'linode' state: absent - - linode.cloud.firewall_device: + - name: Delete firewall device in nodebalancer + linode.cloud.firewall_device: firewall_id: '{{ fw.firewall.id }}' entity_id: '{{ nb.node_balancer.id }}' entity_type: 'nodebalancer' state: absent - - linode.cloud.nodebalancer: + - name: Delete nodebalancer + linode.cloud.nodebalancer: label: '{{ nb.node_balancer.label }}' state: absent - - linode.cloud.instance: + - name: Delete instance + linode.cloud.instance: label: '{{ inst.instance.label }}' state: absent - - linode.cloud.firewall: + - name: Delete Firewall + linode.cloud.firewall: label: '{{ fw.firewall.label }}' state: absent diff --git a/tests/integration/targets/firewall_icmp/tasks/main.yaml b/tests/integration/targets/firewall_icmp/tasks/main.yaml index 74a10a6c..e2f8ab70 100644 --- a/tests/integration/targets/firewall_icmp/tasks/main.yaml +++ b/tests/integration/targets/firewall_icmp/tasks/main.yaml @@ -2,6 +2,7 @@ block: - set_fact: r: "{{ 1000000000 | random }}" + - name: Create a Linode Instance linode.cloud.instance: label: 'ansible-test-{{ r }}' @@ -54,7 +55,8 @@ state: present register: unchanged - - assert: + - name: Assert firewall is unchanged + assert: that: - unchanged.changed == False @@ -68,7 +70,7 @@ state: absent register: delete - - name: Assert Firewall delete succeeded + - name: Assert Firewall is deleted assert: that: - delete.changed @@ -80,7 +82,7 @@ state: absent register: delete_instance - - name: Assert instance delete succeeded + - name: Assert instance is deleted assert: that: - delete_instance.changed diff --git a/tests/integration/targets/firewall_list/tasks/main.yaml b/tests/integration/targets/firewall_list/tasks/main.yaml index bbbf78c0..0908197b 100644 --- a/tests/integration/targets/firewall_list/tasks/main.yaml +++ b/tests/integration/targets/firewall_list/tasks/main.yaml @@ -21,15 +21,16 @@ that: - create.changed - - name: List firewalls with no filter + - name: List firewall_list with no filter linode.cloud.firewall_list: register: no_filter - - assert: + - name: Assert firewall_list with no filter + assert: that: - no_filter.firewalls | length >= 1 - - name: List firewalls with filter on label + - name: List firewall_list with filter on label linode.cloud.firewall_list: order_by: created order: desc @@ -38,7 +39,8 @@ values: ansible-test-{{ r }} register: filter - - assert: + - name: Assert firewall_list with filter on label + assert: that: - filter.firewalls | length >= 1 - filter.firewalls[0].label == 'ansible-test-{{ r }}' diff --git a/tests/integration/targets/firewall_update/tasks/main.yaml b/tests/integration/targets/firewall_update/tasks/main.yaml index d1fcdf3b..af77ed25 100644 --- a/tests/integration/targets/firewall_update/tasks/main.yaml +++ b/tests/integration/targets/firewall_update/tasks/main.yaml @@ -20,6 +20,7 @@ assert: that: - create.changed + - name: Set Linode Firewall with just IPv4 linode.cloud.firewall: state: present diff --git a/tests/integration/targets/image_basic/tasks/main.yaml b/tests/integration/targets/image_basic/tasks/main.yaml index fbf42ef4..e09bdb21 100644 --- a/tests/integration/targets/image_basic/tasks/main.yaml +++ b/tests/integration/targets/image_basic/tasks/main.yaml @@ -21,29 +21,32 @@ state: present register: image_create - - assert: + - name: Assert image is created + assert: that: - image_create.image.status == 'available' - image_create.image.description == 'cool' - image_create.image.capabilities[0] == 'cloud-init' - - name: Get info about the image by ID + - name: Get image_info by ID linode.cloud.image_info: id: '{{ image_create.image.id }}' register: info_id - - assert: + - name: Assert image_info by ID + assert: that: - info_id.image.status == 'available' - info_id.image.description == 'cool' - info_id.image.id == image_create.image.id - - name: Get info about the image by label + - name: Get image_info by label linode.cloud.image_info: label: '{{ image_create.image.label }}' register: info_label - - assert: + - name: Assert image_info by label + assert: that: - info_label.image.status == 'available' - info_label.image.description == 'cool' @@ -57,7 +60,8 @@ state: present register: image_update - - assert: + - name: Assert image is updated + assert: that: - image_update.image.status == 'available' - image_update.image.description == 'cool2' @@ -72,7 +76,8 @@ state: present register: image_recreate - - assert: + - name: Assert image is overwritten + assert: that: - image_recreate.changed - image_recreate.image.id != image_create.image.id @@ -81,11 +86,13 @@ always: - ignore_errors: yes block: - - linode.cloud.image: + - name: Delete image + linode.cloud.image: label: '{{ image_create.image.label }}' state: absent - - linode.cloud.instance: + - name: Delete instance + linode.cloud.instance: label: '{{ instance_create.instance.label }}' state: absent diff --git a/tests/integration/targets/image_list/tasks/main.yaml b/tests/integration/targets/image_list/tasks/main.yaml index 51566308..6c3fa725 100644 --- a/tests/integration/targets/image_list/tasks/main.yaml +++ b/tests/integration/targets/image_list/tasks/main.yaml @@ -3,15 +3,17 @@ - set_fact: r: "{{ 1000000000 | random }}" - - linode.cloud.image_list: + - name: List image_list with no filter + linode.cloud.image_list: count: 5 register: no_filter - - assert: + - name: Assert image_list with no filter + assert: that: - no_filter.images | length == 5 - - name: Resolve an image + - name: List image_list with filter on label linode.cloud.image_list: count: 1 order_by: created @@ -21,19 +23,21 @@ values: Alpine 3.19 register: filter - - assert: + - name: Assert image_list with filter on label + assert: that: - filter.images | length == 1 - filter.images[0].id == 'linode/alpine3.19' - - name: Resolve an empty list of images + - name: List image_list with empty filter linode.cloud.image_list: filters: - name: vendor values: DefinitelyRealVendor register: filter_empty - - assert: + - name: Assert image_list with empty filter + assert: that: - filter_empty.images | length == 0 diff --git a/tests/integration/targets/image_upload/tasks/main.yaml b/tests/integration/targets/image_upload/tasks/main.yaml index 47150d7d..8c3dc9f8 100644 --- a/tests/integration/targets/image_upload/tasks/main.yaml +++ b/tests/integration/targets/image_upload/tasks/main.yaml @@ -10,7 +10,8 @@ suffix: .img.gz register: source_file - - copy: + - name: Copy temp file to destination + copy: dest: '{{ source_file.path }}' content: '{{ file_content | b64decode }}' @@ -22,7 +23,8 @@ state: present register: image_create - - assert: + - name: Assert image is created from image file + assert: that: - image_create.image.size == 1 - image_create.image.status == 'available' @@ -30,7 +32,8 @@ always: - ignore_errors: yes block: - - linode.cloud.image: + - name: Delete image + linode.cloud.image: label: '{{ image_create.image.label }}' state: absent diff --git a/tests/integration/targets/instance_config_disk/tasks/main.yaml b/tests/integration/targets/instance_config_disk/tasks/main.yaml index 9c4c2527..8e0c4549 100644 --- a/tests/integration/targets/instance_config_disk/tasks/main.yaml +++ b/tests/integration/targets/instance_config_disk/tasks/main.yaml @@ -32,7 +32,8 @@ state: present register: create - - assert: + - name: Assert instance is created with explicit disks and config + assert: that: - create.changed - create.disks[0].label == 'test-disk' @@ -81,7 +82,8 @@ state: present register: unchanged - - assert: + - name: Assert config is unchanged + assert: that: - unchanged.changed == False @@ -110,7 +112,8 @@ state: present register: update_config - - assert: + - name: Assert config is updated + assert: that: - update_config.changed - update_config.disks[0].label == 'test-disk' @@ -132,7 +135,8 @@ state: present register: resize - - assert: + - name: Assert config is deleted and disk is resized + assert: that: - resize.changed - resize.configs|length == 0 @@ -192,7 +196,8 @@ state: present register: boot - - assert: + - name: Assert instance is booted with new config and disk + assert: that: - boot.changed - boot.instance.status == 'running' diff --git a/tests/integration/targets/instance_config_disk_private/tasks/main.yaml b/tests/integration/targets/instance_config_disk_private/tasks/main.yaml index 46ac8178..4be25083 100644 --- a/tests/integration/targets/instance_config_disk_private/tasks/main.yaml +++ b/tests/integration/targets/instance_config_disk_private/tasks/main.yaml @@ -10,7 +10,8 @@ suffix: .img.gz register: source_file - - copy: + - name: Copy temporary image file to destination path + copy: dest: '{{ source_file.path }}' content: '{{ file_content | b64decode }}' @@ -21,7 +22,8 @@ state: present register: image_create - - assert: + - name: Assert private image is file is created from temporary image file + assert: that: - image_create.image.status == 'available' @@ -52,7 +54,8 @@ state: present register: instance_create - - assert: + - name: Assert instance is provisioned consuming the image + assert: that: - instance_create.changed - instance_create.disks | length == 2 @@ -60,11 +63,13 @@ always: - ignore_errors: yes block: - - linode.cloud.instance: + - name: Delete instance + linode.cloud.instance: label: '{{ instance_create.instance.label }}' state: absent - - linode.cloud.image: + - name: Delete image + linode.cloud.image: label: '{{ image_create.image.label }}' state: absent diff --git a/tests/integration/targets/instance_config_vlan/tasks/main.yaml b/tests/integration/targets/instance_config_vlan/tasks/main.yaml index e4268711..3bbd40f5 100644 --- a/tests/integration/targets/instance_config_vlan/tasks/main.yaml +++ b/tests/integration/targets/instance_config_vlan/tasks/main.yaml @@ -57,7 +57,8 @@ state: present register: update_instance - - assert: + - name: Assert instance is updated + assert: that: - update_instance.changed - update_instance.instance.ipv4|length == 1 @@ -89,7 +90,8 @@ state: present register: unchanged_instance - - assert: + - name: Assert instance is unchanged + assert: that: - unchanged_instance.changed == False @@ -102,7 +104,7 @@ state: absent register: delete_instance - - name: Assert instance delete succeeded + - name: Assert instance is deleted assert: that: - delete_instance.changed diff --git a/tests/integration/targets/instance_disk_stackscript/tasks/main.yaml b/tests/integration/targets/instance_disk_stackscript/tasks/main.yaml index a0f52d0a..9ba3f3f3 100644 --- a/tests/integration/targets/instance_disk_stackscript/tasks/main.yaml +++ b/tests/integration/targets/instance_disk_stackscript/tasks/main.yaml @@ -31,7 +31,8 @@ state: present register: instance_create - - assert: + - name: Assert instance is created with explicit disk and stackscript + assert: that: - instance_create.changed - instance_create.disks[0].label == "test-disk" @@ -52,21 +53,25 @@ always: - ignore_errors: yes block: - - linode.cloud.instance: + - name: Delete instance + linode.cloud.instance: label: "{{ instance_create.instance.label }}" state: absent register: instance_delete - - assert: + - name: Assert instance is deleted + assert: that: - instance_delete.changed - - linode.cloud.stackscript: + - name: Delete stackscript + linode.cloud.stackscript: label: "{{ stackscript_create.stackscript.label }}" state: absent register: stackscript_delete - - assert: + - name: Assert stackscript is deleted + assert: that: - stackscript_delete.changed diff --git a/tests/integration/targets/instance_interfaces_vpc/tasks/main.yaml b/tests/integration/targets/instance_interfaces_vpc/tasks/main.yaml index 5ddb519c..7bdf1686 100644 --- a/tests/integration/targets/instance_interfaces_vpc/tasks/main.yaml +++ b/tests/integration/targets/instance_interfaces_vpc/tasks/main.yaml @@ -113,7 +113,8 @@ state: present register: unchanged_instance - - assert: + - name: Assert instance interface is unchanged + assert: that: - unchanged_instance.changed == False diff --git a/tests/integration/targets/instance_inventory/playbooks/test_inventory_filter.yml b/tests/integration/targets/instance_inventory/playbooks/test_inventory_filter.yml index 9a82316a..9e9924d1 100644 --- a/tests/integration/targets/instance_inventory/playbooks/test_inventory_filter.yml +++ b/tests/integration/targets/instance_inventory/playbooks/test_inventory_filter.yml @@ -5,7 +5,8 @@ tasks: - meta: refresh_inventory - - assert: + - name: Assert inventory + assert: that: - '"ansible-test-inventory" in hostvars' - hostvars | length == 1 \ No newline at end of file diff --git a/tests/integration/targets/instance_inventory/playbooks/test_inventory_templatetoken.yml b/tests/integration/targets/instance_inventory/playbooks/test_inventory_templatetoken.yml index 9a82316a..9e9924d1 100644 --- a/tests/integration/targets/instance_inventory/playbooks/test_inventory_templatetoken.yml +++ b/tests/integration/targets/instance_inventory/playbooks/test_inventory_templatetoken.yml @@ -5,7 +5,8 @@ tasks: - meta: refresh_inventory - - assert: + - name: Assert inventory + assert: that: - '"ansible-test-inventory" in hostvars' - hostvars | length == 1 \ No newline at end of file diff --git a/tests/integration/targets/instance_list/tasks/main.yaml b/tests/integration/targets/instance_list/tasks/main.yaml index 1b28c6dc..1f023fa3 100644 --- a/tests/integration/targets/instance_list/tasks/main.yaml +++ b/tests/integration/targets/instance_list/tasks/main.yaml @@ -21,11 +21,12 @@ - create.instance.ipv4|length > 1 - create.networking.ipv4.public[0].address != None - - name: List instances with no filter + - name: List instance_list with no filter linode.cloud.instance_list: register: no_filter - - assert: + - name: Assert instance_list with no filter + assert: that: - no_filter.instances | length >= 1 @@ -38,7 +39,8 @@ values: us-ord register: filter - - assert: + - name: Assert instance_list with filter on region + assert: that: - filter.instances | length >= 1 - filter.instances[0].region == 'us-ord' diff --git a/tests/integration/targets/instance_region_migration/tasks/main.yaml b/tests/integration/targets/instance_region_migration/tasks/main.yaml index 731c0ced..1441b4bf 100644 --- a/tests/integration/targets/instance_region_migration/tasks/main.yaml +++ b/tests/integration/targets/instance_region_migration/tasks/main.yaml @@ -3,7 +3,8 @@ - set_fact: r: "{{ 1000000000 | random }}" - - linode.cloud.instance: + - name: Create instance + linode.cloud.instance: label: 'ansible-test-{{ r }}' region: us-mia type: g6-nanode-1 @@ -11,12 +12,14 @@ state: present register: create - - assert: + - name: Assert instance is created + assert: that: - create.changed - create.instance.region == "us-mia" - - linode.cloud.instance: + - name: Migrate instance (cold) + linode.cloud.instance: label: 'ansible-test-{{ r }}' region: us-iad type: g6-nanode-1 @@ -25,7 +28,8 @@ state: present register: migrated - - assert: + - name: Assert instance migrated (cold) + assert: that: - migrated.changed - migrated.instance.region == "us-iad" @@ -33,12 +37,14 @@ always: - ignore_errors: yes block: - - linode.cloud.instance: + - name: Delete instance + linode.cloud.instance: label: '{{ create.instance.label }}' state: absent register: delete - - assert: + - name: Assert instance is deleted + assert: that: - delete.changed - delete.instance.id == create.instance.id diff --git a/tests/integration/targets/instance_timeout/tasks/main.yaml b/tests/integration/targets/instance_timeout/tasks/main.yaml index 3c570206..6b9351ab 100644 --- a/tests/integration/targets/instance_timeout/tasks/main.yaml +++ b/tests/integration/targets/instance_timeout/tasks/main.yaml @@ -18,7 +18,8 @@ always: - ignore_errors: yes block: - - linode.cloud.instance: + - name: Instance state is absent + linode.cloud.instance: label: 'ansible-test-{{ r }}' state: absent diff --git a/tests/integration/targets/instance_type_change/tasks/main.yaml b/tests/integration/targets/instance_type_change/tasks/main.yaml index 630e8ee1..94a3685f 100644 --- a/tests/integration/targets/instance_type_change/tasks/main.yaml +++ b/tests/integration/targets/instance_type_change/tasks/main.yaml @@ -3,7 +3,8 @@ - set_fact: r: "{{ 1000000000 | random }}" - - linode.cloud.instance: + - name: Create Linode instance + linode.cloud.instance: label: 'ansible-test-{{ r }}' region: us-mia type: g6-nanode-1 @@ -11,12 +12,14 @@ state: present register: create - - assert: + - name: Assert instance is created + assert: that: - create.changed - create.instance.type == "g6-nanode-1" - - linode.cloud.type_list: + - name: List type_list with filter on label + linode.cloud.type_list: filters: - name: label values: Linode 2GB @@ -32,11 +35,12 @@ state: present register: resize_disks - - assert: + - name: Assert instance is resized with resizing disks + assert: that: - resize_disks.changed - resize_disks.instance.type == "g6-standard-1" - - resize_disks.disks[0].size == type_info.types[0].disk - 512 + - resize_disks.instance.specs.disk == type_info.types[0].disk - name: Run a warm resize without resizing disks linode.cloud.instance: @@ -48,7 +52,8 @@ state: present register: resize_disks - - assert: + - name: Assert warm resize without resizing disks + assert: that: - resize_disks.changed - resize_disks.instance.type == "g6-standard-2" @@ -58,12 +63,14 @@ always: - ignore_errors: yes block: - - linode.cloud.instance: + - name: Delete instance + linode.cloud.instance: label: '{{ create.instance.label }}' state: absent register: delete - - assert: + - name: Assert instance is deleted + assert: that: - delete.changed - delete.instance.id == create.instance.id diff --git a/tests/integration/targets/instance_type_list/tasks/main.yaml b/tests/integration/targets/instance_type_list/tasks/main.yaml index bda68c2c..c69cb353 100644 --- a/tests/integration/targets/instance_type_list/tasks/main.yaml +++ b/tests/integration/targets/instance_type_list/tasks/main.yaml @@ -1,10 +1,11 @@ - name: instance_type_list block: - - name: List instance types with no filter + - name: List instance_type_list with no filter linode.cloud.instance_type_list: register: no_filter - - assert: + - name: Assert instance_type_list with no filter + assert: that: - no_filter.instance_types | length >= 1 @@ -15,7 +16,8 @@ values: nanode register: filter - - assert: + - name: Assert instance_type_list with filter on class + assert: that: - filter.instance_types | length >= 1 - filter.instance_types[0].class == 'nanode' diff --git a/tests/integration/targets/ip_assign/tasks/main.yml b/tests/integration/targets/ip_assign/tasks/main.yml index e05d2670..d4d32e98 100644 --- a/tests/integration/targets/ip_assign/tasks/main.yml +++ b/tests/integration/targets/ip_assign/tasks/main.yml @@ -49,10 +49,12 @@ always: - ignore_errors: true block: - - linode.cloud.instance: + - name: Delete instance + linode.cloud.instance: label: '{{ create_instance.instance.label }}' state: absent - - linode.cloud.instance: + - name: Delete instance 2 + linode.cloud.instance: label: '{{ create_instance_2.instance.label }}' state: absent diff --git a/tests/integration/targets/ip_info/tasks/main.yaml b/tests/integration/targets/ip_info/tasks/main.yaml index 7ee7520a..100e249e 100644 --- a/tests/integration/targets/ip_info/tasks/main.yaml +++ b/tests/integration/targets/ip_info/tasks/main.yaml @@ -13,19 +13,21 @@ state: present register: instance_create - - name: Get info about the instance's primary IP + - name: Get ip_info about the instance's primary IP linode.cloud.ip_info: address: '{{ instance_create.instance.ipv4[0] }}' register: ip_info - - assert: + - name: Assert ip_info about instance's primary IP + assert: that: - ip_info.ip.address == instance_create.instance.ipv4[0] always: - ignore_errors: true block: - - linode.cloud.instance: + - name: Delete instance + linode.cloud.instance: label: '{{ instance_create.instance.label }}' state: absent diff --git a/tests/integration/targets/ip_rdns/tasks/main.yaml b/tests/integration/targets/ip_rdns/tasks/main.yaml index 3df9d92f..9ff919de 100644 --- a/tests/integration/targets/ip_rdns/tasks/main.yaml +++ b/tests/integration/targets/ip_rdns/tasks/main.yaml @@ -34,7 +34,8 @@ address: '{{ instance_create.instance.ipv4[0] }}' register: ip_rdns_removed - - assert: + - name: Assert reverse DNS of IP is removed + assert: that: - ip_info.ip.address == instance_create.instance.ipv4[0] - ip_rdns_modified.ip.rdns == new_rdns @@ -43,7 +44,8 @@ always: - ignore_errors: true block: - - linode.cloud.instance: + - name: Delete instance + linode.cloud.instance: label: '{{ instance_create.instance.label }}' state: absent diff --git a/tests/integration/targets/ip_share/tasks/main.yaml b/tests/integration/targets/ip_share/tasks/main.yaml index 89e5dd7a..6048ca56 100644 --- a/tests/integration/targets/ip_share/tasks/main.yaml +++ b/tests/integration/targets/ip_share/tasks/main.yaml @@ -72,11 +72,11 @@ linode_id: '{{ instance_create_shared.instance.id }}' register: ip_unshared - - name: Assert shared IPs configured. - set_fact: + - set_fact: ip_shared_address: "{{ instance_create.instance.ipv4[0] }}" - - assert: + - name: Assert shared IPs configured. + assert: that: - ip_shared.ips[0] == ip_shared_address - ip_already_shared.changed == false @@ -85,10 +85,12 @@ always: - ignore_errors: true block: - - linode.cloud.instance: + - name: Delete instance + linode.cloud.instance: label: '{{ instance_create.instance.label }}' state: absent - - linode.cloud.instance: + - name: Delete shared instance + linode.cloud.instance: label: '{{ instance_create_shared.instance.label }}' state: absent diff --git a/tests/integration/targets/ipv6_range_info/tasks/main.yaml b/tests/integration/targets/ipv6_range_info/tasks/main.yaml index 82debc17..5e4ae0fb 100644 --- a/tests/integration/targets/ipv6_range_info/tasks/main.yaml +++ b/tests/integration/targets/ipv6_range_info/tasks/main.yaml @@ -24,12 +24,13 @@ body_json: '{{ ipv6_body | to_json }}' register: range_create - - name: Get info about the IPv6 range + - name: Get ipv6_range_info about the IPv6 range linode.cloud.ipv6_range_info: range: '{{ range_create.body.range }}' register: range_info - - assert: + - name: Assert ipv6_range_info about IPv6 range + assert: that: - range_info.range.is_bgp == False - range_info.range.linodes[0] == instance_create.instance.id @@ -40,11 +41,13 @@ always: - ignore_errors: yes block: - - linode.cloud.api_request: + - name: Delete IPv6 range + linode.cloud.api_request: path: 'networking/ipv6/ranges/{{ range_create.body.range.split("/")[0] }}' method: DELETE - - linode.cloud.instance: + - name: Assert IPv6 range is deleted + linode.cloud.instance: label: '{{ instance_create.instance.label }}' state: absent diff --git a/tests/integration/targets/lke_cluster_basic/tasks/main.yaml b/tests/integration/targets/lke_cluster_basic/tasks/main.yaml index ba6599fe..3da2258e 100644 --- a/tests/integration/targets/lke_cluster_basic/tasks/main.yaml +++ b/tests/integration/targets/lke_cluster_basic/tasks/main.yaml @@ -34,7 +34,8 @@ state: present register: create_cluster - - assert: + - name: Assert LKE cluster is created + assert: that: - create_cluster.cluster.k8s_version == old_kube_version - create_cluster.cluster.region == 'us-southeast' @@ -60,7 +61,8 @@ state: present register: update_pools - - assert: + - name: Assert cluster's node pools are updated + assert: that: - update_pools.cluster.k8s_version == old_kube_version - update_pools.cluster.region == 'us-southeast' @@ -93,7 +95,8 @@ state: present register: upgrade - - assert: + - name: Assert cluster is updated + assert: that: - upgrade.cluster.k8s_version == kube_version - upgrade.cluster.control_plane.high_availability == True @@ -108,14 +111,15 @@ - upgrade.node_pools[0].autoscaler.min == 1 - upgrade.node_pools[0].autoscaler.max == 3 - - name: Get info about the cluster by id + - name: Get lke_cluster_info about the cluster by id linode.cloud.lke_cluster_info: id: '{{ upgrade.cluster.id }}' register: info_by_id - - assert: + - name: Assert lke_cluster_info about cluster by id + assert: that: - info_by_id.cluster.k8s_version == kube_version - info_by_id.cluster.region == 'us-southeast' @@ -126,12 +130,13 @@ - info_by_id.node_pools[0].count == 1 - info_by_id.node_pools[0].id == create_cluster.node_pools[0].id - - name: Get info about the cluster by label + - name: Get lke_cluster_info about the cluster by label linode.cloud.lke_cluster_info: label: '{{ upgrade.cluster.label }}' register: info_by_label - - assert: + - name: Assert lke_cluster_info about cluster by label + assert: that: - info_by_label.cluster.k8s_version == kube_version - info_by_label.cluster.region == 'us-southeast' diff --git a/tests/integration/targets/lke_cluster_info_ro/tasks/main.yaml b/tests/integration/targets/lke_cluster_info_ro/tasks/main.yaml index b5a4fa47..d1073c98 100644 --- a/tests/integration/targets/lke_cluster_info_ro/tasks/main.yaml +++ b/tests/integration/targets/lke_cluster_info_ro/tasks/main.yaml @@ -29,7 +29,8 @@ state: present register: create_cluster - - assert: + - name: Assert LKE cluster is created + assert: that: - create_cluster.cluster.k8s_version == kube_version - create_cluster.cluster.region == 'us-southeast' @@ -43,7 +44,8 @@ label: '{{ create_cluster.cluster.label }}' register: cluster_info - - assert: + - name: Assert lke_cluster_info with read-only token + assert: that: - cluster_info.cluster.k8s_version == kube_version - cluster_info.cluster.region == 'us-southeast' @@ -54,11 +56,13 @@ always: - ignore_errors: yes block: - - linode.cloud.lke_cluster: + - name: Delete lke_cluster + linode.cloud.lke_cluster: label: '{{ create_cluster.cluster.label }}' state: absent - - linode.cloud.token: + - name: Delete token + linode.cloud.token: label: 'ansible-test-{{ r }}' state: absent diff --git a/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml b/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml index a56ccfcd..92c3cede 100644 --- a/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml +++ b/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml @@ -22,7 +22,8 @@ state: present register: create_cluster - - assert: + - name: Assert minimal LKE cluster is created + assert: that: - create_cluster.cluster.k8s_version == kube_version - create_cluster.cluster.region == 'us-southeast' @@ -39,7 +40,8 @@ state: present register: new_pool - - assert: + - name: Assert node pool is added to cluster + assert: that: - new_pool.node_pool.count == 2 - new_pool.node_pool.type == 'g6-standard-1' @@ -72,7 +74,8 @@ state: present register: update_pool - - assert: + - name: Assert node pool is updated + assert: that: - update_pool.node_pool.count == 1 - update_pool.node_pool.type == 'g6-standard-1' diff --git a/tests/integration/targets/lke_version_list/tasks/main.yaml b/tests/integration/targets/lke_version_list/tasks/main.yaml index f826a859..cfbf3c29 100644 --- a/tests/integration/targets/lke_version_list/tasks/main.yaml +++ b/tests/integration/targets/lke_version_list/tasks/main.yaml @@ -1,10 +1,11 @@ - name: lke_version_list block: - - name: List lke versions with no filter + - name: List lke_version_list with no filter linode.cloud.lke_version_list: register: no_filter - - assert: + - name: Assert lke_version_list with no filter + assert: that: - no_filter.lke_versions | length >= 1 diff --git a/tests/integration/targets/mysql_basic/tasks/main.yaml b/tests/integration/targets/mysql_basic/tasks/main.yaml index e7e54263..d2bcd423 100644 --- a/tests/integration/targets/mysql_basic/tasks/main.yaml +++ b/tests/integration/targets/mysql_basic/tasks/main.yaml @@ -4,14 +4,15 @@ - set_fact: r: "{{ 1000000000 | random }}" - - name: Get available mysql engines list + - name: Get available database_engine_list linode.cloud.database_engine_list: filters: - name: engine values: mysql register: available_engines - - assert: + - name: Assert available database_engine_list + assert: that: - available_engines.database_engines | length >= 1 @@ -30,7 +31,8 @@ state: present register: db_create - - assert: + - name: Assert database is created + assert: that: - db_create.database.allow_list | length == 1 - db_create.database.allow_list[0] == '0.0.0.0/0' @@ -44,12 +46,13 @@ id: '{{ db_create.database.id }}' register: by_id - - name: Get info about the database by label + - name: Get database_mysql_info by label linode.cloud.database_mysql_info: label: '{{ db_create.database.label }}' register: by_label - - assert: + - name: Assert database_mysql_info by label + assert: that: - by_label.database.allow_list | length == 1 - by_label.database.allow_list[0] == '0.0.0.0/0' @@ -82,7 +85,8 @@ state: present register: db_update - - assert: + - name: Assert database is updated + assert: that: - db_update.database.allow_list | length == 1 - db_update.database.allow_list[0] == '10.0.0.1/32' @@ -92,7 +96,8 @@ linode.cloud.database_list: register: all_dbs - - assert: + - name: Assert listing all databases + assert: that: - all_dbs.databases | length > 0 @@ -129,7 +134,8 @@ always: - ignore_errors: true block: - - linode.cloud.database_mysql: + - name: Delete mysql db + linode.cloud.database_mysql: label: '{{ db_create.database.label }}' state: absent diff --git a/tests/integration/targets/mysql_complex/tasks/main.yaml b/tests/integration/targets/mysql_complex/tasks/main.yaml index f964531a..126975e9 100644 --- a/tests/integration/targets/mysql_complex/tasks/main.yaml +++ b/tests/integration/targets/mysql_complex/tasks/main.yaml @@ -11,7 +11,8 @@ values: mysql register: available_engines - - assert: + - name: Assert available mysql engines list + assert: that: - available_engines.database_engines | length >= 1 @@ -52,7 +53,8 @@ state: present register: db_create - - assert: + - name: Assert database is created + assert: that: - db_create.database.allow_list | length == 1 - db_create.database.allow_list[0] == '0.0.0.0/0' @@ -76,7 +78,8 @@ always: - ignore_errors: true block: - - linode.cloud.database_mysql: + - name: Delete mysql database + linode.cloud.database_mysql: label: '{{ db_create.database.label }}' state: absent diff --git a/tests/integration/targets/nodebalancer_basic/tasks/main.yaml b/tests/integration/targets/nodebalancer_basic/tasks/main.yaml index 8043f189..0b4d4862 100644 --- a/tests/integration/targets/nodebalancer_basic/tasks/main.yaml +++ b/tests/integration/targets/nodebalancer_basic/tasks/main.yaml @@ -48,7 +48,8 @@ algorithm: roundrobin register: create_config - - assert: + - name: Assert nb config is added + assert: that: - create_config.configs|length == 1 - create_config.configs[0].port == 80 @@ -66,7 +67,8 @@ check_timeout: 1 register: update_config - - assert: + - name: Assert nb config is updated + assert: that: - update_config.configs|length == 1 - update_config.configs[0].check_timeout == 1 @@ -87,7 +89,8 @@ recreate: true register: recreate_config - - assert: + - name: Assert nb config is recreated + assert: that: - recreate_config.changed - update_config.configs|length == 1 diff --git a/tests/integration/targets/nodebalancer_list/tasks/main.yaml b/tests/integration/targets/nodebalancer_list/tasks/main.yaml index d3b34c57..a2d7904b 100644 --- a/tests/integration/targets/nodebalancer_list/tasks/main.yaml +++ b/tests/integration/targets/nodebalancer_list/tasks/main.yaml @@ -20,7 +20,8 @@ linode.cloud.nodebalancer_list: register: no_filter - - assert: + - name: Assert nodebalancer_list with no filter + assert: that: - no_filter.nodebalancers | length >= 1 @@ -33,7 +34,8 @@ values: us-ord register: filter - - assert: + - name: Assert nodebalancer_list with filter on region + assert: that: - filter.nodebalancers | length >= 1 - filter.nodebalancers[0].region == 'us-ord' diff --git a/tests/integration/targets/nodebalancer_node/tasks/main.yaml b/tests/integration/targets/nodebalancer_node/tasks/main.yaml index 432b7beb..ef95fcf0 100644 --- a/tests/integration/targets/nodebalancer_node/tasks/main.yaml +++ b/tests/integration/targets/nodebalancer_node/tasks/main.yaml @@ -3,7 +3,8 @@ - set_fact: r: "{{ 1000000000 | random }}" - - linode.cloud.nodebalancer: + - name: Create nodebalancer with basic configs + linode.cloud.nodebalancer: label: 'ansible-nb-{{ r }}' region: us-ord state: present @@ -22,7 +23,8 @@ stickiness: none register: nb - - linode.cloud.instance: + - name: Assert nodebalancer is created with basic configs + linode.cloud.instance: label: 'ansible-node-{{ r }}' region: '{{ nb.node_balancer.region }}' private_ip: true @@ -30,7 +32,8 @@ state: present register: inst - - linode.cloud.nodebalancer_node: + - name: Create nodebalancer_node + linode.cloud.nodebalancer_node: nodebalancer_id: '{{ nb.node_balancer.id }}' config_id: '{{ nb.configs[0].id }}' @@ -45,7 +48,8 @@ - set_fact: inst_ipv4_address: "{{ inst.instance.ipv4[1] }}:80" - - assert: + - name: Assert nb node config + assert: that: - nb_node.changed - nb_node.node.label == 'cool' @@ -53,7 +57,8 @@ - nb_node.node.mode == 'accept' - nb_node.node.weight == 10 - - linode.cloud.nodebalancer_node: + - name: Update nodebalancer node config + linode.cloud.nodebalancer_node: nodebalancer_id: '{{ nb.node_balancer.id }}' config_id: '{{ nb.configs[0].id }}' @@ -65,7 +70,8 @@ state: present register: nb_node_update - - assert: + - name: Assert nb node config is updated + assert: that: - nb_node_update.changed - nb_node_update.node.label == 'cool' @@ -96,11 +102,13 @@ - debug: var: nb_update - - linode.cloud.nodebalancer_info: + - name: Get nodebalancer_info + linode.cloud.nodebalancer_info: label: 'ansible-nb-{{ r }}' register: nb_info - - assert: + - name: Assert nb config + assert: that: - nb_update.changed == False - nb_update.nodes[0].id == nb_node.node.id @@ -109,18 +117,21 @@ always: - ignore_errors: yes block: - - linode.cloud.nodebalancer_node: + - name: Delete nodebalancer node + linode.cloud.nodebalancer_node: nodebalancer_id: '{{ nb.node_balancer.id }}' config_id: '{{ nb.configs[0].id }}' label: '{{ nb_node.node.label }}' state: absent - - linode.cloud.instance: + - name: Delete instance + linode.cloud.instance: label: '{{ inst.instance.label }}' state: absent - - linode.cloud.nodebalancer: + - name: Delete nodebalancer + linode.cloud.nodebalancer: label: '{{ nb.node_balancer.label }}' state: absent diff --git a/tests/integration/targets/postgresql_basic/tasks/main.yaml b/tests/integration/targets/postgresql_basic/tasks/main.yaml index dfb662c3..90d53e17 100644 --- a/tests/integration/targets/postgresql_basic/tasks/main.yaml +++ b/tests/integration/targets/postgresql_basic/tasks/main.yaml @@ -11,7 +11,8 @@ values: postgresql register: available_engines - - assert: + - name: Assert postgresql database_engine_list + assert: that: - available_engines.database_engines | length >= 1 @@ -30,7 +31,8 @@ state: present register: db_create - - assert: + - name: Assert database_postgresql is created + assert: that: - db_create.database.allow_list | length == 1 - db_create.database.allow_list[0] == '0.0.0.0/0' @@ -49,7 +51,8 @@ label: '{{ db_create.database.label }}' register: by_label - - assert: + - name: Assert database_postgresql_info + assert: that: - by_label.database.allow_list | length == 1 - by_label.database.allow_list[0] == '0.0.0.0/0' @@ -75,7 +78,8 @@ state: present register: db_update - - assert: + - name: Assert postgres database is updated + assert: that: - db_update.database.allow_list | length == 1 - db_update.database.allow_list[0] == '10.0.0.1/32' @@ -96,7 +100,8 @@ always: - ignore_errors: true block: - - linode.cloud.database_postgresql: + - name: Delete postgres db + linode.cloud.database_postgresql: label: '{{ db_create.database.label }}' state: absent diff --git a/tests/integration/targets/postgresql_complex/tasks/main.yaml b/tests/integration/targets/postgresql_complex/tasks/main.yaml index c217b964..5916871f 100644 --- a/tests/integration/targets/postgresql_complex/tasks/main.yaml +++ b/tests/integration/targets/postgresql_complex/tasks/main.yaml @@ -11,7 +11,8 @@ values: postgresql register: available_engines - - assert: + - name: Assert database_engine_list for postgresql + assert: that: - available_engines.database_engines | length >= 1 @@ -53,7 +54,8 @@ state: present register: db_create - - assert: + - name: Assert postgres db is created + assert: that: - db_create.database.allow_list | length == 1 - db_create.database.allow_list[0] == '0.0.0.0/0' @@ -78,7 +80,8 @@ always: - ignore_errors: true block: - - linode.cloud.database_postgresql: + - name: Delete postgres db + linode.cloud.database_postgresql: label: '{{ db_create.database.label }}' state: absent diff --git a/tests/integration/targets/profile_info/tasks/main.yaml b/tests/integration/targets/profile_info/tasks/main.yaml index 29ebb8f0..9e0095c9 100644 --- a/tests/integration/targets/profile_info/tasks/main.yaml +++ b/tests/integration/targets/profile_info/tasks/main.yaml @@ -1,10 +1,11 @@ - name: account_info block: - - name: Get info about the current profile + - name: Get profile_info about current profile linode.cloud.profile_info: register: profile - - assert: + - name: Assert profile_info about current profile + assert: that: - profile.profile.email | length > 0 diff --git a/tests/integration/targets/region_list/tasks/main.yaml b/tests/integration/targets/region_list/tasks/main.yaml index 45430ecf..b08eac5c 100644 --- a/tests/integration/targets/region_list/tasks/main.yaml +++ b/tests/integration/targets/region_list/tasks/main.yaml @@ -4,7 +4,8 @@ linode.cloud.region_list: register: no_filter - - assert: + - name: Assert region_list with no filter + assert: that: - no_filter.regions | length >= 0 @@ -15,7 +16,8 @@ values: us register: filter_us - - assert: + - name: Assert region_list with filter on country + assert: that: - filter_us.regions | length >= 0 - filter_us.regions[0].country == 'us' @@ -27,7 +29,8 @@ values: core register: filter_core_site - - assert: + - name: Assert region_list with filter on site type + assert: that: - filter_core_site.regions | length >= 0 - filter_core_site.regions[0].site_type == 'core' diff --git a/tests/integration/targets/ssh_key/tasks/main.yaml b/tests/integration/targets/ssh_key/tasks/main.yaml index ae8a9ebc..386b119c 100644 --- a/tests/integration/targets/ssh_key/tasks/main.yaml +++ b/tests/integration/targets/ssh_key/tasks/main.yaml @@ -4,7 +4,8 @@ r: "{{ 1000000000 | random }}" ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCloBr83q7v2/kipfpChnN1cPr+DA++JN3RdLBid3tFjy5UmAelpRmKO9Uhija7ElC9/x187t13smc35NGaDOG+s+zrSMlSfygqA6pf8njEPDRBhvyp12Fjwb8i+ILFXiU1GYaVprbQwpgdApwqieoCZ4pathc/HdPvznX/Aqgyiq+5+dSRa5GUftAPWrt3ScFXttlfihU+0wIanyxoxnrtPcqNshs39dRg8UP2zrB5aK+9nPurO/6qSWDqVnIVlparlqXxZdwKl+Gfiq93pGicrPgVEy49Tbl75Y8Nxj7zDsJsQuO0UlRk9IUoe1asAy5DXqQ6foOb6vR9rld6owqRHCG/tjYDpuw1uYCYj5xm+DDfkNRowWJktIgnajzaYqZ3ytWzg31m8a7X2Wol8foxlFrUqqqesJ05I28A3JvLIU5s4vSzi1hK4cWKSi15UFdxX1f1a+pRsRgY446k+i3uWcFZVybzp5tDRdjUMRO6XQrbjrxFnKurRY0+S1NeRF0=" - - linode.cloud.ssh_key: + - name: Upload ssh key + linode.cloud.ssh_key: api_token: "{{ api_token }}" ua_prefix: "{{ ua_prefix }}" @@ -20,7 +21,8 @@ id: "{{ create_ssh_key.ssh_key.id }}" register: by_id - - assert: + - name: Assert ssh_key_info by ID + assert: that: - create_ssh_key.ssh_key.label == "test-key-{{ r }}" - create_ssh_key.ssh_key.ssh_key == "{{ ssh_pub_key }}" diff --git a/tests/integration/targets/ssh_key_info/tasks/main.yaml b/tests/integration/targets/ssh_key_info/tasks/main.yaml index 8966738f..a5cdafb9 100644 --- a/tests/integration/targets/ssh_key_info/tasks/main.yaml +++ b/tests/integration/targets/ssh_key_info/tasks/main.yaml @@ -4,7 +4,8 @@ r: "{{ 1000000000 | random }}" ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCloBr83q7v2/kipfpChnN1cPr+DA++JN3RdLBid3tFjy5UmAelpRmKO9Uhija7ElC9/x187t13smc35NGaDOG+s+zrSMlSfygqA6pf8njEPDRBhvyp12Fjwb8i+ILFXiU1GYaVprbQwpgdApwqieoCZ4pathc/HdPvznX/Aqgyiq+5+dSRa5GUftAPWrt3ScFXttlfihU+0wIanyxoxnrtPcqNshs39dRg8UP2zrB5aK+9nPurO/6qSWDqVnIVlparlqXxZdwKl+Gfiq93pGicrPgVEy49Tbl75Y8Nxj7zDsJsQuO0UlRk9IUoe1asAy5DXqQ6foOb6vR9rld6owqRHCG/tjYDpuw1uYCYj5xm+DDfkNRowWJktIgnajzaYqZ3ytWzg31m8a7X2Wol8foxlFrUqqqesJ05I28A3JvLIU5s4vSzi1hK4cWKSi15UFdxX1f1a+pRsRgY446k+i3uWcFZVybzp5tDRdjUMRO6XQrbjrxFnKurRY0+S1NeRF0=" - - linode.cloud.api_request: + - name: Upload ssh pub key + linode.cloud.api_request: path: profile/sshkeys method: POST body: @@ -17,12 +18,13 @@ id: "{{ create_ssh_key.body.id }}" register: by_id - - name: Get info about the SSH key by label + - name: Get ssh_key_info by label linode.cloud.ssh_key_info: label: "{{ create_ssh_key.body.label }}" register: by_label - - assert: + - name: Assert ssh_key_info by label + assert: that: - by_id.ssh_key.id == create_ssh_key.body.id - by_id.ssh_key.ssh_key == create_ssh_key.body.ssh_key @@ -34,8 +36,8 @@ always: - ignore_errors: true block: - - linode.cloud.api_request: - + - name: Delete ssh key + linode.cloud.api_request: path: "profile/sshkeys/{{ create_ssh_key.body.id }}" method: DELETE diff --git a/tests/integration/targets/ssh_key_list/tasks/main.yaml b/tests/integration/targets/ssh_key_list/tasks/main.yaml index c5a8f93e..309b4c77 100644 --- a/tests/integration/targets/ssh_key_list/tasks/main.yaml +++ b/tests/integration/targets/ssh_key_list/tasks/main.yaml @@ -4,7 +4,8 @@ r: "{{ 1000000000 | random }}" ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCloBr83q7v2/kipfpChnN1cPr+DA++JN3RdLBid3tFjy5UmAelpRmKO9Uhija7ElC9/x187t13smc35NGaDOG+s+zrSMlSfygqA6pf8njEPDRBhvyp12Fjwb8i+ILFXiU1GYaVprbQwpgdApwqieoCZ4pathc/HdPvznX/Aqgyiq+5+dSRa5GUftAPWrt3ScFXttlfihU+0wIanyxoxnrtPcqNshs39dRg8UP2zrB5aK+9nPurO/6qSWDqVnIVlparlqXxZdwKl+Gfiq93pGicrPgVEy49Tbl75Y8Nxj7zDsJsQuO0UlRk9IUoe1asAy5DXqQ6foOb6vR9rld6owqRHCG/tjYDpuw1uYCYj5xm+DDfkNRowWJktIgnajzaYqZ3ytWzg31m8a7X2Wol8foxlFrUqqqesJ05I28A3JvLIU5s4vSzi1hK4cWKSi15UFdxX1f1a+pRsRgY446k+i3uWcFZVybzp5tDRdjUMRO6XQrbjrxFnKurRY0+S1NeRF0=" - - linode.cloud.api_request: + - name: Uplooad ssh pub key + linode.cloud.api_request: api_token: '{{ api_token }}' ua_prefix: '{{ ua_prefix }}' @@ -14,8 +15,9 @@ ssh_key: "{{ ssh_pub_key }}" label: "test-key-1-{{ r }}" register: create_ssh_key1 - - - linode.cloud.api_request: + + - name: Uplooad ssh pub key 2 + linode.cloud.api_request: api_token: '{{ api_token }}' ua_prefix: '{{ ua_prefix }}' @@ -58,7 +60,8 @@ count: 1 register: key_list_random - - assert: + - name: Assert ssh_key_list for current account + assert: that: - key_list_1.ssh_keys | length == 1 - key_list_12.ssh_keys | length == 2 @@ -67,12 +70,14 @@ always: - ignore_errors: true block: - - linode.cloud.api_request: + - name: Delete SSH key 1 + linode.cloud.api_request: api_token: '{{ api_token }}' ua_prefix: '{{ ua_prefix }}' path: "profile/sshkeys/{{ create_ssh_key1.body.id }}" method: DELETE - - linode.cloud.api_request: + - name: Delete SSH key 2 + linode.cloud.api_request: api_token: '{{ api_token }}' ua_prefix: '{{ ua_prefix }}' path: "profile/sshkeys/{{ create_ssh_key2.body.id }}" diff --git a/tests/integration/targets/stackscript_basic/tasks/main.yaml b/tests/integration/targets/stackscript_basic/tasks/main.yaml index 56c346fb..27d6bed8 100644 --- a/tests/integration/targets/stackscript_basic/tasks/main.yaml +++ b/tests/integration/targets/stackscript_basic/tasks/main.yaml @@ -21,7 +21,8 @@ state: present register: create_stackscript - - assert: + - name: Assert basic stackscript is created + assert: that: - create_stackscript.stackscript.id != None - create_stackscript.stackscript.rev_note == '' @@ -41,7 +42,8 @@ state: present register: update_stackscript - - assert: + - name: Assert stackscript is updated + assert: that: - update_stackscript.stackscript.id != None - update_stackscript.stackscript.rev_note == 'cool' @@ -51,7 +53,8 @@ always: - ignore_errors: yes block: - - linode.cloud.stackscript: + - name: Delete stackscript + linode.cloud.stackscript: label: '{{ create_stackscript.stackscript.label }}' state: absent diff --git a/tests/integration/targets/stackscript_info/tasks/main.yaml b/tests/integration/targets/stackscript_info/tasks/main.yaml index d183f728..c5f0f4c9 100644 --- a/tests/integration/targets/stackscript_info/tasks/main.yaml +++ b/tests/integration/targets/stackscript_info/tasks/main.yaml @@ -14,7 +14,8 @@ state: present register: create_stackscript - - assert: + - name: Assert stackscript is created + assert: that: - create_stackscript.stackscript.id != None - create_stackscript.stackscript.rev_note == '' @@ -31,7 +32,8 @@ label: '{{ create_stackscript.stackscript.label }}' register: by_label - - assert: + - name: Assert stackscript_info by label + assert: that: - by_id.stackscript.id != None - by_id.stackscript.rev_note == '' @@ -45,7 +47,8 @@ always: - ignore_errors: yes block: - - linode.cloud.stackscript: + - name: Delete stackscript + linode.cloud.stackscript: label: '{{ create_stackscript.stackscript.label }}' state: absent diff --git a/tests/integration/targets/stackscript_list/tasks/main.yaml b/tests/integration/targets/stackscript_list/tasks/main.yaml index 9f2da3eb..f067463e 100644 --- a/tests/integration/targets/stackscript_list/tasks/main.yaml +++ b/tests/integration/targets/stackscript_list/tasks/main.yaml @@ -22,7 +22,8 @@ values: '{{ create_stackscript.stackscript.label }}' register: stack_list - - assert: + - name: Assert stackscript_list with filter on Label + assert: that: - stack_list.stackscripts | length == 1 - stack_list.stackscripts[0].id != None @@ -33,7 +34,8 @@ always: - ignore_errors: yes block: - - linode.cloud.stackscript: + - name: Delete stackscript + linode.cloud.stackscript: label: '{{ create_stackscript.stackscript.label }}' state: absent diff --git a/tests/integration/targets/token_info/tasks/main.yaml b/tests/integration/targets/token_info/tasks/main.yaml index 265f1245..ef8ac8f4 100644 --- a/tests/integration/targets/token_info/tasks/main.yaml +++ b/tests/integration/targets/token_info/tasks/main.yaml @@ -26,7 +26,8 @@ id: '{{ create_token.token.id }}' register: by_id - - assert: + - name: Assert token_info by ID + assert: that: - by_label.token.label == create_token.token.label - by_id.token.label == create_token.token.label diff --git a/tests/integration/targets/token_list/tasks/main.yaml b/tests/integration/targets/token_list/tasks/main.yaml index 5457cf52..91141f67 100644 --- a/tests/integration/targets/token_list/tasks/main.yaml +++ b/tests/integration/targets/token_list/tasks/main.yaml @@ -23,7 +23,8 @@ linode.cloud.token_list: register: no_filter - - assert: + - name: Assert token_list with no filter + assert: that: - no_filter.tokens | length >= 1 @@ -36,7 +37,8 @@ values: ansible-test-{{ r }} register: filter - - assert: + - name: Assert token_list with filter on label + assert: that: - filter.tokens | length >= 1 - filter.tokens[0].label == 'ansible-test-{{ r }}' diff --git a/tests/integration/targets/type_info/tasks/main.yaml b/tests/integration/targets/type_info/tasks/main.yaml index 14bb5f5d..07800a34 100644 --- a/tests/integration/targets/type_info/tasks/main.yaml +++ b/tests/integration/targets/type_info/tasks/main.yaml @@ -8,7 +8,8 @@ id: g6-standard-2 register: type_info - - assert: + - name: Assert type_info by ID + assert: that: - type_info.type.class == "standard" diff --git a/tests/integration/targets/type_list/tasks/main.yaml b/tests/integration/targets/type_list/tasks/main.yaml index d63e4024..68bf1242 100644 --- a/tests/integration/targets/type_list/tasks/main.yaml +++ b/tests/integration/targets/type_list/tasks/main.yaml @@ -11,7 +11,8 @@ values: Nanode 1GB register: filter - - assert: + - name: Assert type_list by Linode type + assert: that: - filter.types | length == 1 - filter.types[0].label == 'Nanode 1GB' diff --git a/tests/integration/targets/user_grants/tasks/main.yaml b/tests/integration/targets/user_grants/tasks/main.yaml index a5b76205..75c2fa13 100644 --- a/tests/integration/targets/user_grants/tasks/main.yaml +++ b/tests/integration/targets/user_grants/tasks/main.yaml @@ -76,11 +76,13 @@ always: - ignore_errors: yes block: - - linode.cloud.user: + - name: Delete user + linode.cloud.user: username: '{{ create_user.user.username }}' state: absent - - linode.cloud.domain: + - name: Delete domain + linode.cloud.domain: domain: '{{ create_domain.domain.domain }}' state: absent diff --git a/tests/integration/targets/user_list/tasks/main.yaml b/tests/integration/targets/user_list/tasks/main.yaml index 7244a8f5..62c9b3d0 100644 --- a/tests/integration/targets/user_list/tasks/main.yaml +++ b/tests/integration/targets/user_list/tasks/main.yaml @@ -20,7 +20,8 @@ linode.cloud.user_list: register: no_filter - - assert: + - name: Assert user_list with no filter + assert: that: - no_filter.users | length >= 1 diff --git a/tests/integration/targets/vlan_list/tasks/main.yaml b/tests/integration/targets/vlan_list/tasks/main.yaml index 5945a75d..ca82c5b6 100644 --- a/tests/integration/targets/vlan_list/tasks/main.yaml +++ b/tests/integration/targets/vlan_list/tasks/main.yaml @@ -28,7 +28,8 @@ values: really-cool-vlan register: filter - - assert: + - name: Assert vlan_list with filter on label + assert: that: - filter.vlans | length == 1 - filter.vlans[0].label == 'really-cool-vlan' diff --git a/tests/integration/targets/volume_list/tasks/main.yaml b/tests/integration/targets/volume_list/tasks/main.yaml index 2288ede2..7ad5553c 100644 --- a/tests/integration/targets/volume_list/tasks/main.yaml +++ b/tests/integration/targets/volume_list/tasks/main.yaml @@ -21,7 +21,8 @@ linode.cloud.volume_list: register: no_filter - - assert: + - name: Assert volume_list with no filter + assert: that: - no_filter.volumes | length >= 1 @@ -33,8 +34,9 @@ - name: region values: us-ord register: filter - - - assert: + + - name: Assert volume_list with filter on region + assert: that: - filter.volumes | length >= 1 - filter.volumes[0].region == 'us-ord' diff --git a/tod_scripts b/tod_scripts index 9d6b7c82..41b85dd2 160000 --- a/tod_scripts +++ b/tod_scripts @@ -1 +1 @@ -Subproject commit 9d6b7c8274a645e80fabfc20e64cf42101208616 +Subproject commit 41b85dd2c5588b5b343b8ee365b2f4f196cd9a7f From d2a07c579b31d76173700fae620c1ba628d57123 Mon Sep 17 00:00:00 2001 From: Jacob Riddle Date: Mon, 8 Apr 2024 10:30:10 -0400 Subject: [PATCH 2/9] update labels/release --- .github/labels.yml | 38 +++++++++++++++++++++++++++ .github/release-drafter.yml | 21 --------------- .github/release.yml | 32 ++++++++++++++++++++++ .github/workflows/labeler.yml | 31 ++++++++++++++++++++++ .github/workflows/release-drafter.yml | 16 ----------- 5 files changed, 101 insertions(+), 37 deletions(-) create mode 100644 .github/labels.yml delete mode 100644 .github/release-drafter.yml create mode 100644 .github/release.yml create mode 100644 .github/workflows/labeler.yml delete mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 00000000..2a28fc81 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,38 @@ +# PR Labels +- name: new-feature + description: for new features in the changelog. + color: 225fee +- name: improvement + description: for improvements in existing functionality in the changelog. + color: 22ee47 +- name: repo-ci-improvement + description: for improvements in the repository or CI workflow in the changelog. + color: c922ee +- name: bugfix + description: for any bug fixes in the changelog. + color: ed8e21 +- name: documentation + description: for updates to the documentation in the changelog. + color: d3e1e6 +- name: dependencies + description: dependency updates usually from dependabot + color: 5c9dff +- name: testing + description: for updates to the testing suite in the changelog. + color: 933ac9 +- name: breaking-change + description: for breaking changes in the changelog. + color: ff0000 +- name: ignore-for-release + description: PRs you do not want to render in the changelog + color: 7b8eac +- name: do-not-merge + description: PRs that should not be merged until the commented issue is resolved + color: eb1515 +# Issue Labels +- name: enhancement + description: issues that request a enhancement + color: 22ee47 +- name: bug + description: issues that report a bug + color: ed8e21 diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index f29c6d17..00000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,21 +0,0 @@ -name-template: 'v$NEXT_PATCH_VERSION' -tag-template: 'v$NEXT_PATCH_VERSION' -categories: - - title: '๐Ÿš€ Added' - label: 'added-feature' - - title: '๐Ÿงฐ Changed' - label: 'changed' - - title: "โš ๏ธ Deprecated" - label: "deprecated" - - title: "โš ๏ธ Removed" - label: "removed" - - title: '๐Ÿ› Bug Fixes' - label: 'bugfix' - - title: "โš ๏ธ Security" - label: "security" -change-template: '- $TITLE @$AUTHOR (#$NUMBER)' -no-changes-template: "- No changes" -template: | - ## Changes - - $CHANGES diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000..8417f9fb --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,32 @@ +changelog: + exclude: + labels: + - ignore-for-release + categories: + - title: โš ๏ธ Breaking Change + labels: + - breaking-change + - title: ๐Ÿ› Bug Fixes + labels: + - bugfix + - title: ๐Ÿš€ New Features + labels: + - new-feature + - title: ๐Ÿ’ก Improvements + labels: + - improvement + - title: ๐Ÿงช Testing Improvements + labels: + - testing + - title: โš™๏ธ Repo/CI Improvements + labels: + - repo-ci-improvement + - title: ๐Ÿ“– Documentation + labels: + - documentation + - title: ๐Ÿ“ฆ Dependency Updates + labels: + - dependencies + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 00000000..da42b7e4 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,31 @@ +name: labeler + +on: + push: + branches: + - 'main' + paths: + - '.github/labels.yml' + - '.github/workflows/labeler.yml' + pull_request: + paths: + - '.github/labels.yml' + - '.github/workflows/labeler.yml' + +jobs: + labeler: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Run Labeler + uses: crazy-max/ghaction-github-labeler@de749cf181958193cb7debf1a9c5bb28922f3e1b + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + yaml-file: .github/labels.yml + dry-run: ${{ github.event_name == 'pull_request' }} + exclude: | + help* + *issue diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml deleted file mode 100644 index 0dbf2f62..00000000 --- a/.github/workflows/release-drafter.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Release Drafter - -on: - push: - branches: - - main - -jobs: - update_release_draft: - runs-on: ubuntu-latest - steps: - - uses: release-drafter/release-drafter@569eb7ee3a85817ab916c8f8ff03a5bd96c9c83e # pin@v5.23.0 - with: - config-name: release-drafter.yml - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 3a65544f620c7dac82a463abdba513c5dc3fb8c4 Mon Sep 17 00:00:00 2001 From: Lena Garber <114949949+lgarber-akamai@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:15:07 -0400 Subject: [PATCH 3/9] new: Add handling to update logic for unordered lists; use update helper in NB & Instance modules (#492) * Add handling to update logic for unordered lists; use handle_updates in NB & instance modules * Fix backups test * Revert requirement --- docs/modules/nodebalancer.md | 1 + plugins/module_utils/linode_helper.py | 13 +++- plugins/modules/instance.py | 43 +++-------- plugins/modules/nodebalancer.py | 57 +++++--------- requirements.txt | 2 +- .../tasks/main.yaml | 77 +++++++++++++++++++ 6 files changed, 122 insertions(+), 71 deletions(-) create mode 100644 tests/integration/targets/nodebalancer_reordered_tags/tasks/main.yaml diff --git a/docs/modules/nodebalancer.md b/docs/modules/nodebalancer.md index e399798d..6d2237b2 100644 --- a/docs/modules/nodebalancer.md +++ b/docs/modules/nodebalancer.md @@ -48,6 +48,7 @@ Manage a Linode NodeBalancer. | `client_conn_throttle` |
`int`
|
Optional
| Throttle connections per second. Set to 0 (zero) to disable throttling. **(Updatable)** | | `region` |
`str`
|
Optional
| The ID of the Region to create this NodeBalancer in. | | `firewall_id` |
`int`
|
Optional
| The ID of the Firewall to assign this NodeBalancer to. | +| `tags` |
`list`
|
Optional
| Tags to assign to this NodeBalancer. **(Updatable)** | | [`configs` (sub-options)](#configs) |
`list`
|
Optional
| A list of configs to apply to the NodeBalancer. **(Updatable)** | ### configs diff --git a/plugins/module_utils/linode_helper.py b/plugins/module_utils/linode_helper.py index ce65e479..da9fb984 100644 --- a/plugins/module_utils/linode_helper.py +++ b/plugins/module_utils/linode_helper.py @@ -116,6 +116,9 @@ def handle_updates( obj._api_get() + # We need the type to access property metadata + property_metadata = type(obj).properties + # Update mutable values params = filter_null_values(params) @@ -128,7 +131,15 @@ def handle_updates( old_value = parse_linode_types(getattr(obj, key)) - if new_value != old_value: + has_diff = new_value != old_value + + # We should convert properties to sets + # if they are annotated as unordered in the + # Python SDK. + if property_metadata.get(key).unordered: + has_diff = set(old_value) != set(new_value) + + if has_diff: if key in mutable_fields: put_request[key] = new_value result.add(key) diff --git a/plugins/modules/instance.py b/plugins/modules/instance.py index 0e14b62b..8e1dce56 100644 --- a/plugins/modules/instance.py +++ b/plugins/modules/instance.py @@ -23,6 +23,7 @@ drop_empty_strings, filter_null_values, filter_null_values_recursive, + handle_updates, paginated_list_to_json, parse_linode_types, poll_condition, @@ -538,7 +539,7 @@ ) # Fields that can be updated on an existing instance -linode_instance_mutable = {"group", "tags"} +MUTABLE_FIELDS = {"group", "tags"} linode_instance_config_mutable = { "comments", @@ -1172,15 +1173,14 @@ def _update_disks(self) -> None: def _update_instance(self) -> None: """Update instance handles all update functionality for the current instance""" - should_update = False params = filter_null_values(self.module.params) - for key, new_value in params.items(): - if not hasattr(self._instance, key): - continue - - if key in ( + update_params = { + k: v + for k, v in params.items() + if k + not in ( "configs", "disks", "boot_config_label", @@ -1188,31 +1188,12 @@ def _update_instance(self) -> None: "backups_enabled", "type", "region", - ): - continue - - old_value = parse_linode_types(getattr(self._instance, key)) - - if new_value != old_value: - if key in linode_instance_mutable: - setattr(self._instance, key, new_value) - self.register_action( - 'Updated instance {0}: "{1}" -> "{2}"'.format( - key, old_value, new_value - ) - ) - - should_update = True - continue - - self.fail( - "failed to update instance {0}: {1} is a non-updatable field".format( - self._instance.label, key - ) - ) + ) + } - if should_update: - self._instance.save() + handle_updates( + self._instance, update_params, MUTABLE_FIELDS, self.register_action + ) backups_enabled = params.get("backups_enabled") if ( diff --git a/plugins/modules/nodebalancer.py b/plugins/modules/nodebalancer.py index 044aeb8d..e82fcc84 100644 --- a/plugins/modules/nodebalancer.py +++ b/plugins/modules/nodebalancer.py @@ -9,7 +9,6 @@ from typing import Any, List, Optional, Set, Tuple, cast import ansible_collections.linode.cloud.plugins.module_utils.doc_fragments.nodebalancer as docs -import linode_api4 from ansible_collections.linode.cloud.plugins.module_utils.linode_common import ( LinodeModuleBase, ) @@ -20,6 +19,7 @@ from ansible_collections.linode.cloud.plugins.module_utils.linode_helper import ( dict_select_matching, filter_null_values, + handle_updates, paginated_list_to_json, ) from ansible_specdoc.objects import ( @@ -248,6 +248,12 @@ type=FieldType.integer, description=["The ID of the Firewall to assign this NodeBalancer to."], ), + "tags": SpecField( + type=FieldType.list, + element_type=FieldType.string, + editable=True, + description=["Tags to assign to this NodeBalancer."], + ), "state": SpecField( type=FieldType.string, description=["The desired state of the target."], @@ -299,7 +305,7 @@ }, ) -linode_nodebalancer_mutable: Set[str] = {"client_conn_throttle", "tags"} +MUTABLE_FIELDS: Set[str] = {"client_conn_throttle", "tags"} class LinodeNodeBalancer(LinodeModuleBase): @@ -356,13 +362,15 @@ def _get_node_by_label( def _create_nodebalancer(self) -> Optional[NodeBalancer]: """Creates a NodeBalancer with the given kwargs""" - params = self.module.params - label = params.get("label") - region = params.get("region") - firewall_id = params.get("firewall_id") + params = { + k: v + for k, v in self.module.params.items() + if k in {"client_conn_throttle", "label", "firewall_id", "tags"} + } + try: return self.client.nodebalancer_create( - region, label=label, firewall_id=firewall_id + self.module.params.get("region"), **params ) except Exception as exception: return self.fail(msg=f"failed to create nodebalancer: {exception}") @@ -526,8 +534,7 @@ def _handle_configs(self) -> None: ) def _update_nodebalancer(self) -> None: - """Update instance handles all update functionality for the current nodebalancer""" - should_update = False + """Handles updating the current NodeBalancer""" params = filter_null_values(self.module.params) @@ -545,35 +552,9 @@ def _update_nodebalancer(self) -> None: "Firewall attachments can only be updated via the firewall_device module." ) - for key, new_value in params.items(): - if not hasattr(self._node_balancer, key): - continue - - old_value = getattr(self._node_balancer, key) - - if isinstance(old_value, linode_api4.objects.linode.Region): - old_value = old_value.id - - if new_value != old_value: - if key in linode_nodebalancer_mutable: - setattr(self._node_balancer, key, new_value) - self.register_action( - 'Updated nodebalancer {0}: "{1}" -> "{2}"'.format( - key, old_value, new_value - ) - ) - - should_update = True - continue - - self.fail( - "failed to update nodebalancer {0}: {1} is a non-updatable field".format( - self._node_balancer.label, key - ) - ) - - if should_update: - self._node_balancer.save() + handle_updates( + self._node_balancer, params, MUTABLE_FIELDS, self.register_action + ) def _handle_nodebalancer(self) -> None: """Updates the NodeBalancer defined in kwargs""" diff --git a/requirements.txt b/requirements.txt index c1e6e0aa..d96bf1d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -linode-api4>=5.13.1 +linode-api4>=5.15.0 polling>=0.3.2 types-requests==2.31.0.10 ansible-specdoc>=0.0.14 diff --git a/tests/integration/targets/nodebalancer_reordered_tags/tasks/main.yaml b/tests/integration/targets/nodebalancer_reordered_tags/tasks/main.yaml new file mode 100644 index 00000000..91c2231d --- /dev/null +++ b/tests/integration/targets/nodebalancer_reordered_tags/tasks/main.yaml @@ -0,0 +1,77 @@ +- name: nodebalancer_basic + block: + - set_fact: + r: "{{ 1000000000 | random }}" + + - name: Create a NodeBalancer with tags + linode.cloud.nodebalancer: + label: 'ansible-test-{{ r }}' + region: us-ord + tags: + - test1 + - test2 + - test3 + state: present + register: create_nodebalancer + + - name: Assert NodeBalancer is created + assert: + that: + - create_nodebalancer.changed + - create_nodebalancer.node_balancer.tags|length == 3 + + - name: Reorder the NodeBalancer's tags + linode.cloud.nodebalancer: + label: 'ansible-test-{{ r }}' + region: us-ord + tags: + - test3 + - test1 + - test2 + state: present + register: reorder_nodebalancer_tags + + - name: Assert NodeBalancer is not updated + assert: + that: + - not reorder_nodebalancer_tags.changed + + - name: Update the NodeBalancer's tags + linode.cloud.nodebalancer: + label: 'ansible-test-{{ r }}' + region: us-ord + tags: + - test1 + - test4 + - test5 + - test6 + state: present + register: update_nodebalancer_tags + + - name: Assert NodeBalancer is updated + assert: + that: + - update_nodebalancer_tags.changed + - update_nodebalancer_tags.node_balancer.tags | length == 4 + + always: + - ignore_errors: yes + block: + - name: Delete the NodeBalancer + linode.cloud.nodebalancer: + label: '{{ create_nodebalancer.node_balancer.label }}' + state: absent + register: delete_nodebalancer + + - name: Assert NodeBalancer delete + assert: + that: + - delete_nodebalancer.changed + + environment: + LINODE_UA_PREFIX: '{{ ua_prefix }}' + LINODE_API_TOKEN: '{{ api_token }}' + LINODE_API_URL: '{{ api_url }}' + LINODE_API_VERSION: '{{ api_version }}' + LINODE_CA: '{{ ca_file or "" }}' + From 09b18449473c0a4d1c95f8923053ee0eb4926c6e Mon Sep 17 00:00:00 2001 From: Ye Chen <127243817+yec-akamai@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:21:30 -0400 Subject: [PATCH 4/9] new: Add support to `available` field to account_availability info and list module (#494) * update available * add test * add comment --- docs/modules/account_availability_info.md | 1 + docs/modules/account_availability_list.md | 2 ++ plugins/module_utils/doc_fragments/account_availability_info.py | 1 + plugins/module_utils/doc_fragments/account_availability_list.py | 2 ++ .../targets/account_availability_info/tasks/main.yaml | 2 ++ 5 files changed, 8 insertions(+) diff --git a/docs/modules/account_availability_info.md b/docs/modules/account_availability_info.md index 523147cb..5b2fe5fe 100644 --- a/docs/modules/account_availability_info.md +++ b/docs/modules/account_availability_info.md @@ -40,6 +40,7 @@ Get info about a Linode Account Availability. { "region": "us-east", + "available": ["NodeBalancers", "Block Storage", "Kubernetes"], "unavailable": ["Linode"] } diff --git a/docs/modules/account_availability_list.md b/docs/modules/account_availability_list.md index 03e673e1..15e3441b 100644 --- a/docs/modules/account_availability_list.md +++ b/docs/modules/account_availability_list.md @@ -48,10 +48,12 @@ List and filter on Account Availabilitys. [ { "region": "ap-west", + "available": ["NodeBalancers", "Block Storage", "Kubernetes"], "unavailable": ["Linode"] }, { "region": "ca-central", + "available": ["NodeBalancers", "Kubernetes"], "unavailable": ["Linode", "Block Storage"] } ] diff --git a/plugins/module_utils/doc_fragments/account_availability_info.py b/plugins/module_utils/doc_fragments/account_availability_info.py index 6376d8f0..a9f2b3d7 100644 --- a/plugins/module_utils/doc_fragments/account_availability_info.py +++ b/plugins/module_utils/doc_fragments/account_availability_info.py @@ -3,6 +3,7 @@ result_account_availability_samples = [''' { "region": "us-east", + "available": ["NodeBalancers", "Block Storage", "Kubernetes"], "unavailable": ["Linode"] } '''] diff --git a/plugins/module_utils/doc_fragments/account_availability_list.py b/plugins/module_utils/doc_fragments/account_availability_list.py index 5fab4eab..d90014e1 100644 --- a/plugins/module_utils/doc_fragments/account_availability_list.py +++ b/plugins/module_utils/doc_fragments/account_availability_list.py @@ -8,10 +8,12 @@ result_account_availabilities_samples = ['''[ { "region": "ap-west", + "available": ["NodeBalancers", "Block Storage", "Kubernetes"], "unavailable": ["Linode"] }, { "region": "ca-central", + "available": ["NodeBalancers", "Kubernetes"], "unavailable": ["Linode", "Block Storage"] } ]'''] diff --git a/tests/integration/targets/account_availability_info/tasks/main.yaml b/tests/integration/targets/account_availability_info/tasks/main.yaml index e7e39dc0..fcc7bb7f 100644 --- a/tests/integration/targets/account_availability_info/tasks/main.yaml +++ b/tests/integration/targets/account_availability_info/tasks/main.yaml @@ -9,6 +9,8 @@ assert: that: - account_availability.account_availability.region == "us-east" + # There are only the four services (Linodes, NodeBalancers, Block Storage, Kubernetes) gated for the account availability. + - account_availability.account_availability.available | length + account_availability.account_availability.unavailable | length == 4 environment: LINODE_UA_PREFIX: '{{ ua_prefix }}' From efe0ea50474889093e450d8f64dced949b25b82e Mon Sep 17 00:00:00 2001 From: Lena Garber <114949949+lgarber-akamai@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:16:21 -0400 Subject: [PATCH 5/9] Address breaking change (#497) --- plugins/modules/instance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/instance.py b/plugins/modules/instance.py index 8e1dce56..b34eccfe 100644 --- a/plugins/modules/instance.py +++ b/plugins/modules/instance.py @@ -1050,7 +1050,7 @@ def _update_config( # Special diffing due to handling in linode_api4-python if key == "devices": - for device_key, device in old_value.items(): + for device_key, device in vars(config.devices).items(): if not self._compare_param_to_device( new_value[device_key], device ): From 352efc87ea712253d1fbb88d09f2d2832ae2b2b3 Mon Sep 17 00:00:00 2001 From: Lena Garber <114949949+lgarber-akamai@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:14:52 -0400 Subject: [PATCH 6/9] fix: Resolve error in `handle_updates` when key is not valid (#496) * Check that property_metadata is not None before referencing * oops * oops * Replace key in with .get(key) is not None --- plugins/module_utils/linode_helper.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/module_utils/linode_helper.py b/plugins/module_utils/linode_helper.py index da9fb984..9030478e 100644 --- a/plugins/module_utils/linode_helper.py +++ b/plugins/module_utils/linode_helper.py @@ -136,7 +136,11 @@ def handle_updates( # We should convert properties to sets # if they are annotated as unordered in the # Python SDK. - if property_metadata.get(key).unordered: + if ( + property_metadata is not None + and property_metadata.get(key) is not None + and property_metadata.get(key).unordered + ): has_diff = set(old_value) != set(new_value) if has_diff: From 42e678d3d5fbab9fb172d60a4053074f3f4cd501 Mon Sep 17 00:00:00 2001 From: Zhiwei Liang <121905282+zliang-akamai@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:17:16 -0400 Subject: [PATCH 7/9] Fix plural noun in doc (#498) --- README.md | 2 +- docs/modules/account_availability_list.md | 12 ++++++------ docs/modules/vpc_subnet_list.md | 2 +- plugins/module_utils/linode_common_list.py | 14 +++++++------- plugins/modules/account_availability_list.py | 2 +- plugins/modules/image_list.py | 2 +- plugins/modules/vpc_list.py | 2 +- plugins/modules/vpc_subnet_list.py | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index e7f79f3f..5e31cc81 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Modules for retrieving and filtering on multiple Linode resources. Name | Description | --- | ------------ | -[linode.cloud.account_availability_list](./docs/modules/account_availability_list.md)|List and filter on Account Availabilitys.| +[linode.cloud.account_availability_list](./docs/modules/account_availability_list.md)|List and filter on Account Availabilities.| [linode.cloud.database_engine_list](./docs/modules/database_engine_list.md)|List and filter on Managed Database engine types.| [linode.cloud.database_list](./docs/modules/database_list.md)|List and filter on Linode Managed Databases.| [linode.cloud.domain_list](./docs/modules/domain_list.md)|List and filter on Domains.| diff --git a/docs/modules/account_availability_list.md b/docs/modules/account_availability_list.md index 15e3441b..3b21b205 100644 --- a/docs/modules/account_availability_list.md +++ b/docs/modules/account_availability_list.md @@ -1,6 +1,6 @@ # account_availability_list -List and filter on Account Availabilitys. +List and filter on Account Availabilities. **:warning: This module makes use of beta endpoints and requires the `api_version` field be explicitly set to `v4beta`.** @@ -27,10 +27,10 @@ List and filter on Account Availabilitys. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `order` |
`str`
|
Optional
| The order to list Account Availabilitys in. **(Choices: `desc`, `asc`; Default: `asc`)** | -| `order_by` |
`str`
|
Optional
| The attribute to order Account Availabilitys by. | -| [`filters` (sub-options)](#filters) |
`list`
|
Optional
| A list of filters to apply to the resulting Account Availabilitys. | -| `count` |
`int`
|
Optional
| The number of Account Availabilitys to return. If undefined, all results will be returned. | +| `order` |
`str`
|
Optional
| The order to list Account Availabilities in. **(Choices: `desc`, `asc`; Default: `asc`)** | +| `order_by` |
`str`
|
Optional
| The attribute to order Account Availabilities by. | +| [`filters` (sub-options)](#filters) |
`list`
|
Optional
| A list of filters to apply to the resulting Account Availabilities. | +| `count` |
`int`
|
Optional
| The number of Account Availabilities to return. If undefined, all results will be returned. | ### filters @@ -41,7 +41,7 @@ List and filter on Account Availabilitys. ## Return Values -- `account_availabilities` - The returned Account Availabilitys. +- `account_availabilities` - The returned Account Availabilities. - Sample Response: ```json diff --git a/docs/modules/vpc_subnet_list.md b/docs/modules/vpc_subnet_list.md index 4a9a4f42..893db6d5 100644 --- a/docs/modules/vpc_subnet_list.md +++ b/docs/modules/vpc_subnet_list.md @@ -35,7 +35,7 @@ List and filter on VPC Subnets. | Field | Type | Required | Description | |-----------|------|----------|------------------------------------------------------------------------------| -| `vpc_id` |
`int`
|
**Required**
| The parent VPC for this VPC Subnet. | +| `vpc_id` |
`int`
|
**Required**
| The parent VPC for the VPC Subnets. | | `order` |
`str`
|
Optional
| The order to list VPC Subnets in. **(Choices: `desc`, `asc`; Default: `asc`)** | | `order_by` |
`str`
|
Optional
| The attribute to order VPC Subnets by. | | [`filters` (sub-options)](#filters) |
`list`
|
Optional
| A list of filters to apply to the resulting VPC Subnets. | diff --git a/plugins/module_utils/linode_common_list.py b/plugins/module_utils/linode_common_list.py index 0bdae4e9..7f5e8994 100644 --- a/plugins/module_utils/linode_common_list.py +++ b/plugins/module_utils/linode_common_list.py @@ -118,7 +118,7 @@ def spec(self): "order": SpecField( type=FieldType.string, description=[ - f"The order to list {self.result_display_name}s in." + f"The order to list {self.result_display_name} in." ], default="asc", choices=["desc", "asc"], @@ -126,7 +126,7 @@ def spec(self): "order_by": SpecField( type=FieldType.string, description=[ - f"The attribute to order {self.result_display_name}s by." + f"The attribute to order {self.result_display_name} by." ], ), "filters": SpecField( @@ -134,13 +134,13 @@ def spec(self): element_type=FieldType.dict, suboptions=spec_filter, description=[ - f"A list of filters to apply to the resulting {self.result_display_name}s." + f"A list of filters to apply to the resulting {self.result_display_name}." ], ), "count": SpecField( type=FieldType.integer, description=[ - f"The number of {self.result_display_name}s to return.", + f"The number of {self.result_display_name} to return.", "If undefined, all results will be returned.", ], ), @@ -151,12 +151,12 @@ def spec(self): options[param.name] = SpecField( type=param.type, description=[ - f"The parent {param.display_name} for this {self.result_display_name}." + f"The parent {param.display_name} for the {self.result_display_name}." ], required=True, ) - description = [f"List and filter on {self.result_display_name}s."] + description = [f"List and filter on {self.result_display_name}."] if self.requires_beta: description.append(BETA_DISCLAIMER) @@ -169,7 +169,7 @@ def spec(self): examples=self.examples, return_values={ self.result_field_name: SpecReturnValue( - description=f"The returned {self.result_display_name}s.", + description=f"The returned {self.result_display_name}.", docs_url=self.result_docs_url, type=FieldType.list, elements=FieldType.dict, diff --git a/plugins/modules/account_availability_list.py b/plugins/modules/account_availability_list.py index 5caaba68..2a8f633e 100644 --- a/plugins/modules/account_availability_list.py +++ b/plugins/modules/account_availability_list.py @@ -13,7 +13,7 @@ ) module = ListModule( - result_display_name="Account Availability", + result_display_name="Account Availabilities", result_field_name="account_availabilities", endpoint_template="/account/availability", result_docs_url="TBD", diff --git a/plugins/modules/image_list.py b/plugins/modules/image_list.py index fe749b49..0242d26c 100644 --- a/plugins/modules/image_list.py +++ b/plugins/modules/image_list.py @@ -11,7 +11,7 @@ ) module = ListModule( - result_display_name="Image", + result_display_name="Images", result_field_name="images", endpoint_template="/images", result_docs_url="https://www.linode.com/docs/api/images/#images-list__responses", diff --git a/plugins/modules/vpc_list.py b/plugins/modules/vpc_list.py index 152d5a21..4fc4e64a 100644 --- a/plugins/modules/vpc_list.py +++ b/plugins/modules/vpc_list.py @@ -11,7 +11,7 @@ ) module = ListModule( - result_display_name="VPC", + result_display_name="VPCs", result_field_name="vpcs", endpoint_template="/vpcs", result_docs_url="", diff --git a/plugins/modules/vpc_subnet_list.py b/plugins/modules/vpc_subnet_list.py index acdd54cb..698b2212 100644 --- a/plugins/modules/vpc_subnet_list.py +++ b/plugins/modules/vpc_subnet_list.py @@ -13,7 +13,7 @@ from ansible_specdoc.objects import FieldType module = ListModule( - result_display_name="VPC Subnet", + result_display_name="VPC Subnets", result_field_name="subnets", endpoint_template="/vpcs/{vpc_id}/subnets", result_docs_url="", From f2e553d83ab5abd3adeec4beb7e5a26f8b8a88f6 Mon Sep 17 00:00:00 2001 From: Zhiwei Liang <121905282+zliang-akamai@users.noreply.github.com> Date: Sat, 20 Apr 2024 03:44:30 -0400 Subject: [PATCH 8/9] Add `networking_info` attribute to inventory instances (#493) --- plugins/inventory/instance.py | 9 ++++++--- requirements.txt | 2 +- .../playbooks/test_inventory_filter.yml | 5 ++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/inventory/instance.py b/plugins/inventory/instance.py index d523c9e2..ba47a1b2 100644 --- a/plugins/inventory/instance.py +++ b/plugins/inventory/instance.py @@ -19,7 +19,7 @@ ) from linode_api4.objects import Instance -DOCUMENTATION = r""" +DOCUMENTATION = """ name: instance author: - Luke Murphy (@decentral1se) @@ -59,7 +59,7 @@ type: list """ -EXAMPLES = r""" +EXAMPLES = """ # Minimal example. `LINODE_API_TOKEN` is exposed in environment. plugin: linode.cloud.instance @@ -209,7 +209,10 @@ def _add_instances_to_groups(self) -> None: def _add_hostvars_for_instances(self) -> None: """Add hostvars for instances in the dynamic inventory.""" for instance in self.instances: - hostvars = instance._raw_json + hostvars = {} + hostvars.update(instance._raw_json) + hostvars["networking_info"] = instance.ips.dict + for hostvar_key in hostvars: self.inventory.set_variable( instance.label, hostvar_key, hostvars[hostvar_key] diff --git a/requirements.txt b/requirements.txt index d96bf1d3..5ef3018c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -linode-api4>=5.15.0 +linode-api4>=5.15.1 polling>=0.3.2 types-requests==2.31.0.10 ansible-specdoc>=0.0.14 diff --git a/tests/integration/targets/instance_inventory/playbooks/test_inventory_filter.yml b/tests/integration/targets/instance_inventory/playbooks/test_inventory_filter.yml index 9e9924d1..e359b26b 100644 --- a/tests/integration/targets/instance_inventory/playbooks/test_inventory_filter.yml +++ b/tests/integration/targets/instance_inventory/playbooks/test_inventory_filter.yml @@ -9,4 +9,7 @@ assert: that: - '"ansible-test-inventory" in hostvars' - - hostvars | length == 1 \ No newline at end of file + - hostvars | length == 1 + - '"networking_info" in hostvars["ansible-test-inventory"]' + - '"ipv4" in hostvars["ansible-test-inventory"]["networking_info"]' + - '"ipv6" in hostvars["ansible-test-inventory"]["networking_info"]' \ No newline at end of file From 7108ce04f57172ed598de9432e9e175810ecf0e1 Mon Sep 17 00:00:00 2001 From: Youjung Kim <126618609+ykim-1@users.noreply.github.com> Date: Mon, 22 Apr 2024 09:14:20 -0700 Subject: [PATCH 9/9] update tod_scripts for error handling (#501) --- tod_scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tod_scripts b/tod_scripts index 41b85dd2..e8c8e15c 160000 --- a/tod_scripts +++ b/tod_scripts @@ -1 +1 @@ -Subproject commit 41b85dd2c5588b5b343b8ee365b2f4f196cd9a7f +Subproject commit e8c8e15ce833a169837f8d1513bd2185af2c645b