Commit graph

118 commits

Author SHA1 Message Date
Jonas L
e6328d770b
refactor: add plugins top level __init__ (#320)
##### SUMMARY

This make python/pylint happy when using relative imports between
`modules` and `module_utils`.
2023-09-06 16:06:25 +02:00
Julian Tölle
eb4114bad3
ci: setup release-please (#317)
##### SUMMARY

The current release process for this project requires multiple manual
local steps to prepare and then tag the release. This introduces the
standard release-please workflow we have in most of our integrations.

Release-please will open a new PR whenever there is a releasable change
and it updates the CHANGELOG & other files automatically in this PR.
Once the PR is merged a new tag is created.

This repository has some additional complexity as it uses
`antsibull-changelog` to maintain the user-facing changelog. This is
implemented ina second job in the `release-please` workflow which
executes when the release-please PR is updated and then runs
`antsibull-changelog release` against the version. The resulting changes
are pushed as a second commit to the same PR.
2023-09-05 14:49:05 +02:00
Jonas L
aeda12275c
chore: add antsibull-docs lint-collection pre-commit hook (#315)
##### SUMMARY

This check will run a linter against the documentation. I was already
able to fix a few errors.
2023-08-31 15:20:14 +02:00
Jonas L
6844317920
refactor: fix pylint invalid variable name (#312)
##### SUMMARY

Pylint complains about too short/meaningless variable names. We want to
be explicit when naming variables.
2023-08-25 16:19:15 +02:00
Jonas L
c56cbab1a0
refactor: use f-strings (#310)
##### SUMMARY

Replace string interpolation with f-strings. Improves readability, and
should help prevent #309
2023-08-24 11:27:40 +02:00
Jonas L
deee06281e
chore: prepare v2.1.1 (#311)
##### SUMMARY

Prepare v2.1.1 release.

This should also trigger a new publish process, since 2.1.0 never had
the change to be published to ansible-galaxy.
2023-08-23 15:44:10 +02:00
urbanekpj
8f42c4d950
fix: string formatting error on deprecated server type warning (#309)
##### SUMMARY
after deprecating "server type" warning should be shown but due to error
in string message there is crash.
```
 File "/tmp/ansible_hcloud_server_payload__bgoim7j/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 942, in <module>
  File "/tmp/ansible_hcloud_server_payload__bgoim7j/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 925, in main
  File "/tmp/ansible_hcloud_server_payload__bgoim7j/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 858, in present_server
  File "/tmp/ansible_hcloud_server_payload__bgoim7j/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 405, in _create_server
  File "/tmp/ansible_hcloud_server_payload__bgoim7j/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 541, in _get_server_type
  File "/tmp/ansible_hcloud_server_payload__bgoim7j/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py", line 558, in _check_and_warn_deprecated_server
TypeError: %i format: a real number is required, not str
```

##### ISSUE TYPE
- Bugfix Pull Request

##### COMPONENT NAME
hcloud_server

---------

Co-authored-by: jo <ljonas@riseup.net>
2023-08-23 14:08:06 +02:00
Jonas L
372023796a
chore: prepare v2.1.0 (#304)
##### SUMMARY

 Prepare v2.1.0 release.
2023-08-21 09:35:36 +02:00
Jonas L
5475a9929a
feat: target health status in hcloud_load_balancer_info (#305) 2023-08-17 15:25:14 +02:00
renovate[bot]
7d2300f1ec
deps: update dependency hcloud to v1.28.0 (#306)
* deps: update dependency hcloud to v1.28.0

* chore: update vendored files

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: jo <ljonas@riseup.net>
2023-08-17 15:02:50 +02:00
Jonas L
4bb2bb80fa
feat: query floating ip info by name (#303)
##### SUMMARY

Fixes #302 

The feature was missing, this make the floating_ip_info module consistent with what is expected to be implemented. 

##### ISSUE TYPE

- Feature Pull Request


##### COMPONENT NAME

floating_ip_info
2023-08-17 11:50:19 +02:00
Jonas L
e461a890fa
fix: consistently fail on invalid ID in *_info modules (#301)
* fix: consistently fail on invalid ID in `*_info` modules

* remove unused import
2023-08-16 16:14:55 +02:00
Jonas L
32b44647ef
feat: allow caching the hcloud inventory (#287)
* feat: allow caching the hcloud inventory

* chore: add changelog fragment
2023-08-16 11:59:17 +02:00
Jonas L
2d739edc88
feat: use collection version for the inventory user agent (#297) 2023-08-14 15:55:04 +02:00
renovate[bot]
e89835531f
deps: update dependency hcloud to v1.27.2 (#294)
* deps: update dependency hcloud to v1.27.2

* chore: update vendored files

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: jo <ljonas@riseup.net>
2023-08-11 16:09:41 +02:00
Jonas L
5c4079e059
fix: do not error on location_info invalid id (#292)
* test: fix hcloud_location_info with wrong id test

* chore: cleanup hcloud_location_info tests

* fix: error on location_info invalid id
2023-08-09 12:42:22 +02:00
Jonas L
dd5ee78386
feat: replace ansible version with collection version in hcloud user agent (#291)
* feat: use collection version in hcloud user-agent

* chore: add version sync pre-commit hook

* chore: add changelog fragment
2023-08-09 11:34:12 +02:00
renovate[bot]
ff539800aa
deps: update dependency hcloud to v1.27.1 (#290)
* deps: update dependency hcloud to v1.27.1

* chore: update vendored files

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: jo <ljonas@riseup.net>
2023-08-08 18:17:22 +02:00
Jonas L
a0e91d942a
refactor: rename ansible module classes (#284)
* refactor: rename Hcloud class to AnsibleHCloud

* refactor: rename AnsibleHCloud* modules

* refactor: remove Hcloud deprecation wrapper
2023-08-04 09:24:14 +02:00
Jonas L
98afa99904
refactor: use super() to reference parent class (#280) 2023-08-02 12:05:00 +02:00
Jonas L
64b6804b41
refactor: use relative imports for local modules (#279) 2023-07-31 10:12:55 +02:00
Jonas L
652a41df9d
fix!: don't set inventory image vars if server image is undefined (#275)
Related to #116

Don't set "No Image * found" string if the server image is not defined. This is not an intuitive behavior.

This is a breaking change.
2023-07-24 14:44:52 +02:00
Jonas L
c15377c672
feat: improve hcloud library exceptions handling (#243) 2023-07-20 14:34:48 +02:00
Jonas L
51f705c343
chore: use fqcn module names (#273) 2023-07-20 12:14:57 +02:00
renovate[bot]
f197607dad
deps: update dependency hcloud to v1.26.0 (#268)
* deps: update dependency hcloud to v1.26.0

* feat: upgrade vendored files

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: jo <ljonas@riseup.net>
2023-07-19 15:31:18 +02:00
Jonas L
8a6157e8b2
feat: vendor hcloud python dependency (#244)
* chore: ignore venv directories

* chore: ignore integration test generated inventory

* feat: vendor hcloud package

* import https://github.com/hetznercloud/hcloud-python

* use vendored hcloud in modules

* update integration test requirements

* make vendor script self contained

* chore: add  check-hcloud-vendor pre-commit hook

* pin hcloud version to v.1.24.0

* move vendored __version__.py file to _version.py

* update comment about galaxy-importer filename lint
2023-07-11 11:15:08 +02:00
Jonas L
5190535323
feat: remove deprecated facts modules (#251)
Fixes #8
2023-07-05 09:32:03 +02:00
Jonas L
ef802e7351
docs(hcloud_server_network): fix modules params (#250)
Cherry picked from the https://github.com/ansible-collections/hetzner.hcloud/pull/9
2023-07-04 13:48:04 +02:00
Jonas L
98022020a1
feat: add hcloud_iso_info module (#237)
* Added new command hcloud_isos_info.py to get informations from all ISOs on HETZNER cloud.

* continue iso_info implementation

* add changelog

* fixes and improvements

* remove return docs choices for ansible 2.12 support

* rebase changes

* fix wording

Co-authored-by: Julian Tölle <julian.toelle97@gmail.com>

* run tests in group3

Co-authored-by: Julian Tölle <julian.toelle97@gmail.com>

* docs: returned architecture field might be null

* unused/invalid community.general.ipfilter collection in tests

* update wording relevant -> supported

* apply rebase changes

---------

Co-authored-by: patlegu <3754859+patlegu@users.noreply.github.com>
Co-authored-by: Julian Tölle <julian.toelle97@gmail.com>
2023-07-04 09:54:53 +02:00
Jonas L
0fcf4aad22
refactor: use new to_native function path (#238)
e535eb625b/lib/ansible/module_utils/_text.py
2023-06-27 13:17:21 +02:00
Jonas L
10f47eab0f
fix: facts deprecation warnings and result (#236)
The facts deprecation warnings or result dicts had some small nits.
2023-06-27 12:20:14 +02:00
Jonas L
dfff49e31f
chore: setup pre-commit (#234)
* chore: add pre-commit config

* chore: fix pre-commit errors

* chore: add black pre-commit hook

* style: format python files with black

* chore: add isort pre-commit hook

* style: format python files using isort

* chore: add pyupgrade pre-commit hook

* refactor: upgrade code to python3.7

* Allow stacking PRs

Co-authored-by: Julian Tölle <julian.toelle97@gmail.com>

---------

Co-authored-by: Julian Tölle <julian.toelle97@gmail.com>
2023-06-27 11:50:13 +02:00
Jonas L
e83997517d
test: support python >=3.7 for ansible-test (#235)
* test: only test for python >=3.7

* refactor: remove python 2 utc timezone workaround
2023-06-23 14:43:42 +02:00
Jonas L
81129f373d
feat(network): add expose_routes_to_vswitch field (#232) 2023-06-22 13:09:10 +02:00
Jonas L
02516d9a7b
refactor: prefer true/false over yes/no (#226)
* style: format md and yml files using prettier

* refactor: prefer true/false over yes/no
2023-06-21 10:49:54 +02:00
Jonas L
27821140d7
feat(primary_ip): add hcloud_primary_ip_info module (#225)
Co-authored-by: Kevin Castner <kcastner@kcastner.de>
2023-06-20 14:01:55 +02:00
Julian Tölle
23c2d7d228
ci: ubuntu-18.04 is deprecated/EOL (#224)
Update all references to ubuntu-18.04 (and 20.04) to 22.04, as ubuntu
18.04 is EOL and deprecated in Hetzner Cloud. This causes a CI failure
in the main branch:

https://dev.azure.com/ansible/hetzner.hcloud/_build/results?buildId=80941&view=logs&j=fdb818b8-39d8-529a-d9da-324e304604bc&t=2d52cce2-88ce-5057-da88-145e92cee00f&l=1094
2023-06-20 11:38:51 +02:00
Julian Tölle
082153a700
feat: Server Type Deprecation (#222)
* feat(server_type_info): return deprecation info

Co-authored-by: jo <ljonas@riseup.net>

* feat(server): show warning if server-type is deprecated

Co-authored-by: jo <ljonas@riseup.net>

---------

Co-authored-by: jo <ljonas@riseup.net>
2023-06-20 11:38:38 +02:00
Julian Tölle
9b471cbb00
fix(server): TypeError when using deprecated image (#219)
When using a deprecated image with the "allow_deprecated_image" flag,
the script would crash because the string interpolation was not done
correctly. The brackes were in the wrong place.

Error would look like this:

   An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: unsupported operand type(s) for %: 'NoneType' and 'str'
   fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/julian/.ansible/tmp/ansible-tmp-1686564668.6136558-165294-192879183382787/AnsiballZ_hcloud_server.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/home/julian/.ansible/tmp/ansible-tmp-1686564668.6136558-165294-192879183382787/AnsiballZ_hcloud_server.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/julian/.ansible/tmp/ansible-tmp-1686564668.6136558-165294-192879183382787/AnsiballZ_hcloud_server.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.hetzner.hcloud.plugins.modules.hcloud_server', init_globals=dict(_module_fqn='ansible_collections.hetzner.hcloud.plugins.modules.hcloud_server', _modlib_path=modlib_path),\n  File \"/nix/store/95cxzy2hpizr23343b8bskl4yacf4b3l-python3-3.10.11/lib/python3.10/runpy.py\", line 224, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/nix/store/95cxzy2hpizr23343b8bskl4yacf4b3l-python3-3.10.11/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/nix/store/95cxzy2hpizr23343b8bskl4yacf4b3l-python3-3.10.11/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/run/user/1000/ansible_hcloud_server_payload_1g2rf66q/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 927, in <module>\n  File \"/run/user/1000/ansible_hcloud_server_payload_1g2rf66q/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 908, in main\n  File \"/run/user/1000/ansible_hcloud_server_payload_1g2rf66q/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 843, in present_server\n  File \"/run/user/1000/ansible_hcloud_server_payload_1g2rf66q/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 411, in _create_server\n  File \"/run/user/1000/ansible_hcloud_server_payload_1g2rf66q/ansible_hcloud_server_payload.zip/ansible_collections/hetzner/hcloud/plugins/modules/hcloud_server.py\", line 518, in _get_image\nTypeError: unsupported operand type(s) for %: 'NoneType' and 'str'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
2023-06-19 15:17:07 +02:00
Julian Tölle
94a7a59a84
docs: show warning if image_info is used without architecture (#215) 2023-05-16 11:29:53 +02:00
Julian Tölle
90451c22e3
fix(server): only show force_upgrade warning if actually set (#214)
Make sure that we only log the deprecation warning if force_upgrade was actually
set. Right now it also logs because a default value for the field is set.
2023-05-16 11:29:41 +02:00
Julian Tölle
1cf7be0486
feat(server_type): return included traffic (#212) 2023-05-15 09:40:19 +02:00
Julian Tölle
3c2d4df8bb
feat: add support for ARM APIs (#208)
* feat: add architecture fields for image & server type

* feat: filter images by architecture

* feat: select right image by arch on server create & rebuild

* feat(inventory): add architecture field to returned servers

* docs: add changelog for arm features

* chore: prepare v1.11.0
2023-04-12 10:43:19 +02:00
lrsksr
25bce7eabd
fix(server): prevent backups from being disabled when undefined (#196)
* fix(server): prevent backups from being disabled when undefined

With an existing server with backups enabled and the state being either
present, started, stopped, restarted or rebuild and the backups module
parameter not set, the module would disable backups and in turn delete
all existing backups.

The correct behaviour (leave backups untouched when parameter not set)
is implemented by this commit. Strong typing would have prevented this.

* test: verify fix works

---------

Co-authored-by: Julian Tölle <julian.toelle@hetzner-cloud.de>
2023-04-03 12:36:33 +02:00
Julian Tölle
43ae035040
lint: fix unused-import errors (#195)
The linting rule `unused-import` was recently activated in ansible-test.

This commit removes all unused imports to satify the linting rule.
2023-03-31 09:01:22 +02:00
Julian Tölle
60d9cf74a6
fix(server): server still locked after placement_group attach (#192)
In some cases the server was still marked as locked after attaching it to
a placement_group. This caused potential follow up tasks that use the server
to fail.

This happened because the action returned by `add_to_placement_group()` was
not waited upon.

For the detach case this is handled correctly.
2023-02-08 10:07:46 +01:00
Julian Tölle
1863fe512c
feat(inventory): add variable for ipv6 address (#188)
This variable matches the `ansible_host` variable that we set when
`connect_with: public_ipv6`, and allows the user to dynamically choose the
connection method in `compose`.
2023-02-01 12:56:21 +01:00
Julian Tölle
bfe0f7a575
feat(inventory): handle servers that dont work with connect_with setting (#187)
Currently if any of the servers in the inventory do not work with the
selected `connect_with` mode, the script exits and returns 0 servers.
This can happen for example if one of your servers does not have a public
ipv4 address, but you set `connect_with: public_ipv4` (default).

This commit changes the behaviour to log a warning message, and just skip
setting `ansible_host` for this server. This server will not be reachable
by ansible by default, but users can use `compose` to override the
`ansible_host` that we set based on the other variables.
2023-02-01 10:41:36 +01:00
Julian Tölle
83094a121d
feat(inventory): add all private networks as variables (#186)
This can be used in the `compose`, `groups` and `keyed_groups` settings
to dynamically build the inventory.

It also makes it possible for the user to override the `ansible_host`
in `compose`, based on wether or not the server has a public ipv4 address,
with fallback to the address in a specific private network.
2023-01-31 17:09:54 +01:00
Sander van Rossem
9bc9949869
Increase rebuild wait_until_finished() timeout (#189) 2023-01-31 16:48:02 +01:00