Commit graph

90 commits

Author SHA1 Message Date
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
n00b42
129d3e8ddc
feat: add private_networks_info containing name and private ip in server responses (#183)
Co-authored-by: Maximilian Senftleben <maximilian.senftleben@frogblue-tec.com>
2023-01-31 12:29:27 +01:00
n00b42
ccfa51bf66
feat: Pass extra vars to templating of api_token. (#156)
Co-authored-by: Maximilian Senftleben <maximilian.senftleben@frogblue-tec.com>
2023-01-30 12:08:09 +01:00
Julian Tölle
b5f205485a
feat(inventory): connect via public ipv6 address (#176)
Add a new `connect_with` option `public_ipv6` that uses the first
address from the servers publically-routed ipv6 network.
2022-12-21 11:10:58 +01:00
Julian Tölle
2589783e19
fix(server): attached networks are removed when not defined in hcloud_server (#175)
Fixes #174
2022-12-20 14:49:48 +01:00
Konstantin Köhring
ad8958a2ad
Add possibility to specify private network when creating or updating servers (#160)
* Add possibility to specify private network when creating or updating a server

This allows creating servers without public internet access

* Add integration tests
2022-11-09 22:31:03 +01:00
Lukas Kämmerling
6de022e9fb
hcloud_firewall: Fix race condition on deletion of firewalls (#166)
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2022-11-08 14:05:13 +01:00
Lukas Kämmerling
123ad2c1b0
hcloud_volume & hcloud_volume_info: "None" -> null (#165)
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2022-11-08 10:14:24 +01:00
Lukas Kämmerling
d1c97c7e89
Inventory Plugin: Add support for changing the name of the top level group all servers are added to (#164)
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2022-11-08 09:01:14 +01:00
Lukas Kämmerling
2623b75b10
Docs: Document possibility to set the module api_token via environment variable (#163)
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2022-11-08 08:41:17 +01:00
Lukas Kämmerling
78f0a0a519
hcloud_server & hcloud_server_info fix backup window given out as "None" (#162)
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2022-11-07 14:49:19 +01:00
Konstantin Köhring
5cc7c58ecf
fix hcloud_network_info failing without internet connectivity (#159)
This fixes the behavior if there is a server without direct internet
connectivity in the examined network.
Previously, the module would throw an AttributeError because
server.public_net.ipv4/ipv6 is None in this case. Now the None propagates
correctly.
2022-11-07 13:59:21 +01:00
Lukas Kämmerling
a87c82d808
hcloud_firewall: Add support for esp and gre (#161)
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2022-11-07 13:58:43 +01:00
Lukas Kämmerling
6a7088cf42
- hcloud_server_info - fix crash when having servers without IPs (flexible networks) (#143)
- hcloud_server - When state stopped and server is created, do not start the server

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2022-07-13 08:54:55 +02:00
Lukas Kämmerling
0965f79093
Add support for Primary IPs (#141)
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2022-06-29 09:58:01 +02:00
René Moser
1d568f3ac7
loadbalancer_: improve error handlings (#138)
* loadbalancer_: improve error handlings

* streamline a bit to make ansible 2.9 pass

* handle race condition
2022-06-20 06:26:26 +02:00
René Moser
a0a5da3f46
hcloud_load_balancer_target: fix types in examples (#136) 2022-06-17 22:15:35 +02:00
nuux
fae1449c59
fixes alias_ips by using sorted (#134) 2022-06-13 08:58:32 +02:00
Tagir Bakirov
38d3aa6c51
add server status as an option to filter the server inventory list (#126)
* add status as an option to filter the server list

* Update plugins/inventory/hcloud.py

fix the sanity check

Co-authored-by: Lukas Kämmerling <github@lukas-kaemmerling.de>

Co-authored-by: Tagir Bakirov <tagir.bakirov@reservix.de>
Co-authored-by: Lukas Kämmerling <github@lukas-kaemmerling.de>
2022-06-13 08:57:16 +02:00
Florian Sesser
53fa2c1e96
Docs: fix typo (#127)
Co-authored-by: Florian Sesser <hi@flosse.works>
2022-04-25 06:28:21 +02:00
Andrew Klychkov
181949d165
Sanity tests: copy ignore-2.13.txt to ignore-2.14.txt (#125)
* Sanity tests: copy ignore-2.13.txt to ignore-2.14.txt

* Fix sanity
2022-04-22 09:35:17 +02:00
Lukas Kämmerling
51865c29ab
inventory - support jinjia templating within network (#107)
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2021-08-25 10:57:03 +02:00
Adrian Huber
b85f221340
Add support for LB DNS PTRs (#103)
* Add support for Load Balancer DNS PTRs 

* Add changelogs
2021-08-17 14:48:12 +02:00
Adrian Huber
7d3828837c
Placement groups (#102)
* Add placement_groups

* Create server with placement_group

* Add/remove server to/from placement_group

* Remove deprecated tmage test

* Add changelogs

* Add placement groups to hcloud_server_info

* Deprecate force_upgrade flag
2021-08-16 12:31:02 +02:00
Adrian Huber
8cd7b9f997
Add description field to firewall rules (#101) 2021-08-12 13:13:19 +02:00
Lukas Kämmerling
2be9ff3240
hcloud_rdns improve error message on not existing server/Floating IP (#99)
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2021-07-22 09:24:11 +02:00
Lukas Kämmerling
6e171f231f
hcloud_server: Change backups default to None (#97)
When the default is set to false, it always disables the backups when a user do not specify the backups to True always. This shouldn't be the case.

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2021-07-19 07:21:09 +02:00
Lukas Kämmerling
ffd998a0d6
hcloud_server: Improve Error Message when attaching a not existing firewall (#96) 2021-07-16 11:37:33 +02:00
Lukas Kämmerling
f4b336a444
hcloud_volume: Force detaching volume on deletion (#95)
Force detaching of volumes before deleting when they are still attached to a server. This makes it easier for tools like molecule to see the correct state.
2021-07-16 10:55:08 +02:00