diff options
Diffstat (limited to 'collections-debian-merged/ansible_collections/cloudscale_ch')
83 files changed, 7018 insertions, 0 deletions
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/cleanup.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/cleanup.yml new file mode 100644 index 00000000..7cc98fdb --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/cleanup.yml @@ -0,0 +1,35 @@ +name: Scheduled Cleanup + +on: + schedule: + - cron: '0 2 * * *' # UTC + +jobs: + cleanup: + name: Cleanup possible leftovers + runs-on: ubuntu-latest + steps: + - name: Ensure no other integration test is currently running + uses: softprops/turnstyle@v0.1.3 + timeout-minutes: 60 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + same-branch-only: false + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + + - name: Run cleanup + run: | + pip install cloudscale-cli + for resource in objects-user server floating-ip server-group network; + do + echo "cleaning up $resource..."; + cloudscale $resource list --delete --force; + echo "...done"; + done + env: + CLOUDSCALE_API_TOKEN: ${{ secrets.CLOUDSCALE_API_TOKEN }} diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/publish-ansible-galaxy.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/publish-ansible-galaxy.yml new file mode 100644 index 00000000..7ab9a1d5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/publish-ansible-galaxy.yml @@ -0,0 +1,33 @@ +name: Publish release on Ansible Galaxy + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ansible_collections/cloudscale_ch/cloud + steps: + - uses: actions/checkout@v2 + with: + path: ansible_collections/cloudscale_ch/cloud + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ansible + + - name: Build and publish + env: + ANSIBLE_GALAXY_API_KEY: ${{ secrets.ANSIBLE_GALAXY_API_KEY }} + run: | + ansible-galaxy collection build . + ansible-galaxy collection publish *.tar.gz --api-key $ANSIBLE_GALAXY_API_KEY diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/test-integration.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/test-integration.yml new file mode 100644 index 00000000..7f0287b8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/test-integration.yml @@ -0,0 +1,105 @@ +name: Collection Integration tests + +on: + schedule: + - cron: '0 5 * * *' # UTC + +jobs: + integration-test: + name: Integration test using Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + defaults: + run: + working-directory: ansible_collections/cloudscale_ch/cloud + strategy: + fail-fast: false + max-parallel: 1 + matrix: + runner-python-version: + - 3.6 + python-version: + - 3.6 + - 2.7 + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + path: ansible_collections/cloudscale_ch/cloud + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install ansible and collection dependencies + run: | + python -m pip install --upgrade pip + pip install ansible + pip install -r tests/requirements.txt + + - name: Build and install collection + run: | + ansible-galaxy collection build . + ansible-galaxy collection install *.gz + + - name: Add config file + env: + CONFIG_FILE: ${{ secrets.CONFIG_FILE }} + INI_FILE: tests/integration/cloud-config-cloudscale.ini + run: | + echo -n "$CONFIG_FILE" > $INI_FILE && [ -s $INI_FILE ] || (>&2 echo no secrets provided; exit 1) + + - name: Ensure no other integration test is currently running + uses: softprops/turnstyle@v0.1.3 + timeout-minutes: 60 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + same-branch-only: false + + - name: Run the tests + run: >- + ansible-test + integration + --docker + -v + --diff + --color + --allow-unsupported + --continue-on-error + --coverage + cloud/cloudscale/ + + - name: Generate coverage report. + run: >- + ansible-test + coverage xml + -v + --requirements + --group-by command + --group-by version + + - uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: false + + - name: Send mail in case of failure + id: send_mail + if: ${{ failure() && github.event_name == 'schedule' }} + shell: python3 {0} + run: | + from smtplib import SMTP + from email.message import EmailMessage + + email = EmailMessage() + email['TO'] = '${{ secrets.CRON_RCPT }}' + email['FROM'] = 'noreply@github.com' + email['Subject'] = 'Ansible Cloud Module Integration Test Failure' + email.set_content(""" + Integration tests using Python ${{ matrix.python-version }} failed: + https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + """) + + with SMTP('${{ secrets.MAILSERVER }}') as smtp: + smtp.starttls() + smtp.send_message(email) diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/test-sanity.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/test-sanity.yml new file mode 100644 index 00000000..70edf787 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.github/workflows/test-sanity.yml @@ -0,0 +1,34 @@ +name: Sanity tests + +on: +- pull_request + +jobs: + sanity: + name: Sanity tests (${{ matrix.ansible }}) + defaults: + run: + working-directory: ansible_collections/cloudscale_ch/cloud + strategy: + matrix: + ansible: + - stable-2.10 + - stable-2.9 + - devel + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + path: ansible_collections/cloudscale_ch/cloud + + - name: Set up Python 3 + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install ansible-base (${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + - name: Run sanity tests + run: ansible-test sanity --docker -v --color diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.gitignore b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.gitignore new file mode 100644 index 00000000..dadcc76e --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/.gitignore @@ -0,0 +1,4 @@ +*.pyc +*.tar.gz +tests/integration/cloud-config-cloudscale.ini +tests/output/ diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/CHANGELOG.rst b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/CHANGELOG.rst new file mode 100644 index 00000000..8b350cfb --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/CHANGELOG.rst @@ -0,0 +1,60 @@ +============================================== +Ansible Collection cloudscale.ch Release Notes +============================================== + +.. contents:: Topics + + +v1.3.1 +====== + +Minor Changes +------------- + +- Implemented identical naming support of the same resource type per zone (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/46). + +Bugfixes +-------- + +- Fix inventory plugin failing to launch (https://github.com/cloudscale-ch/ansible-collection-cloudscale/issues/49). + +v1.3.0 +====== + +Minor Changes +------------- + +- floating_ip - Added an optional name parameter to gain idempotency. The parameter will be required for assigning a new floating IP with release of version 2.0.0 (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/43/). +- floating_ip - Allow to reserve an IP without assignment to a server (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/31/). + +New Modules +----------- + +- subnet - Manages subnets on the cloudscale.ch IaaS service + +v1.2.0 +====== + +Minor Changes +------------- + +- server_group - The module has been refactored and the code simplifed (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/23). +- volume - The module has been refactored and the code simplifed (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/24). + +New Modules +----------- + +- network - Manages networks on the cloudscale.ch IaaS service + +v1.1.0 +====== + +Minor Changes +------------- + +- floating_ip - added tags support (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/16) + +New Modules +----------- + +- objects_user - Manages objects users on the cloudscale.ch IaaS service diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/CONTRIBUTING.md b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/CONTRIBUTING.md new file mode 100644 index 00000000..44683c13 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/CONTRIBUTING.md @@ -0,0 +1,6 @@ +# Contributing + +Any contribution is welcome and we only ask contributors to: + +- Create an issues for any significant contribution that would change a large portion of the code base. +- Provide at least integration tests for any contribution diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/COPYING b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/COPYING new file mode 100644 index 00000000..94a04532 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/COPYING @@ -0,0 +1,621 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/FILES.json b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/FILES.json new file mode 100644 index 00000000..0561d128 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/FILES.json @@ -0,0 +1,859 @@ +{ + "files": [ + { + "name": ".", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/workflows", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/workflows/test-integration.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a1d1cca14414dbab929cd7ae08dd8e8b06932b9a2f16db4eefd4b0e8278b4576", + "format": 1 + }, + { + "name": ".github/workflows/publish-ansible-galaxy.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "61882ec43666c8df4fdc7cfa176195339a861705739c0c923f5a3ab5e0434c82", + "format": 1 + }, + { + "name": ".github/workflows/test-sanity.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a66554b94f5b72b1c49f7530e68549bec0e35a3aa6a26692522a7732627c87dc", + "format": 1 + }, + { + "name": ".github/workflows/cleanup.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e4504033bb3a7421a4dbb619e17b76949a0b2107901f696774b2675d461aa94e", + "format": 1 + }, + { + "name": "meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "meta/runtime.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "932ab1d19eba7c0d158a6d527f333eeaeab0f161fb5812f5347af1fdea100996", + "format": 1 + }, + { + "name": "codecov.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "af6b28485318d71eee003780eb62183364d82f1a50917cdcaaa4ffb88a178d51", + "format": 1 + }, + { + "name": "changelogs", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "changelogs/.gitignore", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "919ef00776e7d2ff349950ac4b806132aa9faf006e214d5285de54533e443b33", + "format": 1 + }, + { + "name": "changelogs/fragments", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "changelogs/fragments/.keep", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "changelogs/config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "281f8e67542260c31e3da2659c50236ce74c2c727487179bc751fb568c49e56e", + "format": 1 + }, + { + "name": "changelogs/changelog.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f4f2b3871189701db8ef61fa9e8da938bc84ac2c57562c995a5d082a0c387167", + "format": 1 + }, + { + "name": ".gitignore", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4da3851108cf118d70fb2d8d5bdd4052043ab824fd34d83932212ff433c44731", + "format": 1 + }, + { + "name": "plugins", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/modules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/modules/volume.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "12d5a560775be89393e156625235f17d45edd5afb9afb53a6ed70bc04f37c827", + "format": 1 + }, + { + "name": "plugins/modules/server.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bd70b45f26009ec3ef1fb677f733973430167f45b952b7cba92e0d39d1ff6aa6", + "format": 1 + }, + { + "name": "plugins/modules/subnet.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5b2cb880ae29727265abf4a3908ed1fd4b70f172e3a04ee94940de3e6ab9d800", + "format": 1 + }, + { + "name": "plugins/modules/floating_ip.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5b0fbc66d2744c9e11cd54da02919ffff44e01ab627692935898e25cc4760cc4", + "format": 1 + }, + { + "name": "plugins/modules/objects_user.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "80b229b178c43aa1a62bcf2cad4b76486f059fc87a206a02a6cc613b953cfb8d", + "format": 1 + }, + { + "name": "plugins/modules/network.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1b54189ffc76806e313a3a9e3ac30ea37a918b1f362fbb977f4c5b6f18b04ace", + "format": 1 + }, + { + "name": "plugins/modules/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/modules/server_group.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "29ec16366d6c80aa04f0d282a185317dc67a52a27897594d669486677f7e0174", + "format": 1 + }, + { + "name": "plugins/doc_fragments", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/doc_fragments/api_parameters.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f387be1c4cb6fba1f5306ebe8f715e7023154501b42de21c025858a2ad51e04d", + "format": 1 + }, + { + "name": "plugins/doc_fragments/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/api.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fd36088e4a6da9f4bc1255d915357980a9b4420ea005fb7d3f2ea119b024501c", + "format": 1 + }, + { + "name": "plugins/inventory", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/inventory/inventory.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3b96426c36873306b761c3147b7bef24cd2c01bcd3f83b6c8e3a8a1ee51e6cb7", + "format": 1 + }, + { + "name": "plugins/inventory/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "COPYING", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c61f12da7cdad526bdcbed47a4c0a603e60dbbfdaf8b66933cd088e9132c303f", + "format": 1 + }, + { + "name": "CHANGELOG.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d567e6613124f33c69ac1a82e22168326728d3184c4dffc38367f106d931fdd5", + "format": 1 + }, + { + "name": "CONTRIBUTING.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d61725d614410e2ee0a900fb0f6b6d742ad8fb689ae27c4d6a3a7f89e82fc791", + "format": 1 + }, + { + "name": "tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/cloud-config-cloudscale.ini.template", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b442f74e11fdcdc779e16b3bf0a9f359b04b13b7d5c17175ff12d4b93eeb0b63", + "format": 1 + }, + { + "name": "tests/integration/targets", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/floating_ip", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/floating_ip/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/floating_ip/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fad8168157b59ea211367da3adec3c025885b88e940a43fbdd8c5b9a8f06a791", + "format": 1 + }, + { + "name": "tests/integration/targets/floating_ip/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/floating_ip/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "abef9fb35842fcce0d51933baa7e61ca1709b776f10734031251307de5638f85", + "format": 1 + }, + { + "name": "tests/integration/targets/floating_ip/tasks/deprecation_warning.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3c64ca13bf8965781ad97b1903c6249272a482fbc739a2b32375cb1c96222c67", + "format": 1 + }, + { + "name": "tests/integration/targets/floating_ip/tasks/unassigned.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fd49224daf8665d9980a0041ac445c0402da2718fee85842cd7bf43369c9cfc0", + "format": 1 + }, + { + "name": "tests/integration/targets/floating_ip/tasks/floating_ip.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "402b982a02df802093aee7979fcefc37506a388805b0c791e866737726e165db", + "format": 1 + }, + { + "name": "tests/integration/targets/floating_ip/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "14732eb4e328df90778a7512eaba85e7ba941032a1cfb85c81a915eba15eaa4a", + "format": 1 + }, + { + "name": "tests/integration/targets/subnet", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/subnet/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/subnet/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fad8168157b59ea211367da3adec3c025885b88e940a43fbdd8c5b9a8f06a791", + "format": 1 + }, + { + "name": "tests/integration/targets/subnet/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/subnet/defaults/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7c6f0d3942e38ede79365f096d78892a420172d300f5fea0f79f8f36767d06d0", + "format": 1 + }, + { + "name": "tests/integration/targets/subnet/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/subnet/tasks/setup.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2d52e7e9120b1accdd689734b41e8bc34ecd81f74775c3a800f35d36c07ca63d", + "format": 1 + }, + { + "name": "tests/integration/targets/subnet/tasks/tests.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2d8107e1bdb7deab792785788e8745b42588f71783cafcc2ce1a32d35c1c27ef", + "format": 1 + }, + { + "name": "tests/integration/targets/subnet/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "eddcaa01aabe22df954c1c352a81f8456de8476be5e8aa3ec229e4a0698b19ec", + "format": 1 + }, + { + "name": "tests/integration/targets/subnet/tasks/failures.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "60128cb6423e9f2b21ba9e05cc670325b99d3b6fbbb807d3d4474e100c7c377a", + "format": 1 + }, + { + "name": "tests/integration/targets/subnet/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "14732eb4e328df90778a7512eaba85e7ba941032a1cfb85c81a915eba15eaa4a", + "format": 1 + }, + { + "name": "tests/integration/targets/common", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/common/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/common/defaults/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e1b93612d2cac0203a563bc76043c8764a22b49520d68b637ee3cfc6def79bb6", + "format": 1 + }, + { + "name": "tests/integration/targets/common/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/common/tasks/cleanup_servers.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "58ea8194da127df1082eb88523f6b713d3d3e323a62279ed52a1e0e96efc6bf7", + "format": 1 + }, + { + "name": "tests/integration/targets/common/tasks/cleanup_floating_ips.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bab4ca163d566a13f9abacdf179f59fc186ca160c777937fc7eb76616993c7f3", + "format": 1 + }, + { + "name": "tests/integration/targets/common/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3f4342705d85638595cc3dd584302e9c860bd83d383653c3d9fe283ee98fcf19", + "format": 1 + }, + { + "name": "tests/integration/targets/common/tasks/cleanup_server_groups.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d92489602b40f14f4f3156a04b2a39841f01a3296b837365fd9887e25b84e3b8", + "format": 1 + }, + { + "name": "tests/integration/targets/common/tasks/cleanup_volumes.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fb224f8cf56d2a24e81c14bf3b8974577d1d9aab78cb8c100fdc552055113c9c", + "format": 1 + }, + { + "name": "tests/integration/targets/common/tasks/cleanup_networks.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "76183d1bd899652a5c8deea41b0f27ad64cd268ce3e7a8a69314c7193c677be8", + "format": 1 + }, + { + "name": "tests/integration/targets/common/tasks/cleanup_objects_users.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "52891380666cf92aeb5d8797cc3e5b0567772e2641714a775a05ccb2279d2a98", + "format": 1 + }, + { + "name": "tests/integration/targets/common/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e084a3683ef795d1cdbf5e9b253f2ca1f783ae0d0d6e47e419acbbc4fc80bbfa", + "format": 1 + }, + { + "name": "tests/integration/targets/server_group", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/server_group/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/server_group/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fad8168157b59ea211367da3adec3c025885b88e940a43fbdd8c5b9a8f06a791", + "format": 1 + }, + { + "name": "tests/integration/targets/server_group/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/server_group/tasks/tests.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f41b4068697edfbb80ffa3e1e171b82e016a72b17efc299c77283fe88f774124", + "format": 1 + }, + { + "name": "tests/integration/targets/server_group/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27d4b996ea78fddc8152d8dc5f2a87461ec8972baecb9a494b384c0f163b9bc3", + "format": 1 + }, + { + "name": "tests/integration/targets/server_group/tasks/failures.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "24758d9aae6a825817c2bdfe3314a557264ef5c640ae784b4e26fd07d2e677dc", + "format": 1 + }, + { + "name": "tests/integration/targets/server_group/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "14732eb4e328df90778a7512eaba85e7ba941032a1cfb85c81a915eba15eaa4a", + "format": 1 + }, + { + "name": "tests/integration/targets/network", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/network/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/network/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fad8168157b59ea211367da3adec3c025885b88e940a43fbdd8c5b9a8f06a791", + "format": 1 + }, + { + "name": "tests/integration/targets/network/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/network/tasks/tests.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "da1e8e05fe4586478da692ee2f38b07b8691dafeea6d46f770f58b51260df7b0", + "format": 1 + }, + { + "name": "tests/integration/targets/network/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "be793a4af2cbb5f5398e0ba3fae822b4a6f76be183f69163f679cf6ca888ff3f", + "format": 1 + }, + { + "name": "tests/integration/targets/network/tasks/failures.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6a8e9848f5767e67ce778eca1bdd5044403bccd43586143644d5a6e678f826fb", + "format": 1 + }, + { + "name": "tests/integration/targets/network/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "14732eb4e328df90778a7512eaba85e7ba941032a1cfb85c81a915eba15eaa4a", + "format": 1 + }, + { + "name": "tests/integration/targets/volume", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/volume/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/volume/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fad8168157b59ea211367da3adec3c025885b88e940a43fbdd8c5b9a8f06a791", + "format": 1 + }, + { + "name": "tests/integration/targets/volume/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/volume/tasks/setup.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "06dc76815335258a146c94e35ecb7fc9039b5a0c9c472de75a24ab09451de5af", + "format": 1 + }, + { + "name": "tests/integration/targets/volume/tasks/tests.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "280d8e123778c4e64834f63728f8519f6625d3b849dbfca50e05298dbd28390a", + "format": 1 + }, + { + "name": "tests/integration/targets/volume/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3ef62124a45cde559e774fe901da89ea4b0c7a7ba1ba4a2c302e12261f501ef4", + "format": 1 + }, + { + "name": "tests/integration/targets/volume/tasks/failures.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "da1f31d57f5785e0866673baae9e2f1e1672efd5c423c5da541176cb7953c116", + "format": 1 + }, + { + "name": "tests/integration/targets/volume/tasks/cleanup.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2626113d52c4f1113b41e75af461ad16f779271aee0b01c7600f4f3b8c753a50", + "format": 1 + }, + { + "name": "tests/integration/targets/volume/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "14732eb4e328df90778a7512eaba85e7ba941032a1cfb85c81a915eba15eaa4a", + "format": 1 + }, + { + "name": "tests/integration/targets/objects_user", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/objects_user/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/objects_user/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fad8168157b59ea211367da3adec3c025885b88e940a43fbdd8c5b9a8f06a791", + "format": 1 + }, + { + "name": "tests/integration/targets/objects_user/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/objects_user/tasks/tests.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0e3142fac71c2169fa650af4216cf5d69eef1d80bfe020fbe74549d997d8e1c3", + "format": 1 + }, + { + "name": "tests/integration/targets/objects_user/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "46e001acebb586b961302c5e8876eab0fe2a2c136b7f026da04014df64b30acb", + "format": 1 + }, + { + "name": "tests/integration/targets/objects_user/tasks/failures.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f522a4d67cfc9d074d2e2e9f1a6d0aa274e87712fddb00905ea9262f39f472f3", + "format": 1 + }, + { + "name": "tests/integration/targets/objects_user/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "14732eb4e328df90778a7512eaba85e7ba941032a1cfb85c81a915eba15eaa4a", + "format": 1 + }, + { + "name": "tests/integration/targets/server", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/server/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/server/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fad8168157b59ea211367da3adec3c025885b88e940a43fbdd8c5b9a8f06a791", + "format": 1 + }, + { + "name": "tests/integration/targets/server/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/server/defaults/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "602bbad94a3cf5abaad3e39d229f6dd448cee611c15ad46c1b482556056541c9", + "format": 1 + }, + { + "name": "tests/integration/targets/server/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/server/tasks/tests.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a34ad00f158d4c44b085823f835914367682b78a64afe4ac9eb7bf24b2e9ea75", + "format": 1 + }, + { + "name": "tests/integration/targets/server/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5e86ff7e00c6b3ac11b54f70870e130108df046d22350483c690cd7b851808d3", + "format": 1 + }, + { + "name": "tests/integration/targets/server/tasks/failures.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "39075af57f8eba3ce7f50067dc89259ab4e5391411ebccde06383f54307f8800", + "format": 1 + }, + { + "name": "tests/integration/targets/server/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "14732eb4e328df90778a7512eaba85e7ba941032a1cfb85c81a915eba15eaa4a", + "format": 1 + }, + { + "name": "tests/requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1a5a2e4665194900a0d24968456298eaac531c0b10a3fac4f10be5c58047c0e1", + "format": 1 + }, + { + "name": "tests/sanity", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/sanity/ignore-2.10.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "483ff368a5a08f3a48e1d5705a2b232c55543c39b386a3020cd3af717483692d", + "format": 1 + } + ], + "format": 1 +}
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/MANIFEST.json b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/MANIFEST.json new file mode 100644 index 00000000..3310149a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/MANIFEST.json @@ -0,0 +1,36 @@ +{ + "collection_info": { + "namespace": "cloudscale_ch", + "name": "cloud", + "version": "1.3.1", + "authors": [ + "Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch>", + "Denis Krienb\u00fchl <denis.krienbuehl@cloudscale.ch>", + "Ren\u00e9 Moser <mail@renemoser.net>" + ], + "readme": "README.md", + "tags": [ + "cloud", + "cloudscale", + "cloudscale_ch" + ], + "description": "Ansible Collection for cloudscale.ch", + "license": [ + "GPL-3.0-or-later" + ], + "license_file": null, + "dependencies": {}, + "repository": "https://github.com/cloudscale-ch/ansible-collection-cloudscale", + "documentation": "", + "homepage": "https://github.com/cloudscale-ch/ansible-collection-cloudscale", + "issues": "https://github.com/cloudscale-ch/ansible-collection-cloudscale/issues" + }, + "file_manifest_file": { + "name": "FILES.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13e898d39e7ad4036fabdad8453d8193d40981affc58a92386db42c2a92c66a0", + "format": 1 + }, + "format": 1 +}
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/README.md b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/README.md new file mode 100644 index 00000000..ae77b83b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/README.md @@ -0,0 +1,93 @@ + +![Collection Integration tests](https://github.com/cloudscale-ch/ansible-collection-cloudscale/workflows/Collection%20Integration%20tests/badge.svg) +[![Codecov](https://img.shields.io/codecov/c/github/cloudscale-ch/ansible-collection-cloudscale)](https://codecov.io/gh/cloudscale-ch/ansible-collection-cloudscale) +[![License](https://img.shields.io/badge/license-GPL%20v3.0-brightgreen.svg)](LICENSE) + +# Ansible Collection for cloudscale.ch Cloud + +This collection provides a series of Ansible modules and plugins for interacting with the [cloudscale.ch](https://www.cloudscale.ch) Cloud. + +## Requirements + +- ansible version >= 2.9 + +## Installation + +To install the collection hosted in Galaxy: + +```bash +ansible-galaxy collection install cloudscale_ch.cloud +``` + +To upgrade to the latest version of the collection: + +```bash +ansible-galaxy collection install cloudscale_ch.cloud --force +``` + +## Usage + +### Playbooks + +To use a module from cloudscale.ch collection, please reference the full namespace, collection name, and modules name that you want to use: + +```yaml +--- +- name: Using cloudscale.ch collection + hosts: localhost + tasks: + - cloudscale_ch.cloud.server: + name: web1 + image: debian-10 + flavor: flex-2 + ssh_keys: ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale + server_groups: web-group + zone: lpg1 + api_token: ... +``` + +Or you can add full namepsace and collection name in the `collections` element: + +```yaml +--- +- name: Using cloudscale.ch collection + hosts: localhost + collections: + - cloudscale_ch.cloud + tasks: + - server: + name: web1 + image: debian-10 + flavor: flex-2 + ssh_keys: ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale + server_groups: web-group + zone: lpg1 + api_token: ... +``` + +### Roles + +For existing Ansible roles, please also reference the full namespace, collection name, and modules name which used in tasks instead of just modules name. + +### Plugins + +To use a pluign, please reference the full namespace, collection name, and plugins name that you want to use: + +```yaml +plugin: cloudscale_ch.cloud.<myplugin> +``` + +## Contributing + +There are many ways in which you can participate in the project, for example: + +- Submit bugs and feature requests, and help us verify as they are checked in +- Review source code changes +- Review the documentation and make pull requests for anything from typos to new content +- If you are interested in fixing issues and contributing directly to the code base, please see the [CONTRIBUTING](CONTRIBUTING.md) document. + +## License + +GNU General Public License v3.0 + +See [COPYING](COPYING) to see the full text. diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/.gitignore b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/.gitignore new file mode 100644 index 00000000..6be6b533 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/.gitignore @@ -0,0 +1 @@ +/.plugin-cache.yaml diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/changelog.yaml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/changelog.yaml new file mode 100644 index 00000000..79b6e758 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/changelog.yaml @@ -0,0 +1,50 @@ +ancestor: null +releases: + 1.1.0: + changes: + minor_changes: + - floating_ip - added tags support (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/16) + fragments: + - 16-floating_ip_tags.yml + modules: + - description: Manages objects users on the cloudscale.ch IaaS service + name: objects_user + namespace: '' + release_date: '2020-08-18' + 1.2.0: + changes: + minor_changes: + - server_group - The module has been refactored and the code simplifed (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/23). + - volume - The module has been refactored and the code simplifed (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/24). + fragments: + - consolidate-modules.yml + modules: + - description: Manages networks on the cloudscale.ch IaaS service + name: network + namespace: '' + release_date: '2020-10-13' + 1.3.0: + changes: + minor_changes: + - floating_ip - Added an optional name parameter to gain idempotency. The parameter + will be required for assigning a new floating IP with release of version 2.0.0 + (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/43/). + - floating_ip - Allow to reserve an IP without assignment to a server (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/31/). + fragments: + - floating-idempotency.yml + - floating-ip_optional_server.yml + modules: + - description: Manages subnets on the cloudscale.ch IaaS service + name: subnet + namespace: '' + release_date: '2020-11-23' + 1.3.1: + changes: + bugfixes: + - Fix inventory plugin failing to launch (https://github.com/cloudscale-ch/ansible-collection-cloudscale/issues/49). + minor_changes: + - Implemented identical naming support of the same resource type per zone (https://github.com/cloudscale-ch/ansible-collection-cloudscale/pull/46). + fragments: + - allow-similar-name-per-zone.yml + - fix-inventory-plugin-error.yml + release_date: '2021-01-26' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/config.yaml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/config.yaml new file mode 100644 index 00000000..151cdf32 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/config.yaml @@ -0,0 +1,29 @@ +changelog_filename_template: ../CHANGELOG.rst +changelog_filename_version_depth: 0 +changes_file: changelog.yaml +changes_format: combined +keep_fragments: false +mention_ancestor: true +new_plugins_after_name: removed_features +notesdir: fragments +prelude_section_name: release_summary +prelude_section_title: Release Summary +sections: +- - major_changes + - Major Changes +- - minor_changes + - Minor Changes +- - breaking_changes + - Breaking Changes / Porting Guide +- - deprecated_features + - Deprecated Features +- - removed_features + - Removed Features (previously deprecated) +- - security_fixes + - Security Fixes +- - bugfixes + - Bugfixes +- - known_issues + - Known Issues +title: Ansible Collection cloudscale.ch +trivial_section_name: trivial diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/fragments/.keep b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/fragments/.keep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/changelogs/fragments/.keep diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/codecov.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/codecov.yml new file mode 100644 index 00000000..47fe4ef2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/codecov.yml @@ -0,0 +1,8 @@ +--- +coverage: + precision: 2 + round: down + range: "70...100" + +fixes: + - "/ansible_collections/cloudscale_ch/cloud/::" diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/meta/runtime.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/meta/runtime.yml new file mode 100644 index 00000000..5751eb86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/meta/runtime.yml @@ -0,0 +1,51 @@ +requires_ansible: '>=2.9.10' +action_groups: + cloudscale: + - floating_ip + - network + - objects_user + - server_group + - server + - subnet + - volume + +plugin_routing: + inventory: + cloudscale: + deprecation: + removal_date: 2021-12-12 + warning_text: Deprecated, use cloudscale_ch.cloud.inventory + redirect: cloudscale_ch.cloud.inventory + doc_fragments: + cloudscale: + deprecation: + removal_date: 2021-12-12 + warning_text: Deprecated, use cloudscale_ch.cloud.api_parameters + redirect: cloudscale_ch.cloud.api_parameters + module_utils: + cloudscale: + deprecation: + removal_date: 2021-12-12 + warning_text: Deprecated, use cloudscale_ch.cloud.api + redirect: cloudscale_ch.cloud.api + modules: + cloudscale_floating_ip: + deprecation: + removal_date: 2021-12-12 + warning_text: cloudscale_ prefixed module names are deprecated, use cloudscale_ch.cloud.floating_ip + redirect: cloudscale_ch.cloud.floating_ip + cloudscale_server: + deprecation: + removal_date: 2021-12-12 + warning_text: cloudscale_ prefixed module names are deprecated, use cloudscale_ch.cloud.server + redirect: cloudscale_ch.cloud.server + cloudscale_server_group: + deprecation: + removal_date: 2021-12-12 + warning_text: cloudscale_ prefixed module names are deprecated, use cloudscale_ch.cloud.server_group + redirect: cloudscale_ch.cloud.server_group + cloudscale_volume: + deprecation: + removal_date: 2021-12-12 + warning_text: cloudscale_ prefixed module names are deprecated, use cloudscale_ch.cloud.volume + redirect: cloudscale_ch.cloud.volume diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/doc_fragments/__init__.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/doc_fragments/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/doc_fragments/__init__.py diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/doc_fragments/api_parameters.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/doc_fragments/api_parameters.py new file mode 100644 index 00000000..befa1c03 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/doc_fragments/api_parameters.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +class ModuleDocFragment(object): + + DOCUMENTATION = ''' +options: + api_url: + description: + - cloudscale.ch API URL. + - This can also be passed in the C(CLOUDSCALE_API_URL) environment variable. + default: https://api.cloudscale.ch/v1 + type: str + version_added: 1.3.0 + api_token: + description: + - cloudscale.ch API token. + - This can also be passed in the C(CLOUDSCALE_API_TOKEN) environment variable. + required: true + type: str + api_timeout: + description: + - Timeout in seconds for calls to the cloudscale.ch API. + default: 30 + type: int +notes: + - All operations are performed using the cloudscale.ch public API v1. + - "For details consult the full API documentation: U(https://www.cloudscale.ch/en/api/v1)." + - A valid API token is required for all operations. You can create as many tokens as you like using the cloudscale.ch control panel at + U(https://control.cloudscale.ch). +''' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/inventory/__init__.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/inventory/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/inventory/__init__.py diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/inventory/inventory.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/inventory/inventory.py new file mode 100644 index 00000000..4cc73466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/inventory/inventory.py @@ -0,0 +1,217 @@ +# -*- coding: utf-8 -*- +# +# Copyright: (c) 2018, Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' +--- +name: inventory +plugin_type: inventory +author: + - Gaudenz Steinlin (@gaudenz) +short_description: cloudscale.ch inventory source +description: + - Get inventory hosts from cloudscale.ch API + - Uses an YAML configuration file ending with either I(cloudscale.yml) or I(cloudscale.yaml) to set parameter values (also see examples). +extends_documentation_fragment: + - constructed +options: + api_token: + description: + - cloudscale.ch API token. + - This can also be passed in the C(CLOUDSCALE_API_TOKEN) environment variable. + type: str + plugin: + description: | + Token that ensures this is a source file for the 'cloudscale' + plugin. + required: True + choices: ['cloudscale'] + inventory_hostname: + description: | + What to register as the inventory hostname. + If set to 'uuid' the uuid of the server will be used and a + group will be created for the server name. + If set to 'name' the name of the server will be used unless + there are more than one server with the same name in which + case the 'uuid' logic will be used. + type: str + choices: + - name + - uuid + default: "name" + ansible_host: + description: | + Which IP address to register as the ansible_host. If the + requested value does not exist or this is set to 'none', no + ansible_host will be set. + type: str + choices: + - public_v4 + - public_v6 + - private + - none + default: public_v4 +''' + +EXAMPLES = r''' +# cloudscale.yml name ending file in YAML format +# Example command line: ansible-inventory --list -i inventory_cloudscale.yml + +plugin: cloudscale_ch.cloud.inventory + +# Example grouping by tag key "project" +plugin: cloudscale_ch.cloud.inventory +keyed_groups: + - prefix: project + key: cloudscale.tags.project + +# Example grouping by key "operating_system" lowercased and prefixed with "os" +plugin: cloudscale_ch.cloud.inventory +keyed_groups: + - prefix: os + key: cloudscale.image.operating_system | lower +''' +import os + +from collections import defaultdict +from json import loads + +from ansible.errors import AnsibleError +from ansible.module_utils.urls import open_url +from ansible.inventory.group import to_safe_group_name +from ansible.plugins.inventory import BaseInventoryPlugin, Constructable + +iface_type_map = { + 'public_v4': ('public', 4), + 'public_v6': ('public', 6), + 'private': ('private', 4), + 'none': (None, None), +} + + +class InventoryModule(BaseInventoryPlugin, Constructable): + + NAME = 'cloudscale' + + @property + def api_url(self): + return os.environ.get( + 'CLOUDSCALE_API_URL', 'https://api.cloudscale.ch/v1') + + @property + def api_token(self): + return self.get_option('api_token') \ + or os.environ.get('CLOUDSCALE_API_TOKEN') + + def _get_server_list(self): + + # Get list of servers from cloudscale.ch API + response = open_url( + self.api_url + '/servers', + headers={'Authorization': 'Bearer %s' % self.api_token} + ) + return loads(response.read()) + + def verify_file(self, path): + ''' + :param path: the path to the inventory config file + :return the contents of the config file + ''' + if super(InventoryModule, self).verify_file(path): + if path.endswith(('cloudscale.yml', 'cloudscale.yaml')): + return True + self.display.debug( + "cloudscale inventory filename must end with 'cloudscale.yml' or 'cloudscale.yaml'" + ) + return False + + def parse(self, inventory, loader, path, cache=True): + super(InventoryModule, self).parse(inventory, loader, path) + + self._read_config_data(path) + + if not self.api_token: + raise AnsibleError('Could not find an API token. Set the ' + 'CLOUDSCALE_API_TOKEN environment variable.') + + inventory_hostname = self.get_option('inventory_hostname') + if inventory_hostname not in ('name', 'uuid'): + raise AnsibleError('Invalid value for option inventory_hostname: %s' + % inventory_hostname) + + ansible_host = self.get_option('ansible_host') + if ansible_host not in iface_type_map: + raise AnsibleError('Invalid value for option ansible_host: %s' + % ansible_host) + + # Merge servers with the same name + firstpass = defaultdict(list) + for server in self._get_server_list(): + firstpass[server['name']].append(server) + + # Add servers to inventory + for name, servers in firstpass.items(): + if len(servers) == 1 and inventory_hostname == 'name': + self.inventory.add_host(name) + servers[0]['inventory_hostname'] = name + else: + # Two servers with the same name exist, create a group + # with this name and add the servers by UUID + group_name = to_safe_group_name(name) + if group_name not in self.inventory.groups: + self.inventory.add_group(group_name) + for server in servers: + self.inventory.add_host(server['uuid'], group_name) + server['inventory_hostname'] = server['uuid'] + + # Set variables + iface_type, iface_version = iface_type_map[ansible_host] + for server in servers: + hostname = server.pop('inventory_hostname') + if ansible_host != 'none': + addresses = [address['address'] + for interface in server['interfaces'] + for address in interface['addresses'] + if interface['type'] == iface_type + and address['version'] == iface_version] + + if len(addresses) > 0: + self.inventory.set_variable( + hostname, + 'ansible_host', + addresses[0], + ) + self.inventory.set_variable( + hostname, + 'cloudscale', + server, + ) + + variables = self.inventory.hosts[hostname].get_vars() + # Set composed variables + self._set_composite_vars( + self.get_option('compose'), + variables, + hostname, + self.get_option('strict'), + ) + + # Add host to composed groups + self._add_host_to_composed_groups( + self.get_option('groups'), + variables, + hostname, + self.get_option('strict'), + ) + + # Add host to keyed groups + self._add_host_to_keyed_groups( + self.get_option('keyed_groups'), + variables, + hostname, + self.get_option('strict'), + ) diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/module_utils/api.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/module_utils/api.py new file mode 100644 index 00000000..c3082d63 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/module_utils/api.py @@ -0,0 +1,354 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2017, Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch> +# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from copy import deepcopy +from ansible.module_utils.basic import env_fallback +from ansible.module_utils.urls import fetch_url +from ansible.module_utils._text import to_text + + +def cloudscale_argument_spec(): + return dict( + api_url=dict( + type='str', + fallback=(env_fallback, ['CLOUDSCALE_API_URL']), + default='https://api.cloudscale.ch/v1', + ), + api_token=dict( + type='str', + fallback=(env_fallback, ['CLOUDSCALE_API_TOKEN']), + no_log=True, + required=True, + ), + api_timeout=dict( + type='int', + default=30, + ), + ) + + +class AnsibleCloudscaleApi(object): + + def __init__(self, module): + self._module = module + + self._api_url = module.params['api_url'] + if not self._api_url.endswith('/'): + self._api_url = self._api_url + '/' + + self._auth_header = {'Authorization': 'Bearer %s' % module.params['api_token']} + + def _get(self, api_call): + resp, info = fetch_url(self._module, self._api_url + api_call, + headers=self._auth_header, + timeout=self._module.params['api_timeout']) + + if info['status'] == 200: + return self._module.from_json(to_text(resp.read(), errors='surrogate_or_strict')) + elif info['status'] == 404: + return None + else: + self._module.fail_json(msg='Failure while calling the cloudscale.ch API with GET for ' + '"%s".' % api_call, fetch_url_info=info) + + def _post_or_patch(self, api_call, method, data, filter_none=True): + # This helps with tags when we have the full API resource href to update. + if self._api_url not in api_call: + api_endpoint = self._api_url + api_call + else: + api_endpoint = api_call + + headers = self._auth_header.copy() + if data is not None: + # Sanitize data dictionary + # Deepcopy: Duplicate the data object for iteration, because + # iterating an object and changing it at the same time is insecure + for k, v in deepcopy(data).items(): + if filter_none and v is None: + del data[k] + + data = self._module.jsonify(data) + headers['Content-type'] = 'application/json' + + resp, info = fetch_url(self._module, + api_endpoint, + headers=headers, + method=method, + data=data, + timeout=self._module.params['api_timeout']) + + if info['status'] in (200, 201): + return self._module.from_json(to_text(resp.read(), errors='surrogate_or_strict')) + elif info['status'] == 204: + return None + else: + self._module.fail_json(msg='Failure while calling the cloudscale.ch API with %s for ' + '"%s".' % (method, api_endpoint), fetch_url_info=info) + + def _post(self, api_call, data=None): + return self._post_or_patch(api_call, 'POST', data) + + def _patch(self, api_call, data=None, filter_none=True): + return self._post_or_patch(api_call, 'PATCH', data, filter_none) + + def _delete(self, api_call): + # api_call might be full href already + if self._api_url not in api_call: + api_endpoint = self._api_url + api_call + else: + api_endpoint = api_call + + resp, info = fetch_url(self._module, + api_endpoint, + headers=self._auth_header, + method='DELETE', + timeout=self._module.params['api_timeout']) + + if info['status'] == 204: + return None + else: + self._module.fail_json(msg='Failure while calling the cloudscale.ch API with DELETE for ' + '"%s".' % api_endpoint, fetch_url_info=info) + + +class AnsibleCloudscaleBase(AnsibleCloudscaleApi): + + def __init__( + self, + module, + resource_name='', + resource_key_uuid='uuid', + resource_key_name='name', + resource_create_param_keys=None, + resource_update_param_keys=None, + ): + super(AnsibleCloudscaleBase, self).__init__(module) + self._result = { + 'changed': False, + 'diff': dict( + before=dict(), + after=dict() + ), + } + self._resource_data = dict() + + # The identifier key of the resource, usually 'uuid' + self.resource_key_uuid = resource_key_uuid + + # The name key of the resource, usually 'name' + self.resource_key_name = resource_key_name + + # The API resource e.g server-group + self.resource_name = resource_name + + # List of params used to create the resource + self.resource_create_param_keys = resource_create_param_keys or ['name'] + + # List of params used to update the resource + self.resource_update_param_keys = resource_update_param_keys or ['name'] + + # Resource has no name field but tags, we use a defined tag as name + self.use_tag_for_name = False + self.resource_name_tag = "ansible_name" + + # Constraint Keys to match when query by name + self.query_constraint_keys = [] + + def pre_transform(self, resource): + return resource + + def init_resource(self): + return { + 'state': "absent", + self.resource_key_uuid: self._module.params.get(self.resource_key_uuid) or self._resource_data.get(self.resource_key_uuid), + self.resource_key_name: self._module.params.get(self.resource_key_name) or self._resource_data.get(self.resource_key_name), + } + + def query(self): + # Initialize + self._resource_data = self.init_resource() + + # Query by UUID + uuid = self._module.params[self.resource_key_uuid] + if uuid is not None: + + # network id case + if "/" in uuid: + uuid = uuid.split("/")[0] + + resource = self._get('%s/%s' % (self.resource_name, uuid)) + if resource: + self._resource_data = resource + self._resource_data['state'] = "present" + + # Query by name + else: + name = self._module.params[self.resource_key_name] + + # Resource has no name field, we use a defined tag as name + if self.use_tag_for_name: + resources = self._get('%s?tag:%s=%s' % (self.resource_name, self.resource_name_tag, name)) + else: + resources = self._get('%s' % self.resource_name) + + matching = [] + for resource in resources: + if self.use_tag_for_name: + resource[self.resource_key_name] = resource['tags'].get(self.resource_name_tag) + + # Skip resource if constraints is not given e.g. in case of floating_ip the ip_version differs + for constraint_key in self.query_constraint_keys: + if self._module.params[constraint_key] is not None: + if constraint_key == 'zone': + resource_value = resource['zone']['slug'] + else: + resource_value = resource[constraint_key] + + if resource_value != self._module.params[constraint_key]: + break + else: + if resource[self.resource_key_name] == name: + matching.append(resource) + + # Fail on more than one resource with identical name + if len(matching) > 1: + self._module.fail_json( + msg="More than one %s resource with '%s' exists: %s. " + "Use the '%s' parameter to identify the resource." % ( + self.resource_name, + self.resource_key_name, + name, + self.resource_key_uuid + ) + ) + elif len(matching) == 1: + self._resource_data = matching[0] + self._resource_data['state'] = "present" + + return self.pre_transform(self._resource_data) + + def create(self, resource, data=None): + # Fail if UUID/ID was provided but the resource was not found on state=present. + uuid = self._module.params.get(self.resource_key_uuid) + if uuid is not None: + self._module.fail_json(msg="The resource with UUID '%s' was not found " + "and we would create a new one with different UUID, " + "this is probably not want you have asked for." % uuid) + + self._result['changed'] = True + + if not data: + data = dict() + + for param in self.resource_create_param_keys: + data[param] = self._module.params.get(param) + + self._result['diff']['before'] = deepcopy(resource) + self._result['diff']['after'] = deepcopy(resource) + self._result['diff']['after'].update(deepcopy(data)) + self._result['diff']['after'].update({ + 'state': "present", + }) + + if not self._module.check_mode: + resource = self._post(self.resource_name, data) + resource = self.pre_transform(resource) + resource['state'] = "present" + return resource + + def update(self, resource): + updated = False + for param in self.resource_update_param_keys: + updated = self._param_updated(param, resource) or updated + + # Refresh if resource was updated in live mode + if updated and not self._module.check_mode: + resource = self.query() + return resource + + def present(self): + resource = self.query() + + if self.use_tag_for_name: + name_tag_value = self._module.params[self.resource_key_name] or resource.get('tags', dict()).get(self.resource_name_tag) + if name_tag_value: + self._module.params['tags'] = self._module.params['tags'] or dict() + self._module.params['tags'].update({ + self.resource_name_tag: name_tag_value + }) + + if resource['state'] == "absent": + resource = self.create(resource) + else: + resource = self.update(resource) + return self.get_result(resource) + + def absent(self): + resource = self.query() + if resource['state'] != "absent": + self._result['changed'] = True + self._result['diff']['before'] = deepcopy(resource) + self._result['diff']['after'] = self.init_resource() + + if not self._module.check_mode: + href = resource.get('href') + if not href: + self._module.fail_json(msg='Unable to delete %s, no href found.') + + self._delete(href) + resource['state'] = "absent" + return self.get_result(resource) + + def _param_updated(self, key, resource): + param = self._module.params.get(key) + if param is None: + return False + + if not resource or key not in resource: + return False + + is_different = False + + # If it looks like a stub + if isinstance(resource[key], dict) and 'href' in resource[key]: + uuid = resource[key].get('href', '').split('/')[-1] + if param != uuid: + is_different = True + + elif param != resource[key]: + is_different = True + + if is_different: + self._result['changed'] = True + + patch_data = { + key: param + } + + self._result['diff']['before'].update({key: resource[key]}) + self._result['diff']['after'].update(patch_data) + + if not self._module.check_mode: + href = resource.get('href') + if not href: + self._module.fail_json(msg='Unable to update %s, no href found.' % key) + + self._patch(href, patch_data) + return True + return False + + def get_result(self, resource): + if resource: + for k, v in resource.items(): + self._result[k] = v + + # Transform the name tag to a name field + if self.use_tag_for_name: + self._result['name'] = self._result.get('tags', dict()).pop(self.resource_name_tag, None) + + return self._result diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/__init__.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/__init__.py diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/floating_ip.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/floating_ip.py new file mode 100644 index 00000000..9e136087 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/floating_ip.py @@ -0,0 +1,301 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (c) 2017, Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = ''' +--- +module: floating_ip +short_description: Manages floating IPs on the cloudscale.ch IaaS service +description: + - Create, assign and delete floating IPs on the cloudscale.ch IaaS service. +notes: + - Once a floating_ip is created, all parameters except C(server), C(reverse_ptr) and C(tags) are read-only. +author: + - Gaudenz Steinlin (@gaudenz) + - Denis Krienbühl (@href) + - René Moser (@resmo) +version_added: 1.0.0 +options: + network: + description: + - Floating IP address to change. + - One of I(network) or I(name) is required to identify the floating IP. + aliases: [ ip ] + type: str + name: + description: + - Name to identifiy the floating IP address for idempotency. + - One of I(network) or I(name) is required to identify the floating IP. + - "Note: I(name) will be required for assigning a new floating IP beginning of version 2.0.0." + version_added: 1.3.0 + type: str + state: + description: + - State of the floating IP. + default: present + choices: [ present, absent ] + type: str + ip_version: + description: + - IP protocol version of the floating IP. + - Required when assigning a new floating IP. + choices: [ 4, 6 ] + type: int + server: + description: + - UUID of the server assigned to this floating IP. + type: str + type: + description: + - The type of the floating IP. + choices: [ regional, global ] + type: str + default: regional + region: + description: + - Region in which the floating IP resides (e.g. C(lgp) or C(rma)). + If omitted, the region of the project default zone is used. + This parameter must be omitted if I(type) is set to C(global). + type: str + prefix_length: + description: + - Only valid if I(ip_version) is 6. + - Prefix length for the IPv6 network. Currently only a prefix of /56 can be requested. If no I(prefix_length) is present, a + single address is created. + choices: [ 56 ] + type: int + reverse_ptr: + description: + - Reverse PTR entry for this address. + - You cannot set a reverse PTR entry for IPv6 floating networks. Reverse PTR entries are only allowed for single addresses. + type: str + tags: + description: + - Tags associated with the floating IP. Set this to C({}) to clear any tags. + type: dict + version_added: 1.1.0 +extends_documentation_fragment: cloudscale_ch.cloud.api_parameters +''' + +EXAMPLES = ''' +# Request a new floating IP without assignment to a server +- name: Request a floating IP + cloudscale_ch.cloud.floating_ip: + name: IP to my server + ip_version: 4 + reverse_ptr: my-server.example.com + api_token: xxxxxx + +# Request a new floating IP with assignment +- name: Request a floating IP + cloudscale_ch.cloud.floating_ip: + name: web + ip_version: 4 + server: 47cec963-fcd2-482f-bdb6-24461b2d47b1 + reverse_ptr: my-server.example.com + api_token: xxxxxx + +# Assign an existing floating IP to a different server by its IP address +- name: Move floating IP to backup server + cloudscale_ch.cloud.floating_ip: + ip: 192.0.2.123 + server: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48 + api_token: xxxxxx + +# Assign an existing floating IP to a different server by name +- name: Move floating IP to backup server + cloudscale_ch.cloud.floating_ip: + name: IP to my server + server: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48 + api_token: xxxxxx + +# Request a new floating IPv6 network +- name: Request a floating IP + cloudscale_ch.cloud.floating_ip: + name: IPv6 to my server + ip_version: 6 + prefix_length: 56 + server: 47cec963-fcd2-482f-bdb6-24461b2d47b1 + api_token: xxxxxx + region: lpg1 + +# Assign an existing floating network to a different server +- name: Move floating IP to backup server + cloudscale_ch.cloud.floating_ip: + ip: '{{ floating_ip.ip }}' + server: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48 + api_token: xxxxxx + +# Remove a floating IP +- name: Release floating IP + cloudscale_ch.cloud.floating_ip: + ip: 192.0.2.123 + state: absent + api_token: xxxxxx + +# Remove a floating IP by name +- name: Release floating IP + cloudscale_ch.cloud.floating_ip: + name: IP to my server + state: absent + api_token: xxxxxx +''' + +RETURN = ''' +name: + description: The name of the floating IP. + returned: success + type: str + sample: my floating ip + version_added: 1.3.0 +href: + description: The API URL to get details about this floating IP. + returned: success when state == present + type: str + sample: https://api.cloudscale.ch/v1/floating-ips/2001:db8::cafe +network: + description: The CIDR notation of the network that is routed to your server. + returned: success + type: str + sample: 2001:db8::cafe/128 +next_hop: + description: Your floating IP is routed to this IP address. + returned: success when state == present + type: str + sample: 2001:db8:dead:beef::42 +reverse_ptr: + description: The reverse pointer for this floating IP address. + returned: success when state == present + type: str + sample: 185-98-122-176.cust.cloudscale.ch +server: + description: The floating IP is routed to this server. + returned: success when state == present + type: str + sample: 47cec963-fcd2-482f-bdb6-24461b2d47b1 +ip: + description: The floating IP address. + returned: success when state == present + type: str + sample: 185.98.122.176 +region: + description: The region of the floating IP. + returned: success when state == present + type: dict + sample: {'slug': 'lpg'} +state: + description: The current status of the floating IP. + returned: success + type: str + sample: present +tags: + description: Tags assosiated with the floating IP. + returned: success + type: dict + sample: { 'project': 'my project' } + version_added: 1.1.0 +''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import ( + AnsibleCloudscaleBase, + cloudscale_argument_spec, +) + + +class AnsibleCloudscaleFloatingIp(AnsibleCloudscaleBase): + + def __init__(self, module): + super(AnsibleCloudscaleFloatingIp, self).__init__( + module=module, + resource_key_uuid='network', + resource_name='floating-ips', + resource_create_param_keys=[ + 'ip_version', + 'server', + 'prefix_length', + 'reverse_ptr', + 'type', + 'region', + 'tags', + ], + resource_update_param_keys=[ + 'server', + 'reverse_ptr', + 'tags', + ], + ) + self.use_tag_for_name = True + self.query_constraint_keys = ['ip_version'] + + def pre_transform(self, resource): + if 'server' in resource and isinstance(resource['server'], dict): + resource['server'] = resource['server']['uuid'] + return resource + + # TODO: To be removed in 2.0.0 + def query(self): + # Don't try to find anything without network or name + if not any([self._module.params['name'], self._module.params['network']]): + return self.init_resource() + return super(AnsibleCloudscaleFloatingIp, self).query() + + def create(self, resource): + # Fail when missing params for creation + self._module.fail_on_missing_params(['ip_version']) + + # TODO: To be removed in 2.0.0 + if not self._module.params['name']: + self._module.deprecate( + msg="Name is missing, this won't be supported in the future", + version="2.0.0", + collection_name="cloudscale_ch.cloud" + ) + return super(AnsibleCloudscaleFloatingIp, self).create(resource) + + def get_result(self, resource): + network = resource.get('network') + if network: + self._result['ip'] = network.split('/')[0] + return super(AnsibleCloudscaleFloatingIp, self).get_result(resource) + + +def main(): + argument_spec = cloudscale_argument_spec() + argument_spec.update(dict( + name=dict(type='str'), + state=dict(default='present', choices=('present', 'absent'), type='str'), + network=dict(aliases=('ip',), type='str'), + ip_version=dict(choices=(4, 6), type='int'), + server=dict(type='str'), + type=dict(type='str', choices=('regional', 'global'), default='regional'), + region=dict(type='str'), + prefix_length=dict(choices=(56,), type='int'), + reverse_ptr=dict(type='str'), + tags=dict(type='dict'), + )) + + module = AnsibleModule( + argument_spec=argument_spec, + # TODO: Enable for version 2.0.0 + # required_one_of=(('network', 'name'),), + supports_check_mode=True, + ) + + cloudscale_floating_ip = AnsibleCloudscaleFloatingIp(module) + + if module.params['state'] == 'absent': + result = cloudscale_floating_ip.absent() + else: + result = cloudscale_floating_ip.present() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/network.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/network.py new file mode 100644 index 00000000..c592c671 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/network.py @@ -0,0 +1,197 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (c) 2020, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = ''' +--- +module: network +short_description: Manages networks on the cloudscale.ch IaaS service +description: + - Create, update and remove networks. +author: + - René Moser (@resmo) +version_added: "1.2.0" +options: + name: + description: + - Name of the network. + - Either I(name) or I(uuid) is required. + type: str + uuid: + description: + - UUID of the network. + - Either I(name) or I(uuid) is required. + type: str + mtu: + description: + - The MTU of the network. + default: 9000 + type: int + auto_create_ipv4_subnet: + description: + - Whether to automatically create an IPv4 subnet in the network or not. + default: true + type: bool + zone: + description: + - Zone slug of the network (e.g. C(lgp1) or C(rma1)). + type: str + state: + description: + - State of the network. + choices: [ present, absent ] + default: present + type: str + tags: + description: + - Tags assosiated with the networks. Set this to C({}) to clear any tags. + type: dict +extends_documentation_fragment: cloudscale_ch.cloud.api_parameters +''' + +EXAMPLES = ''' +--- +- name: Ensure network exists + cloudscale_ch.cloud.network: + name: my network + api_token: xxxxxx + +- name: Ensure network in a specific zone + cloudscale_ch.cloud.network: + name: my network + zone: lpg1 + api_token: xxxxxx + +- name: Ensure a network is absent + cloudscale_ch.cloud.network: + name: my network + state: absent + api_token: xxxxxx +''' + +RETURN = ''' +--- +href: + description: API URL to get details about this network. + returned: success + type: str + sample: https://api.cloudscale.ch/v1/networks/cfde831a-4e87-4a75-960f-89b0148aa2cc +uuid: + description: The unique identifier for the network. + returned: success + type: str + sample: cfde831a-4e87-4a75-960f-89b0148aa2cc +name: + description: The name of the network. + returned: success + type: str + sample: my network +created_at: + description: The creation date and time of the network. + returned: success + type: str + sample: "2019-05-29T13:18:42.511407Z" +subnets: + description: A list of subnets objects of the network. + returned: success + type: complex + contains: + href: + description: API URL to get details about the subnet. + returned: success + type: str + sample: https://api.cloudscale.ch/v1/subnets/33333333-1864-4608-853a-0771b6885a3 + uuid: + description: The unique identifier for the subnet. + returned: success + type: str + sample: 33333333-1864-4608-853a-0771b6885a3 + cidr: + description: The CIDR of the subnet. + returned: success + type: str + sample: 172.16.0.0/24 +mtu: + description: The MTU of the network. + returned: success + type: int + sample: 9000 +zone: + description: The zone of the network. + returned: success + type: dict + sample: { 'slug': 'rma1' } +state: + description: State of the network. + returned: success + type: str + sample: present +tags: + description: Tags assosiated with the network. + returned: success + type: dict + sample: { 'project': 'my project' } +''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import ( + AnsibleCloudscaleBase, + cloudscale_argument_spec, +) + + +def main(): + argument_spec = cloudscale_argument_spec() + argument_spec.update(dict( + name=dict(type='str'), + uuid=dict(type='str'), + mtu=dict(type='int', default=9000), + auto_create_ipv4_subnet=dict(type='bool', default=True), + zone=dict(type='str'), + tags=dict(type='dict'), + state=dict(default='present', choices=['absent', 'present']), + )) + + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=(('name', 'uuid'),), + required_if=(('state', 'present', ('name',),),), + supports_check_mode=True, + ) + + cloudscale_network = AnsibleCloudscaleBase( + module, + resource_name='networks', + resource_create_param_keys=[ + 'name', + 'mtu', + 'auto_create_ipv4_subnet', + 'zone', + 'tags', + ], + resource_update_param_keys=[ + 'name', + 'mtu', + 'tags', + ], + ) + + cloudscale_network.query_constraint_keys = [ + 'zone', + ] + + if module.params['state'] == 'absent': + result = cloudscale_network.absent() + else: + result = cloudscale_network.present() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/objects_user.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/objects_user.py new file mode 100644 index 00000000..e6deae7e --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/objects_user.py @@ -0,0 +1,162 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (c) 2020, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = r''' +--- +module: objects_user +short_description: Manages objects users on the cloudscale.ch IaaS service +description: + - Create, update and remove objects users cloudscale.ch IaaS service. +author: + - Rene Moser (@resmo) +version_added: 1.1.0 +options: + display_name: + description: + - Display name of the objects user. + - Either I(display_name) or I(id) is required. + type: str + aliases: + - name + id: + description: + - Name of the objects user. + - Either I(display_name) or I(id) is required. + type: str + tags: + description: + - Tags associated with the objects user. Set this to C({}) to clear any tags. + type: dict + state: + description: + - State of the objects user. + default: present + choices: [ present, absent ] + type: str +extends_documentation_fragment: cloudscale_ch.cloud.api_parameters +''' + +EXAMPLES = r''' +- name: Create an objects user + cloudscale_ch.cloud.objects_user: + display_name: alan + tags: + project: luna + api_token: xxxxxx + register: object_user + +- name: print keys + debug: + var: object_user.keys + +- name: Update an objects user + cloudscale_ch.cloud.objects_user: + display_name: alan + tags: + project: gemini + api_token: xxxxxx + +- name: Remove an objects user + cloudscale_ch.cloud.objects_user: + display_name: alan + state: absent + api_token: xxxxxx +''' + +RETURN = r''' +href: + description: The API URL to get details about this resource. + returned: success when state == present + type: str + sample: https://api.cloudscale.ch/v1/objects-users/6fe39134bf4178747eebc429f82cfafdd08891d4279d0d899bc4012db1db6a15 +display_name: + description: The display name of the objects user. + returned: success + type: str + sample: alan +id: + description: The ID of the objects user. + returned: success + type: str + sample: 6fe39134bf4178747eebc429f82cfafdd08891d4279d0d899bc4012db1db6a15 +keys: + description: List of key objects. + returned: success + type: complex + contains: + access_key: + description: The access key. + returned: success + type: str + sample: 0ZTAIBKSGYBRHQ09G11W + secret_key: + description: The secret key. + returned: success + type: str + sample: bn2ufcwbIa0ARLc5CLRSlVaCfFxPHOpHmjKiH34T +tags: + description: Tags assosiated with the objects user. + returned: success + type: dict + sample: { 'project': 'my project' } +state: + description: The current status of the objects user. + returned: success + type: str + sample: present +''' + +from ansible.module_utils.basic import AnsibleModule, env_fallback, missing_required_lib +from ..module_utils.api import ( + AnsibleCloudscaleBase, + cloudscale_argument_spec, +) + + +def main(): + argument_spec = cloudscale_argument_spec() + argument_spec.update(dict( + display_name=dict(type='str', aliases=['name']), + id=dict(type='str'), + tags=dict(type='dict'), + state=dict(type='str', default='present', choices=('present', 'absent')), + )) + + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=(('display_name', 'id'),), + required_if=(('state', 'present', ('display_name',),),), + supports_check_mode=True, + ) + + cloudscale_objects_user = AnsibleCloudscaleBase( + module, + resource_name='objects-users', + resource_key_uuid='id', + resource_key_name='display_name', + resource_create_param_keys=[ + 'display_name', + 'tags', + ], + resource_update_param_keys=[ + 'display_name', + 'tags', + ], + ) + + if module.params['state'] == "absent": + result = cloudscale_objects_user.absent() + else: + result = cloudscale_objects_user.present() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/server.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/server.py new file mode 100644 index 00000000..c8830c40 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/server.py @@ -0,0 +1,533 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright: (c) 2017, Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch> +# Copyright: (c) 2019, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = ''' +--- +module: server +short_description: Manages servers on the cloudscale.ch IaaS service +description: + - Create, update, start, stop and delete servers on the cloudscale.ch IaaS service. +notes: + - If I(uuid) option is provided, it takes precedence over I(name) for server selection. This allows to update the server's name. + - If no I(uuid) option is provided, I(name) is used for server selection. If more than one server with this name exists, execution is aborted. + - Only the I(name) and I(flavor) are evaluated for the update. + - The option I(force=true) must be given to allow the reboot of existing running servers for applying the changes. +author: + - Gaudenz Steinlin (@gaudenz) + - René Moser (@resmo) + - Denis Krienbühl (@href) +version_added: "1.0.0" +options: + state: + description: + - State of the server. + choices: [ running, stopped, absent ] + default: running + type: str + name: + description: + - Name of the Server. + - Either I(name) or I(uuid) are required. + type: str + uuid: + description: + - UUID of the server. + - Either I(name) or I(uuid) are required. + type: str + flavor: + description: + - Flavor of the server. + type: str + image: + description: + - Image used to create the server. + type: str + zone: + description: + - Zone in which the server resides (e.g. C(lgp1) or C(rma1)). + type: str + volume_size_gb: + description: + - Size of the root volume in GB. + default: 10 + type: int + bulk_volume_size_gb: + description: + - Size of the bulk storage volume in GB. + - No bulk storage volume if not set. + type: int + ssh_keys: + description: + - List of SSH public keys. + - Use the full content of your .pub file here. + type: list + elements: str + password: + description: + - Password for the server. + type: str + use_public_network: + description: + - Attach a public network interface to the server. + default: yes + type: bool + use_private_network: + description: + - Attach a private network interface to the server. + default: no + type: bool + use_ipv6: + description: + - Enable IPv6 on the public network interface. + default: yes + type: bool + server_groups: + description: + - List of UUID or names of server groups. + type: list + elements: str + user_data: + description: + - Cloud-init configuration (cloud-config) data to use for the server. + type: str + force: + description: + - Allow to stop the running server for updating if necessary. + default: no + type: bool + tags: + description: + - Tags assosiated with the servers. Set this to C({}) to clear any tags. + type: dict +extends_documentation_fragment: cloudscale_ch.cloud.api_parameters +''' + +EXAMPLES = ''' +# Create and start a server with an existing server group (shiny-group) +- name: Start cloudscale.ch server + cloudscale_ch.cloud.server: + name: my-shiny-cloudscale-server + image: debian-8 + flavor: flex-4 + ssh_keys: ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale + server_groups: shiny-group + zone: lpg1 + use_private_network: True + bulk_volume_size_gb: 100 + api_token: xxxxxx + +# Start another server in anti-affinity (server group shiny-group) +- name: Start second cloudscale.ch server + cloudscale_ch.cloud.server: + name: my-other-shiny-server + image: ubuntu-16.04 + flavor: flex-8 + ssh_keys: ssh-rsa XXXXXXXXXXX ansible@cloudscale + server_groups: shiny-group + zone: lpg1 + api_token: xxxxxx + +# Force to update the flavor of a running server +- name: Start cloudscale.ch server + cloudscale_ch.cloud.server: + name: my-shiny-cloudscale-server + image: debian-8 + flavor: flex-8 + force: yes + ssh_keys: ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale + use_private_network: True + bulk_volume_size_gb: 100 + api_token: xxxxxx + register: server1 + +# Stop the first server +- name: Stop my first server + cloudscale_ch.cloud.server: + uuid: '{{ server1.uuid }}' + state: stopped + api_token: xxxxxx + +# Delete my second server +- name: Delete my second server + cloudscale_ch.cloud.server: + name: my-other-shiny-server + state: absent + api_token: xxxxxx + +# Start a server and wait for the SSH host keys to be generated +- name: Start server and wait for SSH host keys + cloudscale_ch.cloud.server: + name: my-cloudscale-server-with-ssh-key + image: debian-8 + flavor: flex-4 + ssh_keys: ssh-rsa XXXXXXXXXXX ansible@cloudscale + api_token: xxxxxx + register: server + until: server is not failed + retries: 5 + delay: 2 +''' + +RETURN = ''' +href: + description: API URL to get details about this server + returned: success when not state == absent + type: str + sample: https://api.cloudscale.ch/v1/servers/cfde831a-4e87-4a75-960f-89b0148aa2cc +uuid: + description: The unique identifier for this server + returned: success + type: str + sample: cfde831a-4e87-4a75-960f-89b0148aa2cc +name: + description: The display name of the server + returned: success + type: str + sample: its-a-me-mario.cloudscale.ch +state: + description: The current status of the server + returned: success + type: str + sample: running +flavor: + description: The flavor that has been used for this server + returned: success when not state == absent + type: dict + sample: { "slug": "flex-4", "name": "Flex-4", "vcpu_count": 2, "memory_gb": 4 } +image: + description: The image used for booting this server + returned: success when not state == absent + type: dict + sample: { "default_username": "ubuntu", "name": "Ubuntu 18.04 LTS", "operating_system": "Ubuntu", "slug": "ubuntu-18.04" } +zone: + description: The zone used for booting this server + returned: success when not state == absent + type: dict + sample: { 'slug': 'lpg1' } +volumes: + description: List of volumes attached to the server + returned: success when not state == absent + type: list + sample: [ {"type": "ssd", "device": "/dev/vda", "size_gb": "50"} ] +interfaces: + description: List of network ports attached to the server + returned: success when not state == absent + type: list + sample: [ { "type": "public", "addresses": [ ... ] } ] +ssh_fingerprints: + description: A list of SSH host key fingerprints. Will be null until the host keys could be retrieved from the server. + returned: success when not state == absent + type: list + sample: ["ecdsa-sha2-nistp256 SHA256:XXXX", ... ] +ssh_host_keys: + description: A list of SSH host keys. Will be null until the host keys could be retrieved from the server. + returned: success when not state == absent + type: list + sample: ["ecdsa-sha2-nistp256 XXXXX", ... ] +server_groups: + description: List of server groups + returned: success when not state == absent + type: list + sample: [ {"href": "https://api.cloudscale.ch/v1/server-groups/...", "uuid": "...", "name": "db-group"} ] +tags: + description: Tags assosiated with the server. + returned: success + type: dict + sample: { 'project': 'my project' } +''' + +from datetime import datetime, timedelta +from time import sleep +from copy import deepcopy + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import ( + AnsibleCloudscaleBase, + cloudscale_argument_spec, +) + +ALLOWED_STATES = ('running', + 'stopped', + 'absent', + ) + + +class AnsibleCloudscaleServer(AnsibleCloudscaleBase): + + def __init__(self, module): + super(AnsibleCloudscaleServer, self).__init__(module) + + # Initialize server dictionary + self._info = {} + + def _init_server_container(self): + return { + 'uuid': self._module.params.get('uuid') or self._info.get('uuid'), + 'name': self._module.params.get('name') or self._info.get('name'), + 'state': 'absent', + } + + def _get_server_info(self, refresh=False): + if self._info and not refresh: + return self._info + + self._info = self._init_server_container() + + uuid = self._info.get('uuid') + if uuid is not None: + server_info = self._get('servers/%s' % uuid) + if server_info: + self._info = self._transform_state(server_info) + + else: + name = self._info.get('name') + if name is not None: + servers = self._get('servers') or [] + matching_server = [] + for server in servers: + if server['name'] == name: + matching_server.append(server) + + if len(matching_server) == 1: + self._info = self._transform_state(matching_server[0]) + elif len(matching_server) > 1: + self._module.fail_json(msg="More than one server with name '%s' exists. " + "Use the 'uuid' parameter to identify the server." % name) + + return self._info + + @staticmethod + def _transform_state(server): + if 'status' in server: + server['state'] = server['status'] + del server['status'] + else: + server['state'] = 'absent' + return server + + def _wait_for_state(self, states): + start = datetime.now() + timeout = self._module.params['api_timeout'] * 2 + while datetime.now() - start < timedelta(seconds=timeout): + server_info = self._get_server_info(refresh=True) + if server_info.get('state') in states: + return server_info + sleep(1) + + # Timeout succeeded + if server_info.get('name') is not None: + msg = "Timeout while waiting for a state change on server %s to states %s. " \ + "Current state is %s." % (server_info.get('name'), states, server_info.get('state')) + else: + name_uuid = self._module.params.get('name') or self._module.params.get('uuid') + msg = 'Timeout while waiting to find the server %s' % name_uuid + + self._module.fail_json(msg=msg) + + def _start_stop_server(self, server_info, target_state="running", ignore_diff=False): + actions = { + 'stopped': 'stop', + 'running': 'start', + } + + server_state = server_info.get('state') + if server_state != target_state: + self._result['changed'] = True + + if not ignore_diff: + self._result['diff']['before'].update({ + 'state': server_info.get('state'), + }) + self._result['diff']['after'].update({ + 'state': target_state, + }) + if not self._module.check_mode: + self._post('servers/%s/%s' % (server_info['uuid'], actions[target_state])) + server_info = self._wait_for_state((target_state, )) + + return server_info + + def _update_param(self, param_key, server_info, requires_stop=False): + param_value = self._module.params.get(param_key) + if param_value is None: + return server_info + + if 'slug' in server_info[param_key]: + server_v = server_info[param_key]['slug'] + else: + server_v = server_info[param_key] + + if server_v != param_value: + # Set the diff output + self._result['diff']['before'].update({param_key: server_v}) + self._result['diff']['after'].update({param_key: param_value}) + + if server_info.get('state') == "running": + if requires_stop and not self._module.params.get('force'): + self._module.warn("Some changes won't be applied to running servers. " + "Use force=yes to allow the server '%s' to be stopped/started." % server_info['name']) + return server_info + + # Either the server is stopped or change is forced + self._result['changed'] = True + if not self._module.check_mode: + + if requires_stop: + self._start_stop_server(server_info, target_state="stopped", ignore_diff=True) + + patch_data = { + param_key: param_value, + } + + # Response is 204: No Content + self._patch('servers/%s' % server_info['uuid'], patch_data) + + # State changes to "changing" after update, waiting for stopped/running + server_info = self._wait_for_state(('stopped', 'running')) + + return server_info + + def _get_server_group_ids(self): + server_group_params = self._module.params['server_groups'] + if not server_group_params: + return None + + matching_group_names = [] + results = [] + server_groups = self._get('server-groups') + for server_group in server_groups: + if server_group['uuid'] in server_group_params: + results.append(server_group['uuid']) + server_group_params.remove(server_group['uuid']) + + elif server_group['name'] in server_group_params: + results.append(server_group['uuid']) + server_group_params.remove(server_group['name']) + # Remember the names found + matching_group_names.append(server_group['name']) + + # Names are not unique, verify if name already found in previous iterations + elif server_group['name'] in matching_group_names: + self._module.fail_json(msg="More than one server group with name exists: '%s'. " + "Use the 'uuid' parameter to identify the server group." % server_group['name']) + + if server_group_params: + self._module.fail_json(msg="Server group name or UUID not found: %s" % ', '.join(server_group_params)) + + return results + + def _create_server(self, server_info): + self._result['changed'] = True + + data = deepcopy(self._module.params) + for i in ('uuid', 'state', 'force', 'api_timeout', 'api_token', 'api_url'): + del data[i] + data['server_groups'] = self._get_server_group_ids() + + self._result['diff']['before'] = self._init_server_container() + self._result['diff']['after'] = deepcopy(data) + if not self._module.check_mode: + self._post('servers', data) + server_info = self._wait_for_state(('running', )) + return server_info + + def _update_server(self, server_info): + + previous_state = server_info.get('state') + + # The API doesn't support to update server groups. + # Show a warning to the user if the desired state does not match. + desired_server_group_ids = self._get_server_group_ids() + if desired_server_group_ids is not None: + current_server_group_ids = [grp['uuid'] for grp in server_info['server_groups']] + if desired_server_group_ids != current_server_group_ids: + self._module.warn("Server groups can not be mutated, server needs redeployment to change groups.") + + server_info = self._update_param('flavor', server_info, requires_stop=True) + server_info = self._update_param('name', server_info) + server_info = self._update_param('tags', server_info) + + if previous_state == "running": + server_info = self._start_stop_server(server_info, target_state="running", ignore_diff=True) + + return server_info + + def present_server(self): + server_info = self._get_server_info() + + if server_info.get('state') != "absent": + + # If target state is stopped, stop before an potential update and force would not be required + if self._module.params.get('state') == "stopped": + server_info = self._start_stop_server(server_info, target_state="stopped") + + server_info = self._update_server(server_info) + + if self._module.params.get('state') == "running": + server_info = self._start_stop_server(server_info, target_state="running") + else: + server_info = self._create_server(server_info) + server_info = self._start_stop_server(server_info, target_state=self._module.params.get('state')) + + return server_info + + def absent_server(self): + server_info = self._get_server_info() + if server_info.get('state') != "absent": + self._result['changed'] = True + self._result['diff']['before'] = deepcopy(server_info) + self._result['diff']['after'] = self._init_server_container() + if not self._module.check_mode: + self._delete('servers/%s' % server_info['uuid']) + server_info = self._wait_for_state(('absent', )) + return server_info + + +def main(): + argument_spec = cloudscale_argument_spec() + argument_spec.update(dict( + state=dict(default='running', choices=ALLOWED_STATES), + name=dict(), + uuid=dict(), + flavor=dict(), + image=dict(), + zone=dict(), + volume_size_gb=dict(type='int', default=10), + bulk_volume_size_gb=dict(type='int'), + ssh_keys=dict(type='list', elements='str'), + password=dict(no_log=True), + use_public_network=dict(type='bool', default=True), + use_private_network=dict(type='bool', default=False), + use_ipv6=dict(type='bool', default=True), + server_groups=dict(type='list', elements='str'), + user_data=dict(), + force=dict(type='bool', default=False), + tags=dict(type='dict'), + )) + + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=(('name', 'uuid'),), + supports_check_mode=True, + ) + + cloudscale_server = AnsibleCloudscaleServer(module) + if module.params['state'] == "absent": + server = cloudscale_server.absent_server() + else: + server = cloudscale_server.present_server() + + result = cloudscale_server.get_result(server) + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/server_group.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/server_group.py new file mode 100644 index 00000000..ce68a6bc --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/server_group.py @@ -0,0 +1,171 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (c) 2019, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = ''' +--- +module: server_group +short_description: Manages server groups on the cloudscale.ch IaaS service +description: + - Create, update and remove server groups. +author: + - René Moser (@resmo) + - Denis Krienbühl (@href) +version_added: "1.0.0" +options: + name: + description: + - Name of the server group. + - Either I(name) or I(uuid) is required. These options are mutually exclusive. + type: str + uuid: + description: + - UUID of the server group. + - Either I(name) or I(uuid) is required. These options are mutually exclusive. + type: str + type: + description: + - Type of the server group. + default: anti-affinity + type: str + zone: + description: + - Zone slug of the server group (e.g. C(lgp1) or C(rma1)). + type: str + state: + description: + - State of the server group. + choices: [ present, absent ] + default: present + type: str + tags: + description: + - Tags assosiated with the server groups. Set this to C({}) to clear any tags. + type: dict +extends_documentation_fragment: cloudscale_ch.cloud.api_parameters +''' + +EXAMPLES = ''' +--- +- name: Ensure server group exists + cloudscale_ch.cloud.server_group: + name: my-name + type: anti-affinity + api_token: xxxxxx + +- name: Ensure server group in a specific zone + cloudscale_ch.cloud.server_group: + name: my-rma-group + type: anti-affinity + zone: lpg1 + api_token: xxxxxx + +- name: Ensure a server group is absent + cloudscale_ch.cloud.server_group: + name: my-name + state: absent + api_token: xxxxxx +''' + +RETURN = ''' +--- +href: + description: API URL to get details about this server group + returned: if available + type: str + sample: https://api.cloudscale.ch/v1/server-group/cfde831a-4e87-4a75-960f-89b0148aa2cc +uuid: + description: The unique identifier for this server + returned: always + type: str + sample: cfde831a-4e87-4a75-960f-89b0148aa2cc +name: + description: The display name of the server group + returned: always + type: str + sample: load balancers +type: + description: The type the server group + returned: if available + type: str + sample: anti-affinity +zone: + description: The zone of the server group + returned: success + type: dict + sample: { 'slug': 'rma1' } +servers: + description: A list of servers that are part of the server group. + returned: if available + type: list + sample: [] +state: + description: State of the server group. + returned: always + type: str + sample: present +tags: + description: Tags assosiated with the server group. + returned: success + type: dict + sample: { 'project': 'my project' } +''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import ( + AnsibleCloudscaleBase, + cloudscale_argument_spec, +) + + +def main(): + argument_spec = cloudscale_argument_spec() + argument_spec.update(dict( + name=dict(type='str'), + uuid=dict(type='str'), + type=dict(type='str', default='anti-affinity'), + zone=dict(type='str'), + tags=dict(type='dict'), + state=dict(default='present', choices=['absent', 'present']), + )) + + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=(('name', 'uuid'),), + required_if=(('state', 'present', ('name',),),), + supports_check_mode=True, + ) + + cloudscale_server_group = AnsibleCloudscaleBase( + module, + resource_name='server-groups', + resource_create_param_keys=[ + 'name', + 'type', + 'zone', + 'tags', + ], + resource_update_param_keys=[ + 'name', + 'tags', + ], + ) + cloudscale_server_group.query_constraint_keys = [ + 'zone', + ] + + if module.params['state'] == 'absent': + result = cloudscale_server_group.absent() + else: + result = cloudscale_server_group.present() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/subnet.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/subnet.py new file mode 100644 index 00000000..b5e50306 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/subnet.py @@ -0,0 +1,322 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (c) 2020, René Moser <rene.moser@cloudscale.ch> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = ''' +--- +module: subnet +short_description: Manages subnets on the cloudscale.ch IaaS service +description: + - Create, update and remove subnets. +author: + - René Moser (@resmo) +version_added: "1.3.0" +options: + uuid: + description: + - UUID of the subnet. + type: str + cidr: + description: + - The cidr of the subnet. + - Required if I(state=present). + type: str + network: + description: + - The name of the network the subnet is related to. + - Required if I(state=present). + type: dict + suboptions: + uuid: + description: + - The uuid of the network. + type: str + name: + description: + - The uuid of the network. + type: str + zone: + description: + - The zone the network allocated in. + type: str + gateway_address: + description: + - The gateway address of the subnet. If not set, no gateway is used. + - Cannot be within the DHCP range, which is the lowest .101-.254 in the subnet. + type: str + dns_servers: + description: + - A list of DNS resolver IP addresses, that act as DNS servers. + - If not set, the cloudscale.ch default resolvers are used. + type: list + elements: str + reset: + description: + - Resets I(gateway_address) and I(dns_servers) to default values by the API. + - "Note: Idempotency is not given." + type: bool + default: false + state: + description: + - State of the subnet. + choices: [ present, absent ] + default: present + type: str + tags: + description: + - Tags associated with the subnet. Set this to C({}) to clear any tags. + type: dict +extends_documentation_fragment: cloudscale_ch.cloud.api_parameters +''' + +EXAMPLES = ''' +--- +- name: Ensure subnet exists + cloudscale_ch.cloud.subnet: + cidr: 172.16.0.0/24 + network: + uuid: 2db69ba3-1864-4608-853a-0771b6885a3a + api_token: xxxxxx + +- name: Ensure subnet exists + cloudscale_ch.cloud.subnet: + cidr: 192.168.1.0/24 + gateway_address: 192.168.1.1 + dns_servers: + - 192.168.1.10 + - 192.168.1.11 + network: + name: private + zone: lpg1 + api_token: xxxxxx + +- name: Ensure a subnet is absent + cloudscale_ch.cloud.subnet: + cidr: 172.16.0.0/24 + network: + name: private + zone: lpg1 + state: absent + api_token: xxxxxx +''' + +RETURN = ''' +--- +href: + description: API URL to get details about the subnet. + returned: success + type: str + sample: https://api.cloudscale.ch/v1/subnets/33333333-1864-4608-853a-0771b6885a3 +uuid: + description: The unique identifier for the subnet. + returned: success + type: str + sample: 33333333-1864-4608-853a-0771b6885a3 +cidr: + description: The CIDR of the subnet. + returned: success + type: str + sample: 172.16.0.0/24 +network: + description: The network object of the subnet. + returned: success + type: complex + contains: + href: + description: API URL to get details about the network. + returned: success + type: str + sample: https://api.cloudscale.ch/v1/networks/33333333-1864-4608-853a-0771b6885a3 + uuid: + description: The unique identifier for the network. + returned: success + type: str + sample: 33333333-1864-4608-853a-0771b6885a3 + name: + description: The name of the network. + returned: success + type: str + sample: my network + zone: + description: The zone the network is allocated in. + returned: success + type: dict + sample: { 'slug': 'rma1' } + version_added: 1.4.0 +gateway_address: + description: The gateway address of the subnet. + returned: success + type: str + sample: "192.168.42.1" +dns_servers: + description: List of DNS resolver IP addresses. + returned: success + type: list + sample: ["9.9.9.9", "149.112.112.112"] +state: + description: State of the subnet. + returned: success + type: str + sample: present +tags: + description: Tags associated with the subnet. + returned: success + type: dict + sample: { 'project': 'my project' } +''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import ( + AnsibleCloudscaleBase, + cloudscale_argument_spec, +) + + +class AnsibleCloudscaleSubnet(AnsibleCloudscaleBase): + + def __init__(self, module): + super(AnsibleCloudscaleSubnet, self).__init__( + module=module, + resource_name='subnets', + resource_key_name='cidr', + resource_create_param_keys=[ + 'cidr', + 'gateway_address', + 'dns_servers', + 'tags', + ], + resource_update_param_keys=[ + 'gateway_address', + 'dns_servers', + 'tags', + ], + ) + self._network = None + + def query_network(self, uuid=None): + if self._network is not None: + return self._network + + net_param = self._module.params['network'] + net_uuid = uuid or net_param['uuid'] + + if net_uuid is not None: + network = self._get('networks/%s' % net_uuid) + if not network: + self._module.fail_json(msg="Network with 'uuid' not found: %s" % net_uuid) + + elif net_param['name'] is not None: + networks_found = [] + networks = self._get('networks') + for network in networks or []: + # Skip networks in other zones + if net_param['zone'] is not None and network['zone']['slug'] != net_param['zone']: + continue + + if network.get('name') == net_param['name']: + networks_found.append(network) + + if not networks_found: + msg = "Network with 'name' not found: %s" % net_param['name'] + self._module.fail_json(msg=msg) + + elif len(networks_found) == 1: + network = networks_found[0] + + # We might have found more than one network with identical name + else: + msg = ("Multiple networks with 'name' not found: %s." + "Add the 'zone' to distinguish or use 'uuid' argument to specify the network." % net_param['name']) + self._module.fail_json(msg=msg) + + else: + self._module.fail_json(msg="Either Network UUID or name is required.") + + # For consistency, take a minimal network stub, but also include zone + self._network = dict() + for k, v in network.items(): + if k in ['name', 'uuid', 'href', 'zone']: + self._network[k] = v + + return self._network + + def create(self, resource): + resource['network'] = self.query_network() + + data = { + 'network': resource['network']['uuid'], + } + return super(AnsibleCloudscaleSubnet, self).create(resource, data) + + def update(self, resource): + # Resets to default values by the API + if self._module.params.get('reset'): + for key in ('dns_servers', 'gateway_address',): + # No need to reset if user set the param anyway. + if self._module.params.get(key) is None: + self._result['changed'] = True + patch_data = { + key: None + } + if not self._module.check_mode: + href = resource.get('href') + if not href: + self._module.fail_json(msg='Unable to update %s, no href found.' % key) + self._patch(href, patch_data, filter_none=False) + + if not self._module.check_mode: + resource = self.query() + + return super(AnsibleCloudscaleSubnet, self).update(resource) + + def get_result(self, resource): + if resource and 'network' in resource: + resource['network'] = self.query_network(uuid=resource['network']['uuid']) + return super(AnsibleCloudscaleSubnet, self).get_result(resource) + + +def main(): + argument_spec = cloudscale_argument_spec() + argument_spec.update(dict( + uuid=dict(type='str'), + cidr=dict(type='str'), + network=dict( + type='dict', + options=dict( + uuid=dict(type='str'), + name=dict(type='str'), + zone=dict(type='str'), + ), + ), + gateway_address=dict(type='str'), + dns_servers=dict(type='list', elements='str', default=None), + tags=dict(type='dict'), + reset=dict(type='bool', default=False), + state=dict(default='present', choices=['absent', 'present']), + )) + + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=(('cidr', 'uuid',),), + required_together=(('cidr', 'network',),), + required_if=(('state', 'present', ('cidr', 'network',),),), + supports_check_mode=True, + ) + + cloudscale_subnet = AnsibleCloudscaleSubnet(module) + + if module.params['state'] == 'absent': + result = cloudscale_subnet.absent() + else: + result = cloudscale_subnet.present() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/volume.py b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/volume.py new file mode 100644 index 00000000..892d783c --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/plugins/modules/volume.py @@ -0,0 +1,226 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (c) 2018, Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch> +# Copyright (c) 2019, René Moser <mail@renemoser.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = ''' +--- +module: volume +short_description: Manages volumes on the cloudscale.ch IaaS service. +description: + - Create, attach/detach, update and delete volumes on the cloudscale.ch IaaS service. +notes: + - To create a new volume at least the I(name) and I(size_gb) options + are required. + - A volume can be created and attached to a server in the same task. +author: + - Gaudenz Steinlin (@gaudenz) + - René Moser (@resmo) + - Denis Krienbühl (@href) +version_added: "1.0.0" +options: + state: + description: + - State of the volume. + default: present + choices: [ present, absent ] + type: str + name: + description: + - Name of the volume. Either name or UUID must be present to change an + existing volume. + type: str + uuid: + description: + - UUID of the volume. Either name or UUID must be present to change an + existing volume. + type: str + size_gb: + description: + - Size of the volume in GB. + type: int + type: + description: + - Type of the volume. Cannot be changed after creating the volume. + Defaults to C(ssd) on volume creation. + choices: [ ssd, bulk ] + type: str + zone: + description: + - Zone in which the volume resides (e.g. C(lgp1) or C(rma1)). Cannot be + changed after creating the volume. Defaults to the project default zone. + type: str + server_uuids: + description: + - UUIDs of the servers this volume is attached to. Set this to C([]) to + detach the volume. Currently a volume can only be attached to a + single server. + aliases: [ server_uuid ] + type: list + elements: str + tags: + description: + - Tags associated with the volume. Set this to C({}) to clear any tags. + type: dict +extends_documentation_fragment: cloudscale_ch.cloud.api_parameters +''' + +EXAMPLES = ''' +# Create a new SSD volume +- name: Create an SSD volume + cloudscale_ch.cloud.volume: + name: my_ssd_volume + zone: 'lpg1' + size_gb: 50 + api_token: xxxxxx + register: my_ssd_volume + +# Attach an existing volume to a server +- name: Attach volume to server + cloudscale_ch.cloud.volume: + uuid: my_ssd_volume.uuid + server_uuids: + - ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48 + api_token: xxxxxx + +# Create and attach a volume to a server +- name: Create and attach volume to server + cloudscale_ch.cloud.volume: + name: my_ssd_volume + zone: 'lpg1' + size_gb: 50 + server_uuids: + - ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48 + api_token: xxxxxx + +# Detach volume from server +- name: Detach volume from server + cloudscale_ch.cloud.volume: + uuid: my_ssd_volume.uuid + server_uuids: [] + api_token: xxxxxx + +# Delete a volume +- name: Delete volume + cloudscale_ch.cloud.volume: + name: my_ssd_volume + state: absent + api_token: xxxxxx +''' + +RETURN = ''' +href: + description: The API URL to get details about this volume. + returned: state == present + type: str + sample: https://api.cloudscale.ch/v1/volumes/2db69ba3-1864-4608-853a-0771b6885a3a +uuid: + description: The unique identifier for this volume. + returned: state == present + type: str + sample: 2db69ba3-1864-4608-853a-0771b6885a3a +name: + description: The display name of the volume. + returned: state == present + type: str + sample: my_ssd_volume +size_gb: + description: The size of the volume in GB. + returned: state == present + type: str + sample: 50 +type: + description: The type of the volume. + returned: state == present + type: str + sample: bulk +zone: + description: The zone of the volume. + returned: state == present + type: dict + sample: {'slug': 'lpg1'} +server_uuids: + description: The UUIDs of the servers this volume is attached to. + returned: state == present + type: list + sample: ['47cec963-fcd2-482f-bdb6-24461b2d47b1'] +state: + description: The current status of the volume. + returned: success + type: str + sample: present +tags: + description: Tags associated with the volume. + returned: state == present + type: dict + sample: { 'project': 'my project' } +''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import ( + AnsibleCloudscaleBase, + cloudscale_argument_spec, +) + + +class AnsibleCloudscaleVolume(AnsibleCloudscaleBase): + + def create(self, resource): + # Fail when missing params for creation + self._module.fail_on_missing_params(['name', 'size_gb']) + return super(AnsibleCloudscaleVolume, self).create(resource) + + +def main(): + argument_spec = cloudscale_argument_spec() + argument_spec.update(dict( + state=dict(type='str', default='present', choices=('present', 'absent')), + name=dict(type='str'), + uuid=dict(type='str'), + zone=dict(type='str'), + size_gb=dict(type='int'), + type=dict(type='str', choices=('ssd', 'bulk')), + server_uuids=dict(type='list', elements='str', aliases=['server_uuid']), + tags=dict(type='dict'), + )) + + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=(('name', 'uuid'),), + supports_check_mode=True, + ) + + cloudscale_volume = AnsibleCloudscaleVolume( + module, + resource_name='volumes', + resource_create_param_keys=[ + 'name', + 'type', + 'zone', + 'size_gb', + 'server_uuids', + 'tags', + ], + resource_update_param_keys=[ + 'name', + 'size_gb', + 'server_uuids', + 'tags', + ], + ) + + if module.params['state'] == 'absent': + result = cloudscale_volume.absent() + else: + result = cloudscale_volume.present() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/cloud-config-cloudscale.ini.template b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/cloud-config-cloudscale.ini.template new file mode 100644 index 00000000..5fa5d5fc --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/cloud-config-cloudscale.ini.template @@ -0,0 +1,2 @@ +[default] +cloudscale_api_token = @API_TOKEN diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/aliases new file mode 100644 index 00000000..136c05e0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/aliases @@ -0,0 +1 @@ +hidden diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/defaults/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/defaults/main.yml new file mode 100644 index 00000000..6a51b89c --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/defaults/main.yml @@ -0,0 +1,20 @@ +--- +# The image to use for test servers +cloudscale_test_image: 'debian-10' + +# Alternate test image to use if a different image is required +cloudscale_alt_test_image: 'ubuntu-20.04' + +# The flavor to use for test servers +cloudscale_test_flavor: 'flex-2' + +# SSH key to use for test servers +cloudscale_test_ssh_key: | + ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible + +# The zone to use to test servers +cloudscale_test_zone: 'lpg1' +cloudscale_test_alt_zone: 'rma1' + +# The region to use to request floating IPs +cloudscale_test_region: 'lpg' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_floating_ips.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_floating_ips.yml new file mode 100644 index 00000000..66360859 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_floating_ips.yml @@ -0,0 +1,19 @@ +--- +- name: List all floating IPs + uri: + url: 'https://api.cloudscale.ch/v1/floating-ips' + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + status_code: 200 + register: floating_ip_list + +- name: Remove all floating IPs created by this test run + cloudscale_ch.cloud.floating_ip: + # TODO: fix + # ip: '{{ item.network | ipaddr("address") }}' + ip: '{{ item.network.split("/")[0] }}' + state: 'absent' + when: "cloudscale_resource_prefix in (item.reverse_ptr | string ) or ('ansible_name' in item.tags and cloudscale_resource_prefix in item.tags['ansible_name'])" + with_items: '{{ floating_ip_list.json }}' + loop_control: + label: '{{ item.reverse_ptr }} ({{ item.network }})' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_networks.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_networks.yml new file mode 100644 index 00000000..e02c83b1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_networks.yml @@ -0,0 +1,17 @@ +--- +- name: List all networks + uri: + url: 'https://api.cloudscale.ch/v1/networks' + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + status_code: 200 + register: network_list + +- name: Remove all networks created by this test run + cloudscale_ch.cloud.network: + uuid: '{{ item.uuid }}' + state: absent + when: cloudscale_resource_prefix in item.name + with_items: '{{ network_list.json }}' + loop_control: + label: '{{ item.name }} ({{ item.uuid }})' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_objects_users.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_objects_users.yml new file mode 100644 index 00000000..2ddb1743 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_objects_users.yml @@ -0,0 +1,17 @@ +--- +- name: List all objects users + uri: + url: 'https://api.cloudscale.ch/v1/objects-users' + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + status_code: 200 + register: objects_user_list + +- name: Remove all objects users created by this test run + cloudscale_ch.cloud.objects_user: + id: '{{ item.id }}' + state: absent + when: cloudscale_resource_prefix in item.display_name + with_items: '{{ objects_user_list.json }}' + loop_control: + label: '{{ item.display_name }} ({{ item.id }})' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_server_groups.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_server_groups.yml new file mode 100644 index 00000000..cc85b137 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_server_groups.yml @@ -0,0 +1,17 @@ +--- +- name: List all server groups + uri: + url: 'https://api.cloudscale.ch/v1/server-groups' + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + status_code: 200 + register: server_group_list + +- name: Remove all server groups created by this test run + cloudscale_ch.cloud.server_group: + uuid: '{{ item.uuid }}' + state: absent + when: cloudscale_resource_prefix in item.name + with_items: '{{ server_group_list.json }}' + loop_control: + label: '{{ item.name }} ({{ item.uuid }})' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_servers.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_servers.yml new file mode 100644 index 00000000..d8c3a0fa --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_servers.yml @@ -0,0 +1,24 @@ +--- +- name: List all servers + uri: + url: 'https://api.cloudscale.ch/v1/servers' + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + status_code: 200 + register: server_list + until: server_list is not failed + retries: 5 + delay: 3 + +- name: Remove all servers created by this test run + cloudscale_ch.cloud.server: + uuid: '{{ item.uuid }}' + state: 'absent' + when: cloudscale_resource_prefix in item.name + with_items: '{{ server_list.json }}' + register: res + loop_control: + label: '{{ item.name }} ({{ item.uuid }})' + until: res is not failed + retries: 5 + delay: 3 diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_volumes.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_volumes.yml new file mode 100644 index 00000000..7ce17ba3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_volumes.yml @@ -0,0 +1,17 @@ +--- +- name: List all volumes + uri: + url: 'https://api.cloudscale.ch/v1/volumes' + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + status_code: 200 + register: volume_list + +- name: Remove all volumes created by this test run + cloudscale_ch.cloud.volume: + uuid: '{{ item.uuid }}' + state: 'absent' + when: cloudscale_resource_prefix in item.name + with_items: '{{ volume_list.json }}' + loop_control: + label: '{{ item.name }} ({{ item.uuid }})' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/main.yml new file mode 100644 index 00000000..fa0be6eb --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/main.yml @@ -0,0 +1,6 @@ +--- +# Password to use for test server +# This has to be set as a fact, otherwise a new password will be generated +# on every variable access. +- set_fact: + cloudscale_test_password: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') }}" diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/aliases new file mode 100644 index 00000000..c200a3d2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/aliases @@ -0,0 +1,2 @@ +cloud/cloudscale +unsupported diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/meta/main.yml new file mode 100644 index 00000000..2083f0e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - common diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/deprecation_warning.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/deprecation_warning.yml new file mode 100644 index 00000000..f950a8f0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/deprecation_warning.yml @@ -0,0 +1,12 @@ +--- +# TODO: To be removed with 2.0.0 +- name: Test deprecations + cloudscale_ch.cloud.floating_ip: + ip_version: 4 + register: floating_ip + check_mode: true +- name: Verify test deprecations + assert: + that: + - floating_ip is changed + - "'deprecations' in floating_ip" diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/floating_ip.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/floating_ip.yml new file mode 100644 index 00000000..d58d19b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/floating_ip.yml @@ -0,0 +1,158 @@ +- name: Request regional floating IP in check mode + cloudscale_ch.cloud.floating_ip: + name: '{{ cloudscale_resource_prefix }}-floating-ip' + server: '{{ test01.uuid }}' + ip_version: '{{ item.ip_version }}' + reverse_ptr: '{{ item.reverse_ptr | default(omit) }}' + prefix_length: '{{ item.prefix_length | default(omit) }}' + region: '{{ cloudscale_test_region }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + check_mode: true + register: floating_ip +- name: Verify request floating IP in check mode + assert: + that: + - floating_ip is changed + - floating_ip.state == 'absent' + +- name: Request regional floating IP + cloudscale_ch.cloud.floating_ip: + name: '{{ cloudscale_resource_prefix }}-floating-ip' + server: '{{ test01.uuid }}' + ip_version: '{{ item.ip_version }}' + reverse_ptr: '{{ item.reverse_ptr | default(omit) }}' + prefix_length: '{{ item.prefix_length | default(omit) }}' + region: '{{ cloudscale_test_region }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: floating_ip +- name: Verify request regional floating IP + assert: + that: + - floating_ip is changed + - floating_ip.region.slug == cloudscale_test_region + # - (item.ip_version == 4 and floating_ip.ip | ipv4) or (item.ip_version == 6 and floating_ip.ip | ipv6) + - floating_ip.server == test01.uuid + - floating_ip.tags.project == 'ansible-test' + - floating_ip.tags.stage == 'production' + - floating_ip.tags.sla == '24-7' + +- name: Request regional floating IP idempotence + cloudscale_ch.cloud.floating_ip: + name: '{{ cloudscale_resource_prefix }}-floating-ip' + server: '{{ test01.uuid }}' + ip_version: '{{ item.ip_version }}' + reverse_ptr: '{{ item.reverse_ptr | default(omit) }}' + prefix_length: '{{ item.prefix_length | default(omit) }}' + region: '{{ cloudscale_test_region }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: floating_ip_idempotence +- name: Verify request regional floating IP idempotence + assert: + that: + - floating_ip_idempotence is not changed + - floating_ip_idempotence.server == test01.uuid + - floating_ip.region.slug == cloudscale_test_region + - floating_ip.tags.project == 'ansible-test' + - floating_ip.tags.stage == 'production' + - floating_ip.tags.sla == '24-7' + +- name: Request regional floating IP different IP version in check mode + cloudscale_ch.cloud.floating_ip: + name: '{{ cloudscale_resource_prefix }}-floating-ip' + ip_version: '{{ 6 if item.ip_version == 4 else 4 }}' + reverse_ptr: '{{ item.reverse_ptr | default(omit) }}' + prefix_length: '{{ item.prefix_length | default(omit) }}' + region: '{{ cloudscale_test_region }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: floating_ip_version_differ + check_mode: true +- name: Verify Request regional floating IP different IP version in check mode + assert: + that: + - floating_ip_version_differ is changed + - not floating_ip_version_differ.network + +- name: Request global floating IP + cloudscale_ch.cloud.floating_ip: + name: '{{ cloudscale_resource_prefix }}-global-floating-ip' + ip_version: '{{ item.ip_version }}' + reverse_ptr: '{{ item.reverse_ptr | default(omit) }}' + prefix_length: '{{ item.prefix_length | default(omit) }}' + type: 'global' + register: global_floating_ip +- name: Verify global floating IP + assert: + that: + - global_floating_ip is changed + - global_floating_ip.region == None + - global_floating_ip.type == 'global' + # - (item.ip_version == 4 and global_floating_ip.ip | ipv4) or (item.ip_version == 6 and global_floating_ip.ip | ipv6) + - not global_floating_ip.server + +- name: Remove global floating IP + cloudscale_ch.cloud.floating_ip: + ip: '{{ global_floating_ip.ip }}' + state: 'absent' + register: global_floating_ip +- name: Verify release of global floating IP + assert: + that: + - global_floating_ip is changed + - global_floating_ip.state == 'absent' + +- name: Move floating IP to second server + cloudscale_ch.cloud.floating_ip: + server: '{{ test02.uuid }}' + ip: '{{ floating_ip.ip }}' + register: move_ip +- name: Verify move floating IPv4 to second server + assert: + that: + - move_ip is changed + - move_ip.server == test02.uuid + +- name: Remove floating IP in check mode + cloudscale_ch.cloud.floating_ip: + ip: '{{ floating_ip.ip }}' + state: 'absent' + register: release_ip + check_mode: true +- name: Verify Remove floating IP in check mode + assert: + that: + - release_ip is changed + - release_ip.state == 'present' + +- name: Remove floating IP + cloudscale_ch.cloud.floating_ip: + ip: '{{ floating_ip.ip }}' + state: 'absent' + register: release_ip +- name: Verify Remove floating IP + assert: + that: + - release_ip is changed + - release_ip.state == 'absent' + +- name: Remove floating IP idempotence + cloudscale_ch.cloud.floating_ip: + ip: '{{ floating_ip.ip }}' + state: 'absent' + register: release_ip +- name: Verify Remove floating IP idempotence + assert: + that: + - release_ip is not changed + - release_ip.state == 'absent' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/main.yml new file mode 100644 index 00000000..67be9eb5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/main.yml @@ -0,0 +1,38 @@ +--- +- import_tasks: deprecation_warning.yml + +- name: Cloudscale floating IP tests + block: + - name: Create a server + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test01' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + zone: '{{ cloudscale_test_zone }}' + register: test01 + + - name: Create a second server + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test02' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + zone: '{{ cloudscale_test_zone }}' + register: test02 + + - include_tasks: floating_ip.yml + loop: + - { 'ip_version': 4, 'reverse_ptr': '{{ cloudscale_resource_prefix }}-4.example.com' } + - { 'ip_version': 6, 'reverse_ptr': '{{ cloudscale_resource_prefix }}-6.example.com' } + - { 'ip_version': 6, 'prefix_length': 56 } + + - import_tasks: unassigned.yml + + always: + - import_role: + name: common + tasks_from: cleanup_servers + - import_role: + name: common + tasks_from: cleanup_floating_ips diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/unassigned.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/unassigned.yml new file mode 100644 index 00000000..4ee4ed08 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/unassigned.yml @@ -0,0 +1,27 @@ +--- +- name: Assign Floating IP to server test01 + cloudscale_ch.cloud.floating_ip: + name: '{{ cloudscale_resource_prefix }}-unassigned' + ip_version: 6 + server: '{{ test01.uuid }}' + reverse_ptr: '{{ cloudscale_resource_prefix }}-unassigned.example.com' + region: '{{ cloudscale_test_region }}' + register: floating_ip + +# The only way to have an unassigned floating IP is to delete the server +# where the floating IP is currently assigned. +- name: Delete server test01 + cloudscale_ch.cloud.server: + uuid: '{{ test01.uuid }}' + state: 'absent' + +- name: Do not fail if floating IP is unassigned + cloudscale_ch.cloud.floating_ip: + ip: '{{ floating_ip.ip }}' + register: floating_ip_not_fail +- name: Verify do not fail if floating IP is unassigned + assert: + that: + - floating_ip_not_fail is successful + - floating_ip_not_fail is not changed + - floating_ip_not_fail.server == None diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/aliases new file mode 100644 index 00000000..c200a3d2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/aliases @@ -0,0 +1,2 @@ +cloud/cloudscale +unsupported diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/meta/main.yml new file mode 100644 index 00000000..2083f0e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - common diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/failures.yml new file mode 100644 index 00000000..57efebd5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/failures.yml @@ -0,0 +1,44 @@ +--- +- name: Fail missing params + cloudscale_ch.cloud.network: + register: net + ignore_errors: True +- name: 'VERIFY: Fail name and UUID' + assert: + that: + - net is failed + +- name: Create two networks with the same name + uri: + url: 'https://api.cloudscale.ch/v1/networks' + method: POST + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + body: + name: '{{ cloudscale_resource_prefix }}-duplicate' + body_format: json + status_code: 201 + register: duplicate + with_sequence: count=2 + +- name: Try access to duplicate name + cloudscale_ch.cloud.network: + name: '{{ cloudscale_resource_prefix }}-duplicate' + register: net + ignore_errors: True +- name: 'VERIFY: Try access to duplicate name' + assert: + that: + - net is failed + - net.msg.startswith("More than one networks resource with 'name' exists") + +- name: Fail network creation with UUID + cloudscale_ch.cloud.network: + uuid: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48 + register: net + ignore_errors: True +- name: 'VERIFY: Fail network creation with UUID' + assert: + that: + - net is failed + - net.msg.startswith("state is present but all of the following are missing") diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/main.yml new file mode 100644 index 00000000..a89bd140 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/main.yml @@ -0,0 +1,8 @@ +--- +- block: + - import_tasks: failures.yml + - import_tasks: tests.yml + always: + - import_role: + name: common + tasks_from: cleanup_networks diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/tests.yml new file mode 100644 index 00000000..926a452d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/tests.yml @@ -0,0 +1,159 @@ +--- +- name: Create network in check mode + cloudscale_ch.cloud.network: + name: '{{ cloudscale_resource_prefix }}-net' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: net + check_mode: yes +- name: 'VERIFY: Create network in check mode' + assert: + that: + - net is changed + - net.name == '{{ cloudscale_resource_prefix }}-net' + - not net.uuid + +- name: Create network + cloudscale_ch.cloud.network: + name: '{{ cloudscale_resource_prefix }}-net' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: net +- name: 'VERIFY: Create network' + assert: + that: + - net is changed + - net.mtu == 9000 + - net.name == '{{ cloudscale_resource_prefix }}-net' + - net.zone.slug == cloudscale_test_zone + - net.uuid + - net.tags.project == 'ansible-test' + - net.tags.stage == 'production' + - net.tags.sla == '24-7' + +- name: Remember uuid + set_fact: + network_uuid: '{{ net.uuid }}' + +- name: Create network idempotence + cloudscale_ch.cloud.network: + name: '{{ cloudscale_resource_prefix }}-net' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: net +- name: 'VERIFY: Create network idempotence' + assert: + that: + - net is not changed + - net.name == '{{ cloudscale_resource_prefix }}-net' + - net.zone.slug == cloudscale_test_zone + - net.uuid == network_uuid + - net.tags.project == 'ansible-test' + - net.tags.stage == 'production' + - net.tags.sla == '24-7' + +- name: Update network in check mode + cloudscale_ch.cloud.network: + uuid: '{{ network_uuid }}' + name: '{{ cloudscale_resource_prefix }}-net2' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: net + check_mode: yes +- name: 'VERIFY: Update network in check mode' + assert: + that: + - net is changed + - net.name == '{{ cloudscale_resource_prefix }}-net' + - net.uuid == network_uuid + - net.zone.slug == cloudscale_test_zone + - net.tags.project == 'ansible-test' + - net.tags.stage == 'production' + - net.tags.sla == '24-7' + +- name: Update network + cloudscale_ch.cloud.network: + uuid: '{{ network_uuid }}' + name: '{{ cloudscale_resource_prefix }}-net2' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: net +- name: 'VERIFY: Update network' + assert: + that: + - net is changed + - net.name == '{{ cloudscale_resource_prefix }}-net2' + - net.uuid == network_uuid + - net.zone.slug == cloudscale_test_zone + - net.tags.project == 'ansible-test' + - net.tags.stage == 'staging' + - net.tags.sla == '8-5' + +- name: Update network idempotence + cloudscale_ch.cloud.network: + uuid: '{{ network_uuid }}' + name: '{{ cloudscale_resource_prefix }}-net2' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: net +- name: 'VERIFY: Update network idempotence' + assert: + that: + - net is not changed + - net.name == '{{ cloudscale_resource_prefix }}-net2' + - net.uuid == network_uuid + - net.zone.slug == cloudscale_test_zone + - net.tags.project == 'ansible-test' + - net.tags.stage == 'staging' + - net.tags.sla == '8-5' + +- name: Delete network in check mode + cloudscale_ch.cloud.network: + name: '{{ cloudscale_resource_prefix }}-net2' + state: absent + register: net + check_mode: yes +- name: 'VERIFY: Delete network in check mode' + assert: + that: + - net is changed + - net.name == '{{ cloudscale_resource_prefix }}-net2' + - net.uuid == network_uuid + +- name: Delete network + cloudscale_ch.cloud.network: + name: '{{ cloudscale_resource_prefix }}-net2' + state: absent + register: net +- name: 'VERIFY: Delete network' + assert: + that: + - net is changed + - net.name == '{{ cloudscale_resource_prefix }}-net2' + - net.uuid == network_uuid + +- name: Delete network idempotence + cloudscale_ch.cloud.network: + name: '{{ cloudscale_resource_prefix }}-net2' + state: absent + register: net +- name: 'VERIFY: Delete network idempotence' + assert: + that: + - net is not changed + - net.name == '{{ cloudscale_resource_prefix }}-net2' + - not net.uuid diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/aliases new file mode 100644 index 00000000..c200a3d2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/aliases @@ -0,0 +1,2 @@ +cloud/cloudscale +unsupported diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/meta/main.yml new file mode 100644 index 00000000..2083f0e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - common diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/failures.yml new file mode 100644 index 00000000..42d22d0d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/failures.yml @@ -0,0 +1,44 @@ +--- +- name: Fail missing params + cloudscale_ch.cloud.objects_user: + register: obj + ignore_errors: True +- name: 'VERIFY: Fail name and UUID' + assert: + that: + - obj is failed + +- name: Create two objects user with the same display_name + uri: + url: 'https://api.cloudscale.ch/v1/objects-users' + method: POST + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + body: + display_name: '{{ cloudscale_resource_prefix }}-duplicate' + body_format: json + status_code: 201 + register: duplicate + with_sequence: count=2 + +- name: Try access to duplicate display_name + cloudscale_ch.cloud.objects_user: + display_name: '{{ cloudscale_resource_prefix }}-duplicate' + register: obj + ignore_errors: True +- name: 'VERIFY: Try access to duplicate name' + assert: + that: + - obj is failed + - obj.msg.startswith("More than one objects-users resource with 'display_name' exists") + +- name: Fail creation with ID + cloudscale_ch.cloud.objects_user: + id: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48 + register: obj + ignore_errors: True +- name: 'VERIFY: Fail server group creation with ID' + assert: + that: + - obj is failed + - obj.msg.startswith("state is present but all of the following are missing") diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/main.yml new file mode 100644 index 00000000..69171378 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/main.yml @@ -0,0 +1,8 @@ +--- +- block: + - import_tasks: failures.yml + - import_tasks: tests.yml + always: + - import_role: + name: common + tasks_from: cleanup_objects_users diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/tests.yml new file mode 100644 index 00000000..b77921aa --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/tests.yml @@ -0,0 +1,151 @@ +--- +- name: Create objects user in check mode + cloudscale_ch.cloud.objects_user: + display_name: '{{ cloudscale_resource_prefix }}-obj' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: obj + check_mode: yes +- name: 'VERIFY: Create objects user in check mode' + assert: + that: + - obj is changed + - obj.display_name == '{{ cloudscale_resource_prefix }}-obj' + - not obj.id + +- name: Create objects user + cloudscale_ch.cloud.objects_user: + display_name: '{{ cloudscale_resource_prefix }}-obj' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: obj +- name: 'VERIFY: Create objects user' + assert: + that: + - obj is changed + - obj.display_name == '{{ cloudscale_resource_prefix }}-obj' + - obj.id + - obj.tags.project == 'ansible-test' + - obj.tags.stage == 'production' + - obj.tags.sla == '24-7' + +- name: Remember uuid + set_fact: + objects_user_id: '{{ obj.id }}' + +- name: Create objects user idempotence + cloudscale_ch.cloud.objects_user: + display_name: '{{ cloudscale_resource_prefix }}-obj' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: obj +- name: 'VERIFY: Create objects user idempotence' + assert: + that: + - obj is not changed + - obj.display_name == '{{ cloudscale_resource_prefix }}-obj' + - obj.id == objects_user_id + - obj.tags.project == 'ansible-test' + - obj.tags.stage == 'production' + - obj.tags.sla == '24-7' + +- name: Update objects user in check mode + cloudscale_ch.cloud.objects_user: + id: '{{ objects_user_id }}' + display_name: '{{ cloudscale_resource_prefix }}-obj2' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: obj + check_mode: yes +- name: 'VERIFY: Update objects user in check mode' + assert: + that: + - obj is changed + - obj.display_name == '{{ cloudscale_resource_prefix }}-obj' + - obj.id == objects_user_id + - obj.tags.project == 'ansible-test' + - obj.tags.stage == 'production' + - obj.tags.sla == '24-7' + +- name: Update objects user + cloudscale_ch.cloud.objects_user: + id: '{{ objects_user_id }}' + display_name: '{{ cloudscale_resource_prefix }}-obj2' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: obj +- name: 'VERIFY: Update objects user' + assert: + that: + - obj is changed + - obj.display_name == '{{ cloudscale_resource_prefix }}-obj2' + - obj.id == objects_user_id + - obj.tags.project == 'ansible-test' + - obj.tags.stage == 'staging' + - obj.tags.sla == '8-5' + +- name: Update objects user idempotence + cloudscale_ch.cloud.objects_user: + id: '{{ objects_user_id }}' + display_name: '{{ cloudscale_resource_prefix }}-obj2' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: obj +- name: 'VERIFY: Update objects user idempotence' + assert: + that: + - obj is not changed + - obj.display_name == '{{ cloudscale_resource_prefix }}-obj2' + - obj.id == objects_user_id + - obj.tags.project == 'ansible-test' + - obj.tags.stage == 'staging' + - obj.tags.sla == '8-5' + +- name: Delete objects user in check mode + cloudscale_ch.cloud.objects_user: + display_name: '{{ cloudscale_resource_prefix }}-obj2' + state: absent + register: obj + check_mode: yes +- name: 'VERIFY: Delete objects user in check mode' + assert: + that: + - obj is changed + - obj.display_name == '{{ cloudscale_resource_prefix }}-obj2' + - obj.id == objects_user_id + +- name: Delete objects user + cloudscale_ch.cloud.objects_user: + display_name: '{{ cloudscale_resource_prefix }}-obj2' + state: absent + register: obj +- name: 'VERIFY: Delete objects user' + assert: + that: + - obj is changed + - obj.display_name == '{{ cloudscale_resource_prefix }}-obj2' + - obj.id == objects_user_id + +- name: Delete objects user idempotence + cloudscale_ch.cloud.objects_user: + display_name: '{{ cloudscale_resource_prefix }}-obj2' + state: absent + register: obj +- name: 'VERIFY: Delete objects user idempotence' + assert: + that: + - obj is not changed + - obj.display_name == '{{ cloudscale_resource_prefix }}-obj2' + - not obj.id diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/aliases new file mode 100644 index 00000000..c200a3d2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/aliases @@ -0,0 +1,2 @@ +cloud/cloudscale +unsupported diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/defaults/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/defaults/main.yml new file mode 100644 index 00000000..6d8a0ff8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/defaults/main.yml @@ -0,0 +1,2 @@ +--- +cloudscale_test_flavor_2: flex-4 diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/meta/main.yml new file mode 100644 index 00000000..2083f0e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - common diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/failures.yml new file mode 100644 index 00000000..8d9ebee0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/failures.yml @@ -0,0 +1,53 @@ +--- +- name: Fail missing params + cloudscale_ch.cloud.server: + register: srv + ignore_errors: True +- name: 'VERIFY: Fail name and UUID' + assert: + that: + - srv is failed + +- name: Fail unexisting server group + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-group' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + password: '{{ cloudscale_test_password }}' + server_groups: '{{ cloudscale_resource_prefix }}-unexist-group' + ignore_errors: True + register: srv +- name: 'VERIFY: Fail unexisting server group' + assert: + that: + - srv is failed + - srv.msg.startswith('Server group name or UUID not found') + +- name: Create two server groups with the same name + uri: + url: https://api.cloudscale.ch/v1/server-groups + method: POST + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + body: + name: '{{ cloudscale_resource_prefix }}-duplicate' + type: anti-affinity + body_format: json + status_code: 201 + register: duplicate + with_sequence: count=2 + +- name: Try to use server groups with identical name + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-group' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + password: '{{ cloudscale_test_password }}' + server_groups: '{{ cloudscale_resource_prefix }}-duplicate' + ignore_errors: True + register: srv +- name: 'VERIFY: Fail unexisting server group' + assert: + that: + - srv is failed + - srv.msg.startswith('More than one server group with name exists') diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/main.yml new file mode 100644 index 00000000..90e35985 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- block: + - import_tasks: failures.yml + - import_tasks: tests.yml + always: + - import_role: + name: common + tasks_from: cleanup_servers + - import_role: + name: common + tasks_from: cleanup_server_groups diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/tests.yml new file mode 100644 index 00000000..5113ba53 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/tests.yml @@ -0,0 +1,676 @@ +--- +- name: Setup server groups + cloudscale_ch.cloud.server_group: + name: '{{ cloudscale_resource_prefix }}-group-{{ item }}' + type: anti-affinity + zone: '{{ cloudscale_test_zone }}' + with_sequence: count=2 + +- name: Test create a running server in check mode + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: server + check_mode: yes +- name: Verify create a running server in check mode + assert: + that: + - server is changed + - server.state == 'absent' + +- name: Test create a running server + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: server +- name: Verify create a running server + assert: + that: + - server is changed + - server.state == 'running' + - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + - server.zone.slug == '{{ cloudscale_test_zone }}' + - server.tags.project == 'ansible-test' + - server.tags.stage == 'production' + - server.tags.sla == '24-7' + +- name: Test create a running server idempotence + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: server +- name: Verify create a running server idempotence + assert: + that: + - server is not changed + - server.state == 'running' + - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + - server.zone.slug == '{{ cloudscale_test_zone }}' + - server.tags.project == 'ansible-test' + - server.tags.stage == 'production' + - server.tags.sla == '24-7' + +- name: Test update tags in check mode + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: server + check_mode: yes +- name: Verify update tags in check mode + assert: + that: + - server is changed + - server.state == 'running' + - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + - server.tags.project == 'ansible-test' + - server.tags.stage == 'production' + - server.tags.sla == '24-7' + +- name: Test update tags + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: server +- name: Verify update tags + assert: + that: + - server is changed + - server.state == 'running' + - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + - server.tags.project == 'ansible-test' + - server.tags.stage == 'staging' + - server.tags.sla == '8-5' + +- name: Test update tags idempotence + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: server +- name: Verify update tags idempotence + assert: + that: + - server is not changed + - server.state == 'running' + - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + - server.tags.project == 'ansible-test' + - server.tags.stage == 'staging' + - server.tags.sla == '8-5' + +- name: Test omit tags idempotence + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + register: server +- name: Verify update tags idempotence + assert: + that: + - server is not changed + - server.state == 'running' + - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + - server.tags.project == 'ansible-test' + - server.tags.stage == 'staging' + - server.tags.sla == '8-5' + +- name: Test delete tags + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + tags: {} + register: server +- name: Verify delete tags + assert: + that: + - server is changed + - server.state == 'running' + - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + - not server.tags + +- name: Test delete tags idempotence + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + tags: {} + register: server +- name: Verify delete tags idempotence + assert: + that: + - server is not changed + - server.state == 'running' + - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + - not server.tags + +- name: Test update flavor of a running server without force in check mode + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor_2 }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + force: no + register: server + check_mode: yes +- name: Verify update flavor of a running server without force in check mode + assert: + that: + - server is not changed + - server.state == 'running' + - server.flavor.slug == '{{ cloudscale_test_flavor }}' + - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + +- name: Test update flavor of a running server without force + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor_2 }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + force: no + register: server +- name: Verify update flavor of a running server without force + assert: + that: + - server is not changed + - server.state == 'running' + - server.flavor.slug == '{{ cloudscale_test_flavor }}' + - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + +- name: Test update flavor of a running server without force idempotence + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor_2 }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + force: no + register: server +- name: Verify update flavor of a running server without force idempotence + assert: + that: + - server is not changed + - server.state == 'running' + - server.flavor.slug == '{{ cloudscale_test_flavor }}' + - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + +- name: Test update flavor and name of a running server without force in check mode + cloudscale_ch.cloud.server: + uuid: '{{ server.uuid }}' + name: '{{ cloudscale_resource_prefix }}-test-renamed' + flavor: '{{ cloudscale_test_flavor_2 }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + force: no + register: server + check_mode: yes +- name: Verify update flavor and name of a running server without force in check mode + assert: + that: + - server is changed + - server.state == 'running' + - server.flavor.slug == '{{ cloudscale_test_flavor }}' + - server.name == '{{ cloudscale_resource_prefix }}-test' + +- name: Test update flavor and name of a running server without force + cloudscale_ch.cloud.server: + uuid: '{{ server.uuid }}' + name: '{{ cloudscale_resource_prefix }}-test-renamed' + flavor: '{{ cloudscale_test_flavor_2 }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + force: no + register: server +- name: Verify update flavor and name of a running server without force + assert: + that: + - server is changed + - server.state == 'running' + - server.flavor.slug == '{{ cloudscale_test_flavor }}' + - server.name == '{{ cloudscale_resource_prefix }}-test-renamed' + +- name: Test update flavor and name of a running server without force idempotence + cloudscale_ch.cloud.server: + uuid: '{{ server.uuid }}' + name: '{{ cloudscale_resource_prefix }}-test-renamed' + flavor: '{{ cloudscale_test_flavor_2 }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + force: no + register: server +- name: Verify update flavor and name of a running server without force idempotence + assert: + that: + - server is not changed + - server.state == 'running' + - server.flavor.slug == '{{ cloudscale_test_flavor }}' + - server.name == '{{ cloudscale_resource_prefix }}-test-renamed' + +- name: Test update flavor of a running server with force in check mode + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-renamed' + flavor: '{{ cloudscale_test_flavor_2 }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + force: yes + register: server + check_mode: yes +- name: Verify update flavor of a running server with force in check mode + assert: + that: + - server is changed + - server.state == 'running' + - server.flavor.slug == '{{ cloudscale_test_flavor }}' + - server.name == '{{ cloudscale_resource_prefix }}-test-renamed' + +- name: Test update flavor of a running server with force + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-renamed' + flavor: '{{ cloudscale_test_flavor_2 }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + force: yes + register: server +- name: Verify update flavor of a running server with force + assert: + that: + - server is changed + - server.state == 'running' + - server.flavor.slug == '{{ cloudscale_test_flavor_2 }}' + - server.name == '{{ cloudscale_resource_prefix }}-test-renamed' + +- name: Test update a running server with force idempotence + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-renamed' + flavor: '{{ cloudscale_test_flavor_2 }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + force: yes + register: server +- name: Verify update flavor of a running server with force idempotence + assert: + that: + - server is not changed + - server.state == 'running' + - server.flavor.slug == '{{ cloudscale_test_flavor_2 }}' + - server.name == '{{ cloudscale_resource_prefix }}-test-renamed' + +- name: Remember uuid of running server for anti affinity + set_fact: + running_server_uuid: '{{ server.uuid }}' + +- name: Test create server stopped in anti affinity and private network only in check mode + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-stopped' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + zone: '{{ cloudscale_test_zone }}' + use_public_network: no + use_private_network: yes + state: stopped + check_mode: yes + register: server_stopped +- name: Verify create server stopped in anti affinity and private network only in check mode + assert: + that: + - server_stopped is changed + - server_stopped.state == 'absent' + +- name: Test create server stopped in anti affinity and private network only + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-stopped' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + zone: '{{ cloudscale_test_zone }}' + use_public_network: no + use_private_network: yes + state: stopped + register: server_stopped +- name: Verify create server stopped in anti affinity and private network only + assert: + that: + - server_stopped is changed + - server_stopped.state == 'stopped' + - server_stopped.zone.slug == '{{ cloudscale_test_zone }}' + - server_stopped.anti_affinity_with.0.uuid == running_server_uuid + - server_stopped.interfaces.0.type == 'private' + - server_stopped.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + +- name: Test create server stopped in anti affinity and private network only idempotence + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-stopped' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-1' + zone: '{{ cloudscale_test_zone }}' + use_public_network: no + use_private_network: yes + state: stopped + register: server_stopped +- name: Verify create server stopped in anti affinity and private network only idempotence + assert: + that: + - server_stopped is not changed + - server_stopped.state == 'stopped' + - server_stopped.zone.slug == '{{ cloudscale_test_zone }}' + - server_stopped.anti_affinity_with.0.uuid == running_server_uuid + - server_stopped.interfaces.0.type == 'private' + - server_stopped.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + +- name: Test change server group not changed + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-stopped' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + server_groups: '{{ cloudscale_resource_prefix }}-group-2' + use_public_network: no + use_private_network: yes + state: stopped + register: server_stopped +- name: Verify Test update server group not changed + assert: + that: + - server_stopped is not changed + - server_stopped.state == 'stopped' + - server_stopped.zone.slug == '{{ cloudscale_test_zone }}' + - server_stopped.anti_affinity_with.0.uuid == running_server_uuid + - server_stopped.interfaces.0.type == 'private' + - server_stopped.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1' + +- name: Test create server with password in check mode + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-password' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + password: '{{ cloudscale_test_password }}' + check_mode: yes + register: server_password +- name: Verify create server with password in check mode + assert: + that: + - server_password is changed + - server_password.state == 'absent' + # Verify password is not logged + - server_password.diff.after.password != cloudscale_test_password + +- name: Test create server with password + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-password' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + password: '{{ cloudscale_test_password }}' + register: server_password +- name: Verify create server with password + assert: + that: + - server_password is changed + - server_password.state == 'running' + # Verify password is not logged + - server_password.diff.after.password != cloudscale_test_password + +- name: Test create server with password idempotence + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-password' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + password: '{{ cloudscale_test_password }}' + register: server_password +- name: Verify create server with password idempotence + assert: + that: + - server_password is not changed + - server_password.state == 'running' + +- name: Test create server failure without required parameters + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-failed' + register: server_failed + ignore_errors: yes +- name: Verify create server failure without required parameters + assert: + that: + - server_failed is failed + - "'Failure while calling the cloudscale.ch API with POST' in server_failed.msg" + - "'This field is required.' in server_failed.fetch_url_info.body" + +- name: Test stop running server in check mode + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-renamed' + state: stopped + check_mode: yes + register: server +- name: Verify stop running server in check mode + assert: + that: + - server is changed + - server.state == 'running' + +- name: Test stop running server + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-renamed' + state: stopped + register: server +- name: Verify stop running server + assert: + that: + - server is changed + - server.state == 'stopped' + +- name: Test stop running server idempotence + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test-renamed' + state: 'stopped' + register: server +- name: Verify stop running server idempotence + assert: + that: + - server is not changed + - server.state == 'stopped' + +- name: Test update a stopped server in check mode + cloudscale_ch.cloud.server: + uuid: '{{ server.uuid }}' + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + state: stopped + register: server + check_mode: yes +- name: Verify update a stopped server in check mode + assert: + that: + - server is changed + - server.state == 'stopped' + - server.flavor.slug == '{{ cloudscale_test_flavor_2 }}' + - server.name == '{{ cloudscale_resource_prefix }}-test-renamed' + +- name: Test update a stopped server without force + cloudscale_ch.cloud.server: + uuid: '{{ server.uuid }}' + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + state: stopped + register: server +- name: Verify update a stopped server without force + assert: + that: + - server is changed + - server.state == 'stopped' + - server.flavor.slug == '{{ cloudscale_test_flavor }}' + - server.name == '{{ cloudscale_resource_prefix }}-test' + +- name: Test update a stopped server idempotence + cloudscale_ch.cloud.server: + uuid: '{{ server.uuid }}' + name: '{{ cloudscale_resource_prefix }}-test' + flavor: '{{ cloudscale_test_flavor }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + state: stopped + register: server +- name: Verify update a stopped server idempotence + assert: + that: + - server is not changed + - server.state == 'stopped' + - server.flavor.slug == '{{ cloudscale_test_flavor }}' + - server.name == '{{ cloudscale_resource_prefix }}-test' + +- name: Test server running in check mode + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + state: running + register: server + check_mode: yes +- name: Verify server running in check mode + assert: + that: + - server is changed + - server.state == 'stopped' + +- name: Test server running + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + state: running + register: server +- name: Verify server running + assert: + that: + - server is changed + - server.state == 'running' + +- name: Test server running idempotence + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + state: running + register: server +- name: Verify server running idempotence + assert: + that: + - server is not changed + - server.state == 'running' + +- name: Test running server deletion by name in check mode + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + state: absent + register: server + check_mode: yes +- name: Verify running server deletion by name in check mode + assert: + that: + - server is changed + - server.state == 'running' + +- name: Test running server deletion by name + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + state: absent + register: server +- name: Verify running server deletion by name + assert: + that: + - server is changed + - server.state == 'absent' + +- name: Test running server deletion by name idempotence + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-test' + state: absent + register: server +- name: Verify running server deletion by name idempotence + assert: + that: + - server is not changed + - server.state == 'absent' + +- name: Test stopped server deletion by uuid in check mode + cloudscale_ch.cloud.server: + uuid: '{{ server_stopped.uuid }}' + state: absent + register: server_stopped + check_mode: yes +- name: Verify stopped server deletion by uuid in check mode + assert: + that: + - server_stopped is changed + - server_stopped.state == 'stopped' + +- name: Test stopped server deletion by uuid + cloudscale_ch.cloud.server: + uuid: '{{ server_stopped.uuid }}' + state: absent + register: server_stopped +- name: Verify stopped server deletion by uuid + assert: + that: + - server_stopped is changed + - server_stopped.state == 'absent' + +- name: Test stopped server deletion by uuid idempotence + cloudscale_ch.cloud.server: + uuid: '{{ server_stopped.uuid }}' + state: absent + register: server_stopped +- name: Verify stopped server deletion by uuid idempotence + assert: + that: + - server_stopped is not changed + - server_stopped.state == 'absent' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/aliases new file mode 100644 index 00000000..c200a3d2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/aliases @@ -0,0 +1,2 @@ +cloud/cloudscale +unsupported diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/meta/main.yml new file mode 100644 index 00000000..2083f0e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - common diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/failures.yml new file mode 100644 index 00000000..b02ee031 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/failures.yml @@ -0,0 +1,45 @@ +--- +- name: Fail missing params + cloudscale_ch.cloud.server_group: + register: grp + ignore_errors: True +- name: 'VERIFY: Fail name and UUID' + assert: + that: + - grp is failed + +- name: Create two server groups with the same name + uri: + url: 'https://api.cloudscale.ch/v1/server-groups' + method: POST + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + body: + name: '{{ cloudscale_resource_prefix }}-duplicate' + type: 'anti-affinity' + body_format: json + status_code: 201 + register: duplicate + with_sequence: count=2 + +- name: Try access to duplicate name + cloudscale_ch.cloud.server_group: + name: '{{ cloudscale_resource_prefix }}-duplicate' + register: grp + ignore_errors: True +- name: 'VERIFY: Try access to duplicate name' + assert: + that: + - grp is failed + - grp.msg.startswith("More than one server-groups resource with 'name' exists") + +- name: Fail server group creation with UUID + cloudscale_ch.cloud.server_group: + uuid: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48 + register: grp + ignore_errors: True +- name: 'VERIFY: Fail server group creation with UUID' + assert: + that: + - grp is failed + - grp.msg.startswith("state is present but all of the following are missing") diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/main.yml new file mode 100644 index 00000000..44fe7303 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/main.yml @@ -0,0 +1,8 @@ +--- +- block: + - import_tasks: failures.yml + - import_tasks: tests.yml + always: + - import_role: + name: common + tasks_from: cleanup_server_groups diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/tests.yml new file mode 100644 index 00000000..018b85a5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/tests.yml @@ -0,0 +1,180 @@ +--- +- name: Create server group in check mode + cloudscale_ch.cloud.server_group: + name: '{{ cloudscale_resource_prefix }}-grp' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: grp + check_mode: yes +- name: 'VERIFY: Create server group in check mode' + assert: + that: + - grp is changed + - grp.name == '{{ cloudscale_resource_prefix }}-grp' + - not grp.uuid + +- name: Create server group + cloudscale_ch.cloud.server_group: + name: '{{ cloudscale_resource_prefix }}-grp' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: grp +- name: 'VERIFY: Create server group' + assert: + that: + - grp is changed + - grp.type == 'anti-affinity' + - grp.name == '{{ cloudscale_resource_prefix }}-grp' + - grp.zone.slug == '{{ cloudscale_test_zone }}' + - grp.uuid + - grp.tags.project == 'ansible-test' + - grp.tags.stage == 'production' + - grp.tags.sla == '24-7' + +- name: Remember uuid + set_fact: + server_group_uuid: '{{ grp.uuid }}' + +- name: Create server group idempotence + cloudscale_ch.cloud.server_group: + name: '{{ cloudscale_resource_prefix }}-grp' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: grp +- name: 'VERIFY: Create server group idempotence' + assert: + that: + - grp is not changed + - grp.name == '{{ cloudscale_resource_prefix }}-grp' + - grp.zone.slug == '{{ cloudscale_test_zone }}' + - grp.uuid == server_group_uuid + - grp.tags.project == 'ansible-test' + - grp.tags.stage == 'production' + - grp.tags.sla == '24-7' + +- name: Create server group with same name in alt zone + cloudscale_ch.cloud.server_group: + name: '{{ cloudscale_resource_prefix }}-grp' + zone: '{{ cloudscale_test_alt_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: grp +- name: 'VERIFY:Create server group with same name in alt zone' + assert: + that: + - grp is changed + - grp.name == '{{ cloudscale_resource_prefix }}-grp' + - grp.zone.slug == '{{ cloudscale_test_alt_zone }}' + - grp.uuid != server_group_uuid + - grp.tags.project == 'ansible-test' + - grp.tags.stage == 'production' + - grp.tags.sla == '24-7' + +- name: Update server group in check mode + cloudscale_ch.cloud.server_group: + uuid: '{{ server_group_uuid }}' + name: '{{ cloudscale_resource_prefix }}-grp2' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: grp + check_mode: yes +- name: 'VERIFY: Update server group in check mode' + assert: + that: + - grp is changed + - grp.name == '{{ cloudscale_resource_prefix }}-grp' + - grp.uuid == server_group_uuid + - grp.zone.slug == '{{ cloudscale_test_zone }}' + - grp.tags.project == 'ansible-test' + - grp.tags.stage == 'production' + - grp.tags.sla == '24-7' + +- name: Update server group + cloudscale_ch.cloud.server_group: + uuid: '{{ server_group_uuid }}' + name: '{{ cloudscale_resource_prefix }}-grp2' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: grp +- name: 'VERIFY: Update server group' + assert: + that: + - grp is changed + - grp.name == '{{ cloudscale_resource_prefix }}-grp2' + - grp.uuid == server_group_uuid + - grp.zone.slug == '{{ cloudscale_test_zone }}' + - grp.tags.project == 'ansible-test' + - grp.tags.stage == 'staging' + - grp.tags.sla == '8-5' + +- name: Update server group idempotence + cloudscale_ch.cloud.server_group: + uuid: '{{ server_group_uuid }}' + name: '{{ cloudscale_resource_prefix }}-grp2' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: grp +- name: 'VERIFY: Update server group idempotence' + assert: + that: + - grp is not changed + - grp.name == '{{ cloudscale_resource_prefix }}-grp2' + - grp.uuid == server_group_uuid + - grp.zone.slug == '{{ cloudscale_test_zone }}' + - grp.tags.project == 'ansible-test' + - grp.tags.stage == 'staging' + - grp.tags.sla == '8-5' + +- name: Delete server group in check mode + cloudscale_ch.cloud.server_group: + name: '{{ cloudscale_resource_prefix }}-grp2' + state: absent + register: grp + check_mode: yes +- name: 'VERIFY: Delete server group in check mode' + assert: + that: + - grp is changed + - grp.name == '{{ cloudscale_resource_prefix }}-grp2' + - grp.uuid == server_group_uuid + +- name: Delete server group + cloudscale_ch.cloud.server_group: + name: '{{ cloudscale_resource_prefix }}-grp2' + state: absent + register: grp +- name: 'VERIFY: Delete server group' + assert: + that: + - grp is changed + - grp.name == '{{ cloudscale_resource_prefix }}-grp2' + - grp.uuid == server_group_uuid + +- name: Delete server group idempotence + cloudscale_ch.cloud.server_group: + name: '{{ cloudscale_resource_prefix }}-grp2' + state: absent + register: grp +- name: 'VERIFY: Delete server group idempotence' + assert: + that: + - grp is not changed + - grp.name == '{{ cloudscale_resource_prefix }}-grp2' + - not grp.uuid diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/aliases new file mode 100644 index 00000000..c200a3d2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/aliases @@ -0,0 +1,2 @@ +cloud/cloudscale +unsupported diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/defaults/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/defaults/main.yml new file mode 100644 index 00000000..67d807cd --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/defaults/main.yml @@ -0,0 +1,2 @@ +--- +cloudscale_subnet_cidr: 192.168.23.0/24 diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/meta/main.yml new file mode 100644 index 00000000..2083f0e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - common diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/failures.yml new file mode 100644 index 00000000..c28f5ab0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/failures.yml @@ -0,0 +1,82 @@ +--- +- name: Fail missing params + cloudscale_ch.cloud.subnet: + register: snet + ignore_errors: True +- name: 'VERIFY: Fail missing params' + assert: + that: + - snet is failed + - snet.msg.startswith("one of the following is required") + +- name: Fail creation with UUID + cloudscale_ch.cloud.subnet: + uuid: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48 + register: snet + ignore_errors: True +- name: 'VERIFY: Fail creation with UUID' + assert: + that: + - snet is failed + - snet.msg.startswith("state is present but all of the following are missing") + +- name: Fail creation unknown network name + cloudscale_ch.cloud.subnet: + cidr: '{{ cloudscale_subnet_cidr }}' + network: + name: '{{ cloudscale_resource_prefix }}-does-not-exist' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: snet + ignore_errors: True +- name: 'VERIFY: Fail creation unknown network name' + assert: + that: + - snet is failed + - snet.msg.startswith("Network with 'name' not found") + +- name: Fail creation unknown network uuid + cloudscale_ch.cloud.subnet: + cidr: '{{ cloudscale_subnet_cidr }}' + network: + uuid: 'f0bb5270-f66c-41d6-ac3b-a223cd280ced' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: snet + ignore_errors: True +- name: 'VERIFY: Fail creation unknown network uuid' + assert: + that: + - snet is failed + - snet.msg.startswith("Network with 'uuid' not found") + +- name: Create two networks with the same name + uri: + url: 'https://api.cloudscale.ch/v1/networks' + method: POST + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + body: + name: '{{ cloudscale_resource_prefix }}-duplicate' + auto_create_ipv4_subnet: False + body_format: json + status_code: 201 + register: duplicate + with_sequence: count=2 + +- name: Try access to duplicate network name + cloudscale_ch.cloud.subnet: + cidr: '{{ cloudscale_subnet_cidr }}' + network: + name: '{{ cloudscale_resource_prefix }}-duplicate' + register: snet + ignore_errors: True +- name: 'VERIFY: Try access to duplicate network name' + assert: + that: + - snet is failed + - snet.msg.startswith("Multiple networks with 'name' not found") diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/main.yml new file mode 100644 index 00000000..54078ffa --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/main.yml @@ -0,0 +1,10 @@ +--- +- name: Subnet test run + block: + - import_tasks: failures.yml + - import_tasks: setup.yml + - import_tasks: tests.yml + always: + - import_role: + name: common + tasks_from: cleanup_networks diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/setup.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/setup.yml new file mode 100644 index 00000000..4662f9e7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/setup.yml @@ -0,0 +1,13 @@ +--- +- name: Setup network in alt zone + cloudscale_ch.cloud.network: + name: '{{ cloudscale_resource_prefix }}-net' + auto_create_ipv4_subnet: false + zone: '{{ cloudscale_test_alt_zone }}' + +- name: Setup network in test zone + cloudscale_ch.cloud.network: + name: '{{ cloudscale_resource_prefix }}-net' + auto_create_ipv4_subnet: false + zone: '{{ cloudscale_test_zone }}' + register: net diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/tests.yml new file mode 100644 index 00000000..5e0ff6b1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/tests.yml @@ -0,0 +1,243 @@ +--- +- name: Create subnet in check mode + cloudscale_ch.cloud.subnet: + cidr: '{{ cloudscale_subnet_cidr }}' + network: + name: '{{ cloudscale_resource_prefix }}-net' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: snet + check_mode: yes +- name: 'VERIFY: Create subnet in check mode' + assert: + that: + - snet is changed + - snet.cidr == cloudscale_subnet_cidr + - not snet.uuid + +- name: Create subnet + cloudscale_ch.cloud.subnet: + cidr: '{{ cloudscale_subnet_cidr }}' + network: + name: '{{ cloudscale_resource_prefix }}-net' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: snet +- name: 'VERIFY: Create subnet' + assert: + that: + - snet is changed + - snet.cidr == cloudscale_subnet_cidr + - snet.uuid + - snet.tags.project == 'ansible-test' + - snet.tags.stage == 'production' + - snet.tags.sla == '24-7' + - snet.network.zone.slug == cloudscale_test_zone + +- name: Remember subnet uuid + set_fact: + subnet_uuid: '{{ snet.uuid }}' + +- name: Create subnet idempotence + cloudscale_ch.cloud.subnet: + cidr: '{{ cloudscale_subnet_cidr }}' + network: + name: '{{ cloudscale_resource_prefix }}-net' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: production + sla: 24-7 + register: snet +- name: 'VERIFY: Create subnet idempotence' + assert: + that: + - snet is not changed + - snet.cidr == cloudscale_subnet_cidr + - snet.uuid == subnet_uuid + - snet.tags.project == 'ansible-test' + - snet.tags.stage == 'production' + - snet.tags.sla == '24-7' + - snet.network.zone.slug == cloudscale_test_zone + +- name: Update subnet in check mode + cloudscale_ch.cloud.subnet: + cidr: '{{ cloudscale_subnet_cidr }}' + network: + name: '{{ cloudscale_resource_prefix }}-net' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: snet + check_mode: yes +- name: 'VERIFY: Update subnet in check mode' + assert: + that: + - snet is changed + - snet.cidr == cloudscale_subnet_cidr + - snet.uuid == subnet_uuid + - snet.tags.project == 'ansible-test' + - snet.tags.stage == 'production' + - snet.tags.sla == '24-7' + - snet.network.zone.slug == cloudscale_test_zone + +- name: Update subnet + cloudscale_ch.cloud.subnet: + cidr: '{{ cloudscale_subnet_cidr }}' + network: + name: '{{ cloudscale_resource_prefix }}-net' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: snet +- name: 'VERIFY: Update subnet' + assert: + that: + - snet is changed + - snet.cidr == cloudscale_subnet_cidr + - snet.uuid == subnet_uuid + - snet.tags.project == 'ansible-test' + - snet.tags.stage == 'staging' + - snet.tags.sla == '8-5' + - snet.network.zone.slug == cloudscale_test_zone + +- name: Update subnet idempotence + cloudscale_ch.cloud.subnet: + uuid: '{{ subnet_uuid }}' + cidr: '{{ cloudscale_subnet_cidr }}' + network: + name: '{{ cloudscale_resource_prefix }}-net' + zone: '{{ cloudscale_test_zone }}' + tags: + project: ansible-test + stage: staging + sla: 8-5 + register: snet +- name: 'VERIFY: Update subnet idempotence' + assert: + that: + - snet is not changed + - snet.cidr == cloudscale_subnet_cidr + - snet.uuid == subnet_uuid + - snet.tags.project == 'ansible-test' + - snet.tags.stage == 'staging' + - snet.tags.sla == '8-5' + - snet.network.zone.slug == cloudscale_test_zone + +- name: Update subnet by Network UUID + cloudscale_ch.cloud.subnet: + cidr: '{{ cloudscale_subnet_cidr }}' + network: + uuid: '{{ net.uuid }}' + dns_servers: + - 9.9.9.9 + - 8.8.8.8 + gateway_address: 192.168.23.1 + register: snet +- name: 'VERIFY: Update subnet' + assert: + that: + - snet is changed + - snet.cidr == cloudscale_subnet_cidr + - snet.uuid == subnet_uuid + - snet.dns_servers == ['9.9.9.9', '8.8.8.8'] + - snet.gateway_address == '192.168.23.1' + - snet.tags.project == 'ansible-test' + - snet.tags.stage == 'staging' + - snet.tags.sla == '8-5' + - snet.network.zone.slug == cloudscale_test_zone + +- name: Update subnet by Network UUID idempotence + cloudscale_ch.cloud.subnet: + cidr: '{{ cloudscale_subnet_cidr }}' + network: + uuid: '{{ net.uuid }}' + dns_servers: + - 9.9.9.9 + - 8.8.8.8 + gateway_address: 192.168.23.1 + register: snet +- name: 'VERIFY: Update subnet' + assert: + that: + - snet is not changed + - snet.cidr == cloudscale_subnet_cidr + - snet.uuid == subnet_uuid + - snet.dns_servers == ['9.9.9.9', '8.8.8.8'] + - snet.gateway_address == '192.168.23.1' + - snet.tags.project == 'ansible-test' + - snet.tags.stage == 'staging' + - snet.tags.sla == '8-5' + - snet.network.zone.slug == cloudscale_test_zone + +- name: Reset DNS servers in subnet + cloudscale_ch.cloud.subnet: + cidr: '{{ cloudscale_subnet_cidr }}' + network: + uuid: '{{ net.uuid }}' + gateway_address: 192.168.23.1 + reset: true + register: snet +- name: 'VERIFY: Update subnet' + assert: + that: + - snet is changed + - snet.cidr == cloudscale_subnet_cidr + - snet.uuid == subnet_uuid + - snet.dns_servers != ['9.9.9.9', '8.8.8.8'] + - snet.gateway_address == '192.168.23.1' + - snet.tags.project == 'ansible-test' + - snet.tags.stage == 'staging' + - snet.tags.sla == '8-5' + - snet.network.zone.slug == cloudscale_test_zone + +- name: Delete subnet in check mode + cloudscale_ch.cloud.subnet: + uuid: "{{ snet.uuid }}" + state: absent + register: snet + check_mode: yes +- name: 'VERIFY: Delete subnet in check mode' + assert: + that: + - snet is changed + - snet.cidr == cloudscale_subnet_cidr + - snet.uuid == subnet_uuid + - snet.state == "present" + - snet.network.zone.slug == cloudscale_test_zone + +- name: Delete subnet + cloudscale_ch.cloud.subnet: + uuid: "{{ snet.uuid }}" + state: absent + register: snet +- name: 'VERIFY: Delete subnet' + assert: + that: + - snet is changed + - snet.cidr == cloudscale_subnet_cidr + - snet.uuid == subnet_uuid + - snet.state == "absent" + - snet.network.zone.slug == cloudscale_test_zone + +- name: Delete subnet idempotence + cloudscale_ch.cloud.subnet: + uuid: "{{ snet.uuid }}" + state: absent + register: snet +- name: 'VERIFY: Delete subnet idempotence' + assert: + that: + - snet is not changed + - snet.uuid == subnet_uuid + - snet.state == "absent" diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/aliases new file mode 100644 index 00000000..c200a3d2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/aliases @@ -0,0 +1,2 @@ +cloud/cloudscale +unsupported diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/meta/main.yml new file mode 100644 index 00000000..2083f0e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - common diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/cleanup.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/cleanup.yml new file mode 100644 index 00000000..e7abce57 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/cleanup.yml @@ -0,0 +1,5 @@ +--- +- name: Remove test server + cloudscale_ch.cloud.server: + uuid: '{{ server.uuid }}' + state: 'absent' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/failures.yml new file mode 100644 index 00000000..4962a7a7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/failures.yml @@ -0,0 +1,38 @@ +--- +- name: Create two volumes with the same name + uri: + url: 'https://api.cloudscale.ch/v1/volumes' + method: POST + headers: + Authorization: 'Bearer {{ cloudscale_api_token }}' + body: + name: '{{ cloudscale_resource_prefix }}-duplicate' + size_gb: 50 + body_format: json + status_code: 201 + register: duplicate + with_sequence: count=2 + +- name: Try access to duplicate name + cloudscale_ch.cloud.volume: + name: '{{ cloudscale_resource_prefix }}-duplicate' + size_gb: 10 + register: vol + ignore_errors: True +- name: 'VERIFY: Try access to duplicate name' + assert: + that: + - vol is failed + +- name: Fail volume creation with UUID + cloudscale_ch.cloud.volume: + uuid: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48 + name: '{{ cloudscale_resource_prefix }}-inexistent' + size_gb: 10 + register: vol + ignore_errors: True +- name: 'VERIFY: Fail volume creation with UUID' + assert: + that: + - vol is failed + - vol.msg.startswith("The resource with UUID 'ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48' was not found") diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/main.yml new file mode 100644 index 00000000..653f5446 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/main.yml @@ -0,0 +1,12 @@ +--- +- block: + - import_tasks: setup.yml + - import_tasks: failures.yml + - import_tasks: tests.yml + always: + - import_role: + name: common + tasks_from: cleanup_servers + - import_role: + name: common + tasks_from: cleanup_volumes diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/setup.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/setup.yml new file mode 100644 index 00000000..c256766d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/setup.yml @@ -0,0 +1,9 @@ +--- +- name: Create test instance + cloudscale_ch.cloud.server: + name: '{{ cloudscale_resource_prefix }}-server' + flavor: '{{ cloudscale_test_flavor }}' + zone: '{{ cloudscale_test_zone }}' + image: '{{ cloudscale_test_image }}' + ssh_keys: '{{ cloudscale_test_ssh_key }}' + register: server diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/tests.yml new file mode 100644 index 00000000..9aa9d04e --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/tests.yml @@ -0,0 +1,260 @@ +--- +- name: Create volume in check mode + cloudscale_ch.cloud.volume: + name: '{{ cloudscale_resource_prefix }}-vol' + zone: '{{ cloudscale_test_zone }}' + size_gb: 50 + tags: + project: ansible-test + stage: production + sla: 24-7 + check_mode: yes + register: vol +- name: 'VERIFY: Create volume in check mode' + assert: + that: + - vol is successful + - vol is changed + - vol.state == 'absent' + +- name: Create volume + cloudscale_ch.cloud.volume: + name: '{{ cloudscale_resource_prefix }}-vol' + zone: '{{ cloudscale_test_zone }}' + size_gb: 50 + tags: + project: ansible-test + stage: production + sla: 24-7 + register: vol +- name: 'VERIFY: Create volume' + assert: + that: + - vol is successful + - vol is changed + - vol.size_gb == 50 + - vol.name == '{{ cloudscale_resource_prefix }}-vol' + - vol.zone.slug == '{{ cloudscale_test_zone }}' + - vol.tags.project == 'ansible-test' + - vol.tags.stage == 'production' + - vol.tags.sla == '24-7' + +- name: Create volume idempotence + cloudscale_ch.cloud.volume: + name: '{{ cloudscale_resource_prefix }}-vol' + zone: '{{ cloudscale_test_zone }}' + size_gb: 50 + tags: + project: ansible-test + stage: production + sla: 24-7 + register: vol +- name: 'VERIFY: Create volume idempotence' + assert: + that: + - vol is successful + - vol is not changed + - vol.size_gb == 50 + - vol.name == '{{ cloudscale_resource_prefix }}-vol' + - vol.zone.slug == '{{ cloudscale_test_zone }}' + - vol.tags.project == 'ansible-test' + - vol.tags.stage == 'production' + - vol.tags.sla == '24-7' + +- name: Attach existing volume by name to server in check mode + cloudscale_ch.cloud.volume: + name: '{{ cloudscale_resource_prefix }}-vol' + server_uuids: + - '{{ server.uuid }}' + check_mode: yes + register: vol +- name: 'VERIFY: Attach existing volume by name to server in check mode' + assert: + that: + - vol is successful + - vol is changed + - server.uuid not in vol.server_uuids + +- name: Attach existing volume by name to server + cloudscale_ch.cloud.volume: + name: '{{ cloudscale_resource_prefix }}-vol' + server_uuids: + - '{{ server.uuid }}' + register: vol +- name: 'VERIFY: Attach existing volume by name to server' + assert: + that: + - vol is successful + - vol is changed + - server.uuid in vol.server_uuids + +- name: Attach existing volume by name to server idempotence + cloudscale_ch.cloud.volume: + name: '{{ cloudscale_resource_prefix }}-vol' + server_uuids: + - '{{ server.uuid }}' + register: vol +- name: 'VERIFY: Attach existing volume by name to server idempotence' + assert: + that: + - vol is successful + - vol is not changed + - server.uuid in vol.server_uuids + +- name: Resize attached volume by UUID in check mode + cloudscale_ch.cloud.volume: + uuid: '{{ vol.uuid }}' + size_gb: 100 + check_mode: yes + register: vol +- name: 'VERIFY: Resize attached volume by UUID in check mode' + assert: + that: + - vol is successful + - vol is changed + - vol.size_gb == 50 + +- name: Resize attached volume by UUID + cloudscale_ch.cloud.volume: + uuid: '{{ vol.uuid }}' + size_gb: 100 + register: vol +- name: 'VERIFY: Resize attached volume by UUID' + assert: + that: + - vol is successful + - vol is changed + - vol.size_gb == 100 + +- name: Resize attached volume by UUID idempotence + cloudscale_ch.cloud.volume: + uuid: '{{ vol.uuid }}' + size_gb: 100 + register: vol +- name: 'VERIFY: Resize attached volume by UUID idempotence' + assert: + that: + - vol is successful + - vol is not changed + - vol.size_gb == 100 + +- name: Delete attached volume by UUID in check mode + cloudscale_ch.cloud.volume: + uuid: '{{ vol.uuid }}' + state: 'absent' + check_mode: yes + register: deleted +- name: 'VERIFY: Delete attached volume by UUID in check mode' + assert: + that: + - deleted is successful + - deleted is changed + - deleted.state == 'present' + - deleted.uuid == vol.uuid + - deleted.name == '{{ cloudscale_resource_prefix }}-vol' + +- name: Delete attached volume by UUID + cloudscale_ch.cloud.volume: + uuid: '{{ vol.uuid }}' + state: 'absent' + register: deleted +- name: 'VERIFY: Delete attached volume by UUID' + assert: + that: + - deleted is successful + - deleted is changed + - deleted.state == 'absent' + - deleted.uuid == vol.uuid + - deleted.name == '{{ cloudscale_resource_prefix }}-vol' + +- name: Delete attached volume by UUID idempotence + cloudscale_ch.cloud.volume: + uuid: '{{ vol.uuid }}' + state: 'absent' + register: deleted +- name: 'VERIFY: Delete attached volume by UUID idempotence' + assert: + that: + - deleted is successful + - deleted is not changed + - deleted.state == 'absent' + - deleted.uuid == vol.uuid + - not deleted.name + +- name: Create bulk volume and attach + cloudscale_ch.cloud.volume: + name: '{{ cloudscale_resource_prefix }}-bulk' + type: bulk + zone: '{{ cloudscale_test_zone }}' + size_gb: 100 + server_uuids: + - '{{ server.uuid }}' + register: bulk +- name: 'VERIFY: Create bulk volume and attach' + assert: + that: + - bulk is successful + - bulk is changed + - bulk.size_gb == 100 + - server.uuid in bulk.server_uuids + +- name: Detach volume by UUID + cloudscale_ch.cloud.volume: + uuid: '{{ bulk.uuid }}' + server_uuids: [] + register: bulk +- name: 'VERIFY: Detach volume by UUID' + assert: + that: + - bulk is successful + - bulk is changed + - bulk.server_uuids == [] + +- name: Resize detached volume by name + cloudscale_ch.cloud.volume: + name: '{{ bulk.name }}' + size_gb: 200 + register: bulk +- name: 'VERIFY: Resize detached volume by name' + assert: + that: + - bulk is successful + - bulk is changed + - bulk.size_gb == 200 + +- name: Delete volume by name in check mode + cloudscale_ch.cloud.volume: + name: '{{ bulk.name }}' + state: 'absent' + check_mode: yes + register: bulk +- name: 'VERIFY: Delete volume by name' + assert: + that: + - bulk is successful + - bulk is changed + - bulk.state == 'present' + +- name: Delete volume by name + cloudscale_ch.cloud.volume: + name: '{{ bulk.name }}' + state: 'absent' + register: bulk +- name: 'VERIFY: Delete volume by name' + assert: + that: + - bulk is successful + - bulk is changed + - bulk.state == 'absent' + +- name: Delete volume by name idempotence + cloudscale_ch.cloud.volume: + name: '{{ bulk.name }}' + state: 'absent' + register: bulk +- name: 'VERIFY: Delete volume by name idempotence' + assert: + that: + - bulk is successful + - bulk is not changed + - bulk.state == 'absent' diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/requirements.txt b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/requirements.txt new file mode 100644 index 00000000..4f6a277e --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/requirements.txt @@ -0,0 +1 @@ +netaddr diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/sanity/ignore-2.10.txt b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/sanity/ignore-2.10.txt new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/sanity/ignore-2.10.txt |