diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5c025cb..af42103 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: @@ -22,10 +23,7 @@ jobs: strategy: matrix: python_version: - - "3.8" - - "3.7" - - "3.6" - # - "3.10" + - "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 }} @@ -55,14 +52,13 @@ 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 - pip install flake8 pytest pip install -r requirements.txt - name: Configure integration tests run: | @@ -70,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 @@ -98,14 +94,13 @@ 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 - pip install flake8 pytest pip install -r requirements.txt - name: Configure integration tests run: | @@ -113,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 @@ -136,14 +131,13 @@ 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 - pip install flake8 pytest pip install -r requirements.txt - name: Configure integration tests run: | @@ -151,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 @@ -172,14 +166,13 @@ 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 - pip install flake8 pytest pip install -r requirements.txt - name: Remove tests from final distribution run: rm -r tests/ 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..75a0413 100644 --- a/ansible_collections/serverscom/sc_api/plugins/module_utils/modules.py +++ b/ansible_collections/serverscom/sc_api/plugins/module_utils/modules.py @@ -13,6 +13,7 @@ __metaclass__ = type +_ignored = DEFAULT_API_ENDPOINT # to silence pylint warning, it is reimported 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..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) @@ -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..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 = """ @@ -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..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 = """ @@ -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.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_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..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 @@ -280,7 +281,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..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. """ @@ -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..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 = """ @@ -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..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 @@ -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_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. 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, 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 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..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 @@ -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 @@ -52,14 +52,3 @@ - creds.tenant_name - creds.username - creds.password - -- name: Validate creds - os_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 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. diff --git a/requirements.txt b/requirements.txt index e2fa2d6..4206eae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -ansible==2.9.20 +ansible-core==2.16.2 wheel openstacksdk -jinja2<3.1 +flake8 +pytest