From 851459ea40fed988d7002494d8931b1c5ca76ac6 Mon Sep 17 00:00:00 2001 From: George Shuklin Date: Tue, 16 Jan 2024 16:11:53 +0200 Subject: [PATCH 01/10] ci: allow manual run for job --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5c025cb..6d45705 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -5,6 +5,7 @@ name: Test and build push: paths-ignore: - ".github/**" + workflow_dispatch: jobs: lint: @@ -25,7 +26,6 @@ jobs: - "3.8" - "3.7" - "3.6" - # - "3.10" steps: - name: Checkout uses: actions/checkout@v3 From e66def6b679b0e237a941a06bb418b4b3b3093a7 Mon Sep 17 00:00:00 2001 From: George Shuklin Date: Tue, 16 Jan 2024 16:12:26 +0200 Subject: [PATCH 02/10] fix: fix pylint warnings (ansible-test 2.16) --- .../serverscom/sc_api/plugins/module_utils/modules.py | 3 ++- .../sc_api/plugins/modules/sc_baremetal_servers_info.py | 1 - .../sc_api/plugins/modules/sc_cloud_computing_flavors_info.py | 1 - .../sc_api/plugins/modules/sc_cloud_computing_images_info.py | 1 - .../sc_api/plugins/modules/sc_cloud_computing_instance_info.py | 1 - .../sc_api/plugins/modules/sc_cloud_computing_instance_ptr.py | 1 - .../plugins/modules/sc_cloud_computing_instance_state.py | 1 - .../plugins/modules/sc_cloud_computing_instances_info.py | 1 - .../modules/sc_cloud_computing_openstack_credentials.py | 1 - .../sc_api/plugins/modules/sc_dedicated_server_info.py | 1 - .../serverscom/sc_api/plugins/modules/sc_ssh_key.py | 1 - .../serverscom/sc_api/plugins/modules/sc_ssh_keys_info.py | 1 - 12 files changed, 2 insertions(+), 12 deletions(-) diff --git a/ansible_collections/serverscom/sc_api/plugins/module_utils/modules.py b/ansible_collections/serverscom/sc_api/plugins/module_utils/modules.py index 7d2c089..182f635 100644 --- a/ansible_collections/serverscom/sc_api/plugins/module_utils/modules.py +++ b/ansible_collections/serverscom/sc_api/plugins/module_utils/modules.py @@ -7,12 +7,13 @@ SCBaseError, APIError404, APIError409, - DEFAULT_API_ENDPOINT, + DEFAULT_API_ENDPOIT, ScApi, ) __metaclass__ = type +_ignore = DEFAULT_API_ENDPOIT # to mute linter, DEFAULT_API_ENDPOIT is for reexport. CHANGED = True NOT_CHANGED = False diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_baremetal_servers_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_baremetal_servers_info.py index 9f1bb41..a673d1b 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_baremetal_servers_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_baremetal_servers_info.py @@ -88,7 +88,6 @@ from ansible.module_utils.basic import AnsibleModule -import json from ansible_collections.serverscom.sc_api.plugins.module_utils.modules import ( DEFAULT_API_ENDPOINT, SCBaseError, diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_flavors_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_flavors_info.py index 058ce3c..6a459bb 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_flavors_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_flavors_info.py @@ -101,7 +101,6 @@ from ansible.module_utils.basic import AnsibleModule -import json from ansible_collections.serverscom.sc_api.plugins.module_utils.modules import ( DEFAULT_API_ENDPOINT, SCBaseError, diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_images_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_images_info.py index 0980a3a..0ad2ebb 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_images_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_images_info.py @@ -107,7 +107,6 @@ from ansible.module_utils.basic import AnsibleModule -import json from ansible_collections.serverscom.sc_api.plugins.module_utils.modules import ( DEFAULT_API_ENDPOINT, SCBaseError, diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_info.py index c22a891..24de428 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_info.py @@ -214,7 +214,6 @@ from ansible.module_utils.basic import AnsibleModule -import json from ansible_collections.serverscom.sc_api.plugins.module_utils.modules import ( DEFAULT_API_ENDPOINT, SCBaseError, diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_ptr.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_ptr.py index 8549a6e..49dda6e 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_ptr.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_ptr.py @@ -148,7 +148,6 @@ from ansible.module_utils.basic import AnsibleModule -import json from ansible_collections.serverscom.sc_api.plugins.module_utils.modules import ( DEFAULT_API_ENDPOINT, SCBaseError, diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_state.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_state.py index 049978e..d78ce34 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_state.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_state.py @@ -280,7 +280,6 @@ from ansible.module_utils.basic import AnsibleModule -import json from ansible_collections.serverscom.sc_api.plugins.module_utils.modules import ( DEFAULT_API_ENDPOINT, SCBaseError, diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instances_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instances_info.py index ca21da2..744ca83 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instances_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instances_info.py @@ -178,7 +178,6 @@ from ansible.module_utils.basic import AnsibleModule -import json from ansible_collections.serverscom.sc_api.plugins.module_utils.modules import ( DEFAULT_API_ENDPOINT, SCBaseError, diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_openstack_credentials.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_openstack_credentials.py index dd450ee..cec291d 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_openstack_credentials.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_openstack_credentials.py @@ -132,7 +132,6 @@ from ansible.module_utils.basic import AnsibleModule -import json from ansible_collections.serverscom.sc_api.plugins.module_utils.modules import ( DEFAULT_API_ENDPOINT, SCBaseError, diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_info.py index 27c7b2f..0c8aa48 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_info.py @@ -270,7 +270,6 @@ from ansible.module_utils.basic import AnsibleModule -import json from ansible_collections.serverscom.sc_api.plugins.module_utils.modules import ( DEFAULT_API_ENDPOINT, SCBaseError, diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_ssh_key.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_ssh_key.py index 8e7637c..5df84d0 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_ssh_key.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_ssh_key.py @@ -117,7 +117,6 @@ from ansible.module_utils.basic import AnsibleModule -import json from ansible_collections.serverscom.sc_api.plugins.module_utils.modules import ( DEFAULT_API_ENDPOINT, SCBaseError, diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_ssh_keys_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_ssh_keys_info.py index e620ae1..16dca16 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_ssh_keys_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_ssh_keys_info.py @@ -89,7 +89,6 @@ from ansible.module_utils.basic import AnsibleModule -import json from ansible_collections.serverscom.sc_api.plugins.module_utils.modules import ( DEFAULT_API_ENDPOINT, SCBaseError, From c47941dbb5f0fa0919ea42ad86e5e365328e1991 Mon Sep 17 00:00:00 2001 From: George Shuklin Date: Wed, 17 Jan 2024 10:55:46 +0200 Subject: [PATCH 03/10] chore: bump ansible version for tests, use only 3.8 for now --- .github/workflows/tests.yaml | 9 +-------- requirements.txt | 5 +++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 6d45705..7320114 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -23,9 +23,7 @@ jobs: strategy: matrix: python_version: - - "3.8" - - "3.7" - - "3.6" + - "3.11" steps: - name: Checkout uses: actions/checkout@v3 @@ -36,7 +34,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest pip install -r requirements.txt - name: Sanity tests with dependencies run: ansible-test sanity --requirements --python ${{ matrix.python_version }} @@ -62,7 +59,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest pip install -r requirements.txt - name: Configure integration tests run: | @@ -105,7 +101,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest pip install -r requirements.txt - name: Configure integration tests run: | @@ -143,7 +138,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest pip install -r requirements.txt - name: Configure integration tests run: | @@ -179,7 +173,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest pip install -r requirements.txt - name: Remove tests from final distribution run: rm -r tests/ diff --git a/requirements.txt b/requirements.txt index e2fa2d6..4115a9a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -ansible==2.9.20 +ansible==2.16.2 wheel openstacksdk -jinja2<3.1 +flake8 +pytest From 04a8c61ca503847a10601ba950d64eee4f02f5b5 Mon Sep 17 00:00:00 2001 From: George Shuklin Date: Wed, 17 Jan 2024 10:59:02 +0200 Subject: [PATCH 04/10] fix: typo with DEFAULT_API_ENDPOIT --- .../serverscom/sc_api/plugins/module_utils/modules.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible_collections/serverscom/sc_api/plugins/module_utils/modules.py b/ansible_collections/serverscom/sc_api/plugins/module_utils/modules.py index 182f635..75a0413 100644 --- a/ansible_collections/serverscom/sc_api/plugins/module_utils/modules.py +++ b/ansible_collections/serverscom/sc_api/plugins/module_utils/modules.py @@ -7,13 +7,13 @@ SCBaseError, APIError404, APIError409, - DEFAULT_API_ENDPOIT, + DEFAULT_API_ENDPOINT, ScApi, ) __metaclass__ = type -_ignore = DEFAULT_API_ENDPOIT # to mute linter, DEFAULT_API_ENDPOIT is for reexport. +_ignored = DEFAULT_API_ENDPOINT # to silence pylint warning, it is reimported CHANGED = True NOT_CHANGED = False From 1b144d56ee548cc313a50393e62683017d840a8d Mon Sep 17 00:00:00 2001 From: George Shuklin Date: Wed, 17 Jan 2024 11:36:35 +0200 Subject: [PATCH 05/10] fix: update style to match ansible-test 2.16 --- .../modules/sc_baremetal_servers_info.py | 2 +- .../sc_cloud_computing_flavors_info.py | 4 ++-- .../modules/sc_cloud_computing_images_info.py | 4 ++-- .../modules/sc_cloud_computing_instance.py | 20 +++++++++---------- .../sc_cloud_computing_instance_state.py | 9 +++++---- .../sc_cloud_computing_instances_info.py | 4 ++-- ...c_cloud_computing_openstack_credentials.py | 4 ++-- .../modules/sc_dedicated_server_info.py | 4 ++-- .../modules/sc_dedicated_server_reinstall.py | 6 +++--- 9 files changed, 29 insertions(+), 28 deletions(-) diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_baremetal_servers_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_baremetal_servers_info.py index a673d1b..a27a169 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_baremetal_servers_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_baremetal_servers_info.py @@ -26,7 +26,7 @@ Retrive list of all existing dedicated baremetal servers. notes: - - Not to be confused with M(sc_dedicated_servers_info). + - Not to be confused with M(serverscom.sc_api.sc_dedicated_servers_info). - Includes information for both dedicated and other types of servers (f.e. kubernetes baremetal node) diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_flavors_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_flavors_info.py index 6a459bb..c4c6ed6 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_flavors_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_flavors_info.py @@ -46,8 +46,8 @@ required: true description: - Id of cloud computing region. - - Use I(sc_cloud_computing_regions_info) module to retrive list of - available regions. + - Use I(serverscom.sc_api.sc_cloud_computing_regions_info) module + to retrive list of available regions. """ RETURN = """ diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_images_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_images_info.py index 0ad2ebb..740e0ca 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_images_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_images_info.py @@ -47,8 +47,8 @@ required: true description: - Id of cloud computing region. - - Use I(sc_cloud_computing_regions_info) module to retrive list of - available regions. + - Use I(serverscom.sc_api.sc_cloud_computing_regions_info) module + to retrive list of available regions. """ RETURN = """ diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance.py index fccb939..e5622e8 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance.py @@ -74,8 +74,8 @@ type: int description: - Id of the cloud region for the instance - - Use M(sc_cloud_computing_regions_info) to get list of available - regions. + - Use M(serverscom.sc_api.sc_cloud_computing_regions_info) to get list + of available regions. - Required for I(state)=C(present). - May be used for other I(state) to narrow search to one region with I(name). @@ -162,8 +162,8 @@ type: str description: - Fingerprint of the public ssh key to use for user cloud-user. - - Fingerprint must be registered. Use M(sc_ssh_key) to register - public key. + - Fingerprint must be registered. Use M(serverscom.sc_api.sc_ssh_key) + to register public key. - Mutually exclusive with I(ssh_key_name) - Instance is created with password if no I(ssh_key_fingerprint) or I(ssh_key_name) is used. @@ -209,8 +209,8 @@ - Value C(0) is used to disable wait. - If C(0) is set, module works in 'fire-and-forget' mode. - ACTIVE state doesn't mean that instance is ready to accept ssh - connections. Use M(wait_for_connection) module wait until instance - finishes booting. + connections. Use M(ansible.builtin.wait_for_connection) module + to wait until instance finishes booting. - wait time is independent for I(retry_on_conflicts) and status wait. - If instance is in conflicting state, first module will retry up to I(wait) seconds to delete it, and then wait for I(wait) seconds for @@ -242,8 +242,8 @@ - Upgrades are autoconfirmed in 72 hours. - Used only for I(state)=C(upgraded), ignored of other I(state). - If instance is in the state AWAITING_UPGRADE_CONFIRM, - calling M(cloud_computing_instance) with I(state)=C(upgraded) - confirm upgrade. + calling M(serverscom.sc_api.cloud_computing_instance) + with I(state)=C(upgraded) confirm upgrade. - If I(wait)=C(0) instance upgrage is not confirmed even if I(confirm_upgrade)=C(true). """ @@ -376,7 +376,7 @@ EXAMPLES = """ - name: Delete instance by ID - sc_cloud_computing_instance: + serverscom.sc_api.sc_cloud_computing_instance: token: '{{ sc_token }}' instance_id: M7e5Ba2v state: absent @@ -384,7 +384,7 @@ update_interval: 5 - name: Delete instance by name in region 3 - sc_cloud_computing_instance: + serverscom.sc_api.sc_cloud_computing_instance: token: '{{ sc_token }}' name: test region_id: 3 diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_state.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_state.py index d78ce34..d216d00 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_state.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instance_state.py @@ -26,7 +26,8 @@ description: > Allow to control power state and rescue mode for instance. This module does not allow removal and creation of the instance, - use M(sc_cloud_computing_instance) with state=present/absent. + use M(serverscom.sc_api.sc_cloud_computing_instance) + with state=present/absent. options: endpoint: @@ -111,9 +112,9 @@ - Value C(0) is used to disable wait. - If C(0) is set, module works in 'fire-and-forget' mode. - ACTIVE state doesn't mean that instance is ready to accept ssh - connections. Use M(wait_for_connection) module wait until instance - finishes booting. handlers or when statement may be used - to preserve idempotency. + connections. Use M(ansible.builtin.wait_for_connection) module + wait until instance finishes booting. + handlers or when statement may be used to preserve idempotency. update_interval: type: int diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instances_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instances_info.py index 744ca83..368e34e 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instances_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_instances_info.py @@ -45,8 +45,8 @@ type: int description: - Id of cloud computing region to filter. - - Use I(sc_cloud_computing_regions_info) module to retrive list of - available regions. + - Use I(serverscom.sc_api.sc_cloud_computing_regions_info) module + to retrive list of available regions. - Module returns instances for all regions if I(region_id) is not specified. """ diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_openstack_credentials.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_openstack_credentials.py index cec291d..f2b814a 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_openstack_credentials.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_cloud_computing_openstack_credentials.py @@ -59,8 +59,8 @@ required: true description: - Id of cloud computing region. - - Use I(sc_cloud_computing_regions_info) module to retrive list of - available regions. + - Use I(serverscom.sc_api.sc_cloud_computing_regions_info) module + to retrive list of available regions. """ RETURN = """ diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_info.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_info.py index 0c8aa48..190819f 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_info.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_info.py @@ -250,7 +250,7 @@ EXAMPLES = """ - name: Get server info - sc_dedicated_server_info: + serverscom.sc_api.sc_dedicated_server_info: token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MzgxMjEsInR5cGUiOiJVc2VyIiwiYWNjZXNzX2dyYW50X2lkIjoyNjgwNywiZXhwIjoyMjI2OTk3NjMwfQ.rO4nGXNgXggjNmMJBLXovOh1coNrDWl4dGrGFupYXJE' id: '0m592Zmn' register: srv @@ -259,7 +259,7 @@ msg: 'Server {{ srv.name }} has IP {{ srv.public_ipv4_address }}' - name: Wait until server is ready - sc_dedicated_server_info: + serverscom.sc_api.sc_dedicated_server_info: token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MzgxMjEsInR5cGUiOiJVc2VyIiwiYWNjZXNzX2dyYW50X2lkIjoyNjgwNywiZXhwIjoyMjI2OTk3NjMwfQ.rO4nGXNgXggjNmMJBLXovOh1coNrDWl4dGrGFupYXJE' id: '0m592Zmn' register: srv diff --git a/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_reinstall.py b/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_reinstall.py index 3e83144..b67b420 100644 --- a/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_reinstall.py +++ b/ansible_collections/serverscom/sc_api/plugins/modules/sc_dedicated_server_reinstall.py @@ -155,7 +155,7 @@ elements: str description: - Array of fingerprints of public ssh keys to add for root user. - - Keys must be registered before use by module M(sc_ssh_key). + - Keys must be registered before use by module M(serverscom.sc_api.sc_ssh_key). - Mutually exclusive with I(ssh_key_name). - Server is reinstalled with root password only if no I(ssh_keys) or I(ssh_key_name) specified. @@ -181,8 +181,8 @@ - When server become 'ready' after reinstallation, it can still be in booting state for some time and do not answer ssh/ping request. - Use M(wait_for_connection) module to wait the server - to become available though ssh. + Use M(serverscom.sc_api.wait_for_connection) module + to wait the server to become available though ssh. - Installation may start few minutes later than request, during this time server is responding with 'old' ssh. From 5c42edb35c344a23faab1de90e5584fcb3ba3cfd Mon Sep 17 00:00:00 2001 From: George Shuklin Date: Wed, 17 Jan 2024 11:58:15 +0200 Subject: [PATCH 06/10] fix: versions --- .github/workflows/tests.yaml | 22 +++++++++++----------- requirements.txt | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 7320114..af42103 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -52,10 +52,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python uses: actions/setup-python@v2 with: - python-version: "3.8" + python-version: "3.11" - name: Install dependencies run: | python -m pip install --upgrade pip @@ -66,7 +66,7 @@ jobs: env: SC_TOKEN: "${{ secrets.SC_TOKEN }}" - name: Integration tests - run: ansible-test integration --requirements --python 3.8 + run: ansible-test integration --requirements --python 3.11 sc_ssh_key sc_cloud_computing_flavors_info sc_cloud_computing_regions_info @@ -94,10 +94,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python uses: actions/setup-python@v2 with: - python-version: "3.8" + python-version: "3.11" - name: Install dependencies run: | python -m pip install --upgrade pip @@ -108,7 +108,7 @@ jobs: env: SC_TOKEN: "${{ secrets.SC_TOKEN }}" - name: Integration tests - run: ansible-test integration --requirements --python 3.8 + run: ansible-test integration --requirements --python 3.11 sc_ssh_key sc_baremetal_locations_info sc_baremetal_servers_info @@ -131,10 +131,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python uses: actions/setup-python@v2 with: - python-version: "3.8" + python-version: "3.11" - name: Install dependencies run: | python -m pip install --upgrade pip @@ -145,7 +145,7 @@ jobs: env: SC_TOKEN: "${{ secrets.SC_TOKEN }}" - name: Integration tests - run: ansible-test integration --requirements --python 3.8 + run: ansible-test integration --requirements --python 3.11 sc_l2_segment sc_l2_segment_aliases sc_l2_segments_info @@ -166,10 +166,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: "3.11" - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/requirements.txt b/requirements.txt index 4115a9a..4206eae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -ansible==2.16.2 +ansible-core==2.16.2 wheel openstacksdk flake8 From 3ba7266f7c825dd5fe000c0c8d3c0029ef216881 Mon Sep 17 00:00:00 2001 From: George Shuklin Date: Wed, 17 Jan 2024 14:11:28 +0200 Subject: [PATCH 07/10] fix: selection of flavor in tests shouldn't use flavor-specific img --- .../sc_cloud_computing_instance/tasks/main.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_instance/tasks/main.yaml b/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_instance/tasks/main.yaml index 8ace238..0eb8b11 100644 --- a/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_instance/tasks/main.yaml +++ b/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_instance/tasks/main.yaml @@ -81,6 +81,7 @@ tags: always - name: Test5, create absent instance in check_mode + tags: [test5] block: - name: Test5, create instance in check mode sc_cloud_computing_instance: @@ -89,7 +90,7 @@ state: present region_id: "{{ regions.regions[0].id }}" flavor_id: '{{ (flavor_info.cloud_flavors|sort(attribute="disk"))[0].id }}' - image_id: "{{ img_info.cloud_images[0].id }}" + image_id: "{{ (img_info.cloud_images | selectattr('allowed_flavors', 'equalto', []) | first).id }}" name: ec354674-e844-11ea-ac53-83e1244f3049 backup_copies: 0 gpn: true @@ -120,7 +121,9 @@ update_interval: 5 - name: Test6, normal state=present/state=absent testsuite with wait + tags: [test6] block: + - debug: var=img_info.cloud_images - name: Test6, create instance with wait sc_cloud_computing_instance: token: "{{ sc_token }}" @@ -128,7 +131,7 @@ state: present region_id: "{{ regions.regions[0].id }}" flavor_id: '{{ (flavor_info.cloud_flavors|sort(attribute="disk"))[0].id }}' - image_id: "{{ img_info.cloud_images[0].id }}" + image_id: "{{ (img_info.cloud_images | selectattr('allowed_flavors', 'equalto', []) | first).id }}" name: 52310c60-7446-482d-a30e-2bedeb515878 backup_copies: 0 gpn: true @@ -158,7 +161,7 @@ state: present region_id: "{{ regions.regions[0].id }}" flavor_id: '{{ (flavor_info.cloud_flavors|sort(attribute="disk"))[0].id }}' - image_id: "{{ img_info.cloud_images[0].id }}" + image_id: "{{ (img_info.cloud_images | selectattr('allowed_flavors', 'equalto', []) | first).id }}" name: 52310c60-7446-482d-a30e-2bedeb515878 backup_copies: 0 gpn: true @@ -174,7 +177,7 @@ state: present region_id: "{{ regions.regions[0].id }}" flavor_id: '{{ (flavor_info.cloud_flavors|sort(attribute="disk"))[0].id }}' - image_id: "{{ img_info.cloud_images[0].id }}" + image_id: "{{ (img_info.cloud_images | selectattr('allowed_flavors', 'equalto', []) | first).id }}" name: 52310c60-7446-482d-a30e-2bedeb515878 backup_copies: 0 gpn: true @@ -213,7 +216,7 @@ state: present region_id: "{{ regions.regions[0].id }}" flavor_id: '{{ (flavor_info.cloud_flavors|sort(attribute="disk"))[0].id }}' - image_id: "{{ img_info.cloud_images[0].id }}" + image_id: "{{ (img_info.cloud_images | selectattr('allowed_flavors', 'equalto', []) | first).id }}" name: c4edd55c-8a79-4181-b880-917b8ee5cdf2 backup_copies: 0 gpn: false @@ -313,7 +316,7 @@ name: 15a0688b-44f6-41e2-971c-4e860c402373 region_id: "{{ regions.regions[0].id }}" flavor_name: "dont.exist" - image_id: "{{ img_info.cloud_images[0].id }}" + image_id: "{{ (img_info.cloud_images | selectattr('allowed_flavors', 'equalto', []) | first).id }}" register: test8_flavor failed_when: false From 462c2e0dfb3030a121accef3f0387c12563dd42c Mon Sep 17 00:00:00 2001 From: George Shuklin Date: Wed, 17 Jan 2024 14:11:51 +0200 Subject: [PATCH 08/10] docs: some devel intro --- devel.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 devel.md diff --git a/devel.md b/devel.md new file mode 100644 index 0000000..8b8e802 --- /dev/null +++ b/devel.md @@ -0,0 +1,40 @@ +# Getting started + +1. Install/configure venv using requirements.txt. +2. Do not forget to update your python version in commands below. +3. All ansible-test invocations should happen in `ansible_collections/serverscom/sc_api`. + This is ansible-test requirement. +4. Installing test dependencies: add `--requirements` to ansible-test during normal calls. + +Running sanity checks: + +``` +ansible-test sanity --requirements --python 3.11 +``` + +unit tests: + +``` +ansible-test units --requirements --python 3.11 +``` +(if you get odd errors from pytest, don't forget --requirements) + +Both unit and sanity checks can work without secrets. + +# Integration tests + +To run integration tests you need to generate your own config at +`ansible_collections/serverscom/sc_api/tests/integration/integration_config.yml` +(this location is odd, but it's the single place where ansible-test permits any side +causes into test playbooks) + +See example in `integration_config.yml.template`. + +Please, pay attention, +you need at least 3 baremetal servers to run tests for baremetal modules. + +The main secret you get is SC_TOKEN, which is token to access servers.com API. + +At the time of writing you could get one from here: https://portal.servers.com/profile/api-tokens + +Please be careful, some tests will cause significant financial spendings. They also will reinstall baremetal servers, so you should dedicate servers for those testing exlusively. From 02f108848213ff866387f66455ce06a20fb52425 Mon Sep 17 00:00:00 2001 From: George Shuklin Date: Wed, 17 Jan 2024 15:35:37 +0200 Subject: [PATCH 09/10] fix: add collection install and update os_auth module use. --- .github/workflows/tests.yaml | 2 ++ .../tasks/main.yaml | 28 +++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index af42103..ef8bb18 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -102,6 +102,8 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt + - name: Install dependent collections + run: ansible-galaxy collection install openstack.cloud - name: Configure integration tests run: | envsubst < integration_config.yml.template > ansible_collections/serverscom/sc_api/tests/integration/integration_config.yml diff --git a/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_openstack_credentials/tasks/main.yaml b/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_openstack_credentials/tasks/main.yaml index f646d22..d3c19f6 100644 --- a/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_openstack_credentials/tasks/main.yaml +++ b/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_openstack_credentials/tasks/main.yaml @@ -2,13 +2,13 @@ - name: Check if there are sc_token and sc_endpoint variables no_log: true fail: - msg: 'You need to define sc_token and sc_endpoint variables in tests/integration/integration_config.yml' + msg: "You need to define sc_token and sc_endpoint variables in tests/integration/integration_config.yml" when: not sc_endpoint or not sc_token - name: Test invalid token sc_cloud_computing_openstack_credentials: token: invalid - endpoint: '{{ sc_endpoint }}' + endpoint: "{{ sc_endpoint }}" region_id: 424242 register: test1 failed_when: @@ -18,8 +18,8 @@ - name: Test2, List for non-existing region sc_cloud_computing_openstack_credentials: - token: '{{ sc_token }}' - endpoint: '{{ sc_endpoint }}' + token: "{{ sc_token }}" + endpoint: "{{ sc_endpoint }}" region_id: 424242 register: test2 failed_when: test2.status_code!=404 @@ -33,15 +33,15 @@ - name: Test3 prep, get regions sc_cloud_computing_regions_info: - token: '{{ sc_token }}' - endpoint: '{{ sc_endpoint }}' + token: "{{ sc_token }}" + endpoint: "{{ sc_endpoint }}" register: regions - name: Test3, Get creds for region1 sc_cloud_computing_openstack_credentials: - token: '{{ sc_token }}' - endpoint: '{{ sc_endpoint }}' - region_id: '{{ regions.regions[0].id }}' + token: "{{ sc_token }}" + endpoint: "{{ sc_endpoint }}" + region_id: "{{ regions.regions[0].id }}" register: creds - name: Check Test3 @@ -54,12 +54,12 @@ - creds.password - name: Validate creds - os_auth: + openstack.cloud.auth: auth: - auth_url: '{{ creds.url }}' - username: '{{ creds.username }}' - password: '{{ creds.password }}' - project_name: '{{ creds.tenant_name }}' + auth_url: "{{ creds.url }}" + username: "{{ creds.username }}" + password: "{{ creds.password }}" + project_name: "{{ creds.tenant_name }}" os_user_domain_name: default os_project_domain_name: default register: os From aea5d7f32abc58c88191fee12cb2a3073270cfa4 Mon Sep 17 00:00:00 2001 From: George Shuklin Date: Wed, 17 Jan 2024 16:58:07 +0200 Subject: [PATCH 10/10] test: remove auth test (problems wih openstack coolection in testtime) --- .github/workflows/tests.yaml | 2 -- .../tasks/main.yaml | 11 ----------- 2 files changed, 13 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ef8bb18..af42103 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -102,8 +102,6 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - - name: Install dependent collections - run: ansible-galaxy collection install openstack.cloud - name: Configure integration tests run: | envsubst < integration_config.yml.template > ansible_collections/serverscom/sc_api/tests/integration/integration_config.yml diff --git a/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_openstack_credentials/tasks/main.yaml b/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_openstack_credentials/tasks/main.yaml index d3c19f6..8130acb 100644 --- a/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_openstack_credentials/tasks/main.yaml +++ b/ansible_collections/serverscom/sc_api/tests/integration/targets/sc_cloud_computing_openstack_credentials/tasks/main.yaml @@ -52,14 +52,3 @@ - creds.tenant_name - creds.username - creds.password - -- name: Validate creds - openstack.cloud.auth: - auth: - auth_url: "{{ creds.url }}" - username: "{{ creds.username }}" - password: "{{ creds.password }}" - project_name: "{{ creds.tenant_name }}" - os_user_domain_name: default - os_project_domain_name: default - register: os