Skip to content

Commit

Permalink
refactor: created separate file with common module parts (#188)
Browse files Browse the repository at this point in the history
* refactor: created separate file with common module parts

* test: change test order

* test: change how we import module in tests

* refactor: refactor info module and options

* delete compile module

* fix: docs_generator and update_descriptions fix

* refactor: add info main to module_utils

* refactor: include main methods in module_utils

* doc: possible fix for galaxy docs

* added script to updated DOCUMENTATION and EXAMPLES on modules

* changed some new modules, moved _get_request_id to methods

* refactored alb modules, changed default module to use a list of clients

* refactor: change more info modules

* refactor: change more info modules

* refactor: change remaining info modules

* refactor: changed some regular modules

* refactor: changed more modules, fixed case for multiple user agents

* refactor: changed remaining modules, updated vm_autoscaling_group as module with replacement posibility

* test: updated tests, change user agents attribute type

* doc: updated module documentations

* fix: fixed sonar bugs

* docs: generated docs, fixed some sonar issues

* fix: fixed some sonar issues

* test: removed old test

* fix: user email to check user identity

* fix: wrong constant name

* test: update dataplatform version

* fix workflow

* fix workflow auth

* test: added dataplatform to cleanup

* fix: do_not_replace default value for vm_autoscaling group, error in alb flowlog

* fix: recover transfer_object method, uncomment some tests

* fix: error in dns_secondary_zone module

* fix: error in group module

* fix: fix mongo modules

* test: increate wait timeout

* fix: fix indent in snapshot and missing user agent in alb rule

* test: uncomment tests

* test: random names for container registries

* test: increase timeout

* fix: overwrite some methods for mongo user module, regenerate docs

* chore: update version, added changelog, using galaxy to build local project
  • Loading branch information
rmocanu-ionos authored Feb 26, 2024
1 parent 771e468 commit 1f38fc0
Show file tree
Hide file tree
Showing 268 changed files with 17,784 additions and 32,371 deletions.
4 changes: 4 additions & 0 deletions .github/scripts/cleanup/delete-all-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


# load delete functions
source ./delete-dataplatform-resources.sh
source ./delete-backup-resources.sh
source ./delete-dbaas-resources.sh
source ./delete-user-management-resources.sh
Expand All @@ -18,6 +19,9 @@ source ./delete-nlb-resources.sh
source ./print-utils.sh


echo_step "starting cleanup on Data Platform resources"
delete_dataplatform_resources

echo_step "starting cleanup on Managed Backup resources"
delete_backup_resources

Expand Down
15 changes: 15 additions & 0 deletions .github/scripts/cleanup/delete-dataplatform-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# ENV Vars:
# IONOS_USERNAME - username for IONOS Cloud APIs
# IONOS_PASSWORD - password for IONOS Cloud APIs
# IONOS_TOKEN - token for IONOS Cloud APIs

delete_all_args='--all --force'

function delete_dataplatform_resources() {
ionosctl dataplatform nodepool delete $delete_all_args
ionosctl dataplatform cluster delete $delete_all_args

echo_step_completed
}
1 change: 1 addition & 0 deletions .github/scripts/cleanup/delete-dbaas-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ delete_all_args='--all --force'

function delete_dbaas_resources() {
ionosctl dbaas postgres cluster delete $delete_all_args -W
ionosctl dbaas mongo cluster delete $delete_all_args

echo_step_completed
}
9 changes: 6 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ jobs:
env:
IONOS_USERNAME: ${{ secrets.IONOS_USER_V6 }}
IONOS_PASSWORD: ${{ secrets.IONOS_PASSWORD_V6 }}
IONOS_TOKEN: ${{ secrets.IONOS_PASSWORD_V6 }}
IONOSCTL_VERSION: 6.1.7
IONOS_TOKEN: ${{ secrets.IONOS_TOKEN_V6 }}
IONOSCTL_VERSION: 6.7.4
steps:
- name: Checking out module-ansible
uses: actions/checkout@v2
Expand Down Expand Up @@ -167,9 +167,12 @@ jobs:
python3 -m pip install ionoscloud-logging
python3 -m pip install ionoscloud-vm-autoscaling
- name: Install Ansible
- name: Install Ansible and IONOS module
run: |
python3 -m pip install ansible
ansible-galaxy collection build /home/runner/work/module-ansible/module-ansible/
ansible-galaxy collection install ionoscloudsdk-ionoscloud-$(grep version: galaxy.yml | cut -c10-).tar.gz --force
rm ionoscloudsdk-ionoscloud-$(grep version: galaxy.yml | cut -c10-).tar.gz
- name: Debug pip packages
run: |
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ on:

jobs:
cleanup_test_account:
needs: check_runs
name: Cleanup test account
runs-on: ubuntu-latest
env:
IONOS_USERNAME: ${{ secrets.IONOS_USER_V6 }}
IONOS_PASSWORD: ${{ secrets.IONOS_PASSWORD_V6 }}
IONOS_TOKEN: ${{ secrets.IONOS_PASSWORD_V6 }}
IONOSCTL_VERSION: 6.1.7
IONOS_TOKEN: ${{ secrets.IONOS_TOKEN_V6 }}
IONOSCTL_VERSION: 6.7.4
steps:
- name: Checking out module-ansible
uses: actions/checkout@v2
Expand Down
35 changes: 5 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,37 +84,12 @@ pip install ionoscloud-cert-manager
git clone https://github.com/ionos-cloud/module-ansible
```

2. Ansible must be made aware of the new module path. This too can be accomplished a few different ways depending on your requirements and environment.
2. Install the collection with ansible-galaxy.

* Ansible configuration file: `ansible.cfg`
* Environment variable: `ANSIBLE_LIBRARY`
* Command line parameter: `ansible-playbook --module-path [path]`

2a. The preferred method is to update the Ansible configuration with the module path. To include the path globally for all users, edit the `/etc/ansible/ansible.cfg` file and add `library = /path/to/module/ionos_cloud` under the **\[default\]** section. For example:

```text
[default]
library = /path/to/ionos-module-ansible/ionos_cloud
```

Note that the Ansible configuration file is read from several locations in the following order:

* `ANSIBLE_CONFIG` environment variable path
* `ansible.cfg` from the current directory
* `.ansible.cfg` in the user home directory
* `/etc/ansible/ansible.cfg`

2b. The module path can also be set using an environment variable. This variable will be lost once the terminal session is closed:

```text
export ANSIBLE_LIBRARY=/path/to/ionos-module-ansible/ionos_cloud
```

2c. The module path can be overridden with an `ansible-playbook` command line parameter:

```text
ansible-playbook --module-path /path/to/ionos-module-ansible/ionos_cloud playbook.yml
```
```bash
ansible-galaxy collection build .
ansible-galaxy collection install ionoscloudsdk-ionoscloud-<module_version>.tar.gz
```

## FAQ

Expand Down
31 changes: 3 additions & 28 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,36 +63,11 @@ pip install ionoscloud-cert-manager
git clone https://github.com/ionos-cloud/module-ansible
```

2. Ansible must be made aware of the new module path. This too can be accomplished a few different ways depending on your requirements and environment.

* Ansible configuration file: `ansible.cfg`
* Environment variable: `ANSIBLE_LIBRARY`
* Command line parameter: `ansible-playbook --module-path [path]`

2a. The preferred method is to update the Ansible configuration with the module path. To include the path globally for all users, edit the `/etc/ansible/ansible.cfg` file and add `library = /path/to/module/ionos_cloud` under the **\[default\]** section. For example:

```conf
[default]
library = /path/to/ionos-module-ansible/ionos_cloud
```

Note that the Ansible configuration file is read from several locations in the following order:

* `ANSIBLE_CONFIG` environment variable path
* `ansible.cfg` from the current directory
* `.ansible.cfg` in the user home directory
* `/etc/ansible/ansible.cfg`

2b. The module path can also be set using an environment variable. This variable will be lost once the terminal session is closed:

```bash
export ANSIBLE_LIBRARY=/path/to/ionos-module-ansible/ionos_cloud
```

2c. The module path can be overridden with an `ansible-playbook` command line parameter:
2. Install the collection with ansible-galaxy.

```bash
ansible-playbook --module-path /path/to/ionos-module-ansible/ionos_cloud playbook.yml
ansible-galaxy collection build .
ansible-galaxy collection install ionoscloudsdk-ionoscloud-<module_version>.tar.gz
```

## FAQ
Expand Down
12 changes: 1 addition & 11 deletions docs/api/applicationloadbalancer/application_load_balancer.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This is a simple module that supports creating or removing Application Loadbalan
datacenter: DatacenterName
wait: true
state: absent

```

&nbsp;
Expand Down Expand Up @@ -140,11 +140,6 @@ This is a simple module that supports creating or removing Application Loadbalan
<td>The ID or name of the datacenter.</td>
</tr>
<tr>
<td>allow_replace<br/><mark style="color:blue;">bool</mark></td>
<td align="center">False</td>
<td>Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead<br />Default: False</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos API base URL.</td>
Expand Down Expand Up @@ -337,11 +332,6 @@ This is a simple module that supports creating or removing Application Loadbalan
<td>The ID or name of the Application Loadbalancer.</td>
</tr>
<tr>
<td>allow_replace<br/><mark style="color:blue;">bool</mark></td>
<td align="center">False</td>
<td>Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead<br />Default: False</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos API base URL.</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This is a simple module that supports creating or removing Application Loadbalan
application_load_balancer: AppLoadBalancerName
flowlog: FlowlogName
state: absent

```

&nbsp;
Expand Down Expand Up @@ -138,11 +138,6 @@ This is a simple module that supports creating or removing Application Loadbalan
<td>The ID or name of the Application Loadbalancer.</td>
</tr>
<tr>
<td>allow_replace<br/><mark style="color:blue;">bool</mark></td>
<td align="center">False</td>
<td>Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead<br />Default: False</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos API base URL.</td>
Expand Down Expand Up @@ -342,11 +337,6 @@ This is a simple module that supports creating or removing Application Loadbalan
<td>The ID or name of the Flowlog.</td>
</tr>
<tr>
<td>allow_replace<br/><mark style="color:blue;">bool</mark></td>
<td align="center">False</td>
<td>Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead<br />Default: False</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos API base URL.</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ This is a simple module that supports listing Flowlogs.
<td>The ID or name of the Application Loadbalancer.</td>
</tr>
<tr>
<td>filters<br/><mark style="color:blue;">dict</mark></td>
<td>depth<br/><mark style="color:blue;">int</mark></td>
<td align="center">False</td>
<td>Filter that can be used to list only objects which have a certain set of propeties. Filters should be a dict with a key containing keys and value pair in the following format:'properties.name': 'server_name'</td>
<td>The depth used when retrieving the items.<br />Default: 1</td>
</tr>
<tr>
<td>depth<br/><mark style="color:blue;">int</mark></td>
<td>filters<br/><mark style="color:blue;">dict</mark></td>
<td align="center">False</td>
<td>The depth used when retrieving the items.<br />Default: 1</td>
<td>Filter that can be used to list only objects which have a certain set of propeties. Filters should be a dict with a key containing keys and value pair in the following format: 'properties.name': 'server_name'</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# application_load_balancer_forwardingrule

This is a simple module that supports creating or removing Application Loadbalancer Flowlog rules.
This is a simple module that supports creating or removing Application Loadbalancer Forwarding rules.

## Example Syntax

Expand Down Expand Up @@ -48,7 +48,7 @@ This is a simple module that supports creating or removing Application Loadbalan
application_load_balancer: AppLoadBalancerName
forwarding_rule: "RuleName - UPDATED"
state: absent

```

&nbsp;
Expand Down Expand Up @@ -206,11 +206,6 @@ This is a simple module that supports creating or removing Application Loadbalan
<td>The ID or name of the Application Loadbalancer.</td>
</tr>
<tr>
<td>allow_replace<br/><mark style="color:blue;">bool</mark></td>
<td align="center">False</td>
<td>Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead<br />Default: False</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos API base URL.</td>
Expand Down Expand Up @@ -433,11 +428,6 @@ This is a simple module that supports creating or removing Application Loadbalan
<td>The ID or name of the Application Loadbalancer forwarding rule.</td>
</tr>
<tr>
<td>allow_replace<br/><mark style="color:blue;">bool</mark></td>
<td align="center">False</td>
<td>Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead<br />Default: False</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos API base URL.</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ This is a simple module that supports listing Forwarding Rules.
<td>The ID or name of the Application Loadbalancer.</td>
</tr>
<tr>
<td>filters<br/><mark style="color:blue;">dict</mark></td>
<td>depth<br/><mark style="color:blue;">int</mark></td>
<td align="center">False</td>
<td>Filter that can be used to list only objects which have a certain set of propeties. Filters should be a dict with a key containing keys and value pair in the following format:'properties.name': 'server_name'</td>
<td>The depth used when retrieving the items.<br />Default: 1</td>
</tr>
<tr>
<td>depth<br/><mark style="color:blue;">int</mark></td>
<td>filters<br/><mark style="color:blue;">dict</mark></td>
<td align="center">False</td>
<td>The depth used when retrieving the items.<br />Default: 1</td>
<td>Filter that can be used to list only objects which have a certain set of propeties. Filters should be a dict with a key containing keys and value pair in the following format: 'properties.name': 'server_name'</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ This is a simple module that supports listing Application Load Balancers.
<td>The ID or name of the datacenter.</td>
</tr>
<tr>
<td>filters<br/><mark style="color:blue;">dict</mark></td>
<td>depth<br/><mark style="color:blue;">int</mark></td>
<td align="center">False</td>
<td>Filter that can be used to list only objects which have a certain set of propeties. Filters should be a dict with a key containing keys and value pair in the following format:'properties.name': 'server_name'</td>
<td>The depth used when retrieving the items.<br />Default: 1</td>
</tr>
<tr>
<td>depth<br/><mark style="color:blue;">int</mark></td>
<td>filters<br/><mark style="color:blue;">dict</mark></td>
<td align="center">False</td>
<td>The depth used when retrieving the items.<br />Default: 1</td>
<td>Filter that can be used to list only objects which have a certain set of propeties. Filters should be a dict with a key containing keys and value pair in the following format: 'properties.name': 'server_name'</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
Expand Down
12 changes: 1 addition & 11 deletions docs/api/applicationloadbalancer/target_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This is a simple module that supports creating or removing Target Groups.
wait: true
wait_timeout: 2000
state: absent

```

&nbsp;
Expand Down Expand Up @@ -184,11 +184,6 @@ This is a simple module that supports creating or removing Target Groups.
<td>Array of items in the collection.</td>
</tr>
<tr>
<td>allow_replace<br/><mark style="color:blue;">bool</mark></td>
<td align="center">False</td>
<td>Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead<br />Default: False</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos API base URL.</td>
Expand Down Expand Up @@ -375,11 +370,6 @@ This is a simple module that supports creating or removing Target Groups.
<td>The ID or name of the Target Group.</td>
</tr>
<tr>
<td>allow_replace<br/><mark style="color:blue;">bool</mark></td>
<td align="center">False</td>
<td>Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead<br />Default: False</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
<td align="center">False</td>
<td>The Ionos API base URL.</td>
Expand Down
8 changes: 4 additions & 4 deletions docs/api/applicationloadbalancer/target_group_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ This is a simple module that supports listing Target Groups.
</thead>
<tbody>
<tr>
<td>filters<br/><mark style="color:blue;">dict</mark></td>
<td>depth<br/><mark style="color:blue;">int</mark></td>
<td align="center">False</td>
<td>Filter that can be used to list only objects which have a certain set of propeties. Filters should be a dict with a key containing keys and value pair in the following format:'properties.name': 'server_name'</td>
<td>The depth used when retrieving the items.<br />Default: 1</td>
</tr>
<tr>
<td>depth<br/><mark style="color:blue;">int</mark></td>
<td>filters<br/><mark style="color:blue;">dict</mark></td>
<td align="center">False</td>
<td>The depth used when retrieving the items.<br />Default: 1</td>
<td>Filter that can be used to list only objects which have a certain set of propeties. Filters should be a dict with a key containing keys and value pair in the following format: 'properties.name': 'server_name'</td>
</tr>
<tr>
<td>api_url<br/><mark style="color:blue;">str</mark></td>
Expand Down
Loading

0 comments on commit 1f38fc0

Please sign in to comment.